:root {
  --bg-page: #edf2f7;
  --bg-app: #ffffff;
  --bg-soft: #f5f5f5;
  --bg-chip: #ffffff;
  --text-main: #06070a;
  --text-muted: #8d96a3;
  --border: #e9ebef;
  --border-blue: #afd0ff;
  --brand: #337cff;
  --brand-strong: #1c66f2;
  --assistant: #f4f6f8;
  --user: #e7f0ff;
  --shadow: 0 20px 80px rgba(27, 39, 63, 0.16);
  color-scheme: light;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC",
    "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(221, 232, 244, 0.72), rgba(247, 249, 252, 0.9)),
    var(--bg-page);
  color: var(--text-main);
  display: grid;
  place-items: center;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  width: min(100%, 430px);
  height: min(100dvh, 932px);
  min-height: 640px;
  background: var(--bg-app);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.topbar {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  z-index: 3;
}

.topbar-actions,
.tool-group,
.composer-toolbar,
.attachment-row {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 10px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: transparent;
  color: #17191d;
  display: inline-grid;
  place-items: center;
  flex: 0 0 36px;
  transition:
    background 0.16s ease,
    transform 0.16s ease;
}

.icon-button:hover {
  background: #f2f4f7;
}

.icon-button:active {
  transform: scale(0.94);
}

.icon-button.tiny {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  font-size: 24px;
  line-height: 1;
  color: #7e8795;
}

.split-icon {
  width: 16px;
  height: 16px;
  border: 1.8px solid #111318;
  border-radius: 5px;
  position: relative;
}

.split-icon::after {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 6px;
  width: 1.8px;
  background: #111318;
  border-radius: 2px;
}

.desktop-button {
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
  color: #17191d;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.windows-mark {
  width: 14px;
  height: 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
}

.windows-mark span {
  border-radius: 1px;
}

.windows-mark span:nth-child(1) {
  background: #f25022;
}

.windows-mark span:nth-child(2) {
  background: #7fba00;
}

.windows-mark span:nth-child(3) {
  background: #00a4ef;
}

.windows-mark span:nth-child(4) {
  background: #ffb900;
}

.avatar-button {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: #252a31;
  flex: 0 0 36px;
}

.main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.empty-state {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(300px, 1fr) auto;
  padding: 0 16px 8px;
  overflow-y: auto;
}

.welcome {
  align-self: center;
  justify-self: center;
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 24px;
  transform: translateY(28px);
}

.welcome h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
  font-weight: 760;
  letter-spacing: 0;
  text-align: center;
}

.mode-switch {
  width: min(326px, 100%);
  height: 56px;
  padding: 3px;
  border-radius: 28px;
  background: #f2f2f3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.mode-option {
  border-radius: 25px;
  background: transparent;
  color: #757c86;
  font-size: 16px;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.mode-option.is-active {
  background: #ffffff;
  color: #14161a;
  box-shadow: 0 2px 5px rgba(14, 18, 26, 0.08);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: end;
  padding-bottom: 8px;
}

.suggestions p {
  width: 100%;
  margin: 0 0 2px 3px;
  color: var(--text-muted);
  font-size: 13px;
}

.suggestions button {
  max-width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg-chip);
  color: #15181d;
  text-align: left;
  line-height: 1.35;
  white-space: normal;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 18px;
  display: none;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.messages.has-content {
  display: flex;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.message.user {
  justify-content: flex-end;
}

.bot-mark {
  width: 30px;
  height: 30px;
  border-radius: 11px;
  color: #ffffff;
  background:
    linear-gradient(150deg, #3a86ff 0%, #25c2a0 52%, #f7b733 100%);
  display: grid;
  place-items: center;
  font-weight: 760;
  flex: 0 0 30px;
  box-shadow: 0 4px 10px rgba(51, 124, 255, 0.2);
}

.bubble {
  max-width: min(310px, 84%);
  padding: 11px 13px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.assistant .bubble {
  background: var(--assistant);
  color: #15181d;
  border-top-left-radius: 8px;
}

.message.user .bubble {
  background: var(--user);
  color: #071a3d;
  border-top-right-radius: 8px;
}

.image-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin-bottom: 8px;
  color: #245fae;
  background: rgba(51, 124, 255, 0.09);
  border: 1px solid rgba(51, 124, 255, 0.18);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8d96a3;
  animation: typing 1.1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.14s;
}

.typing span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes typing {
  0%,
  80%,
  100% {
    opacity: 0.32;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer {
  flex: 0 0 auto;
  padding: 8px 16px max(16px, env(safe-area-inset-bottom));
  background: #f7fbff;
}

.composer-card {
  border: 1px solid var(--border-blue);
  border-radius: 20px;
  background: #ffffff;
  padding: 13px 13px 10px;
  box-shadow: 0 10px 30px rgba(51, 124, 255, 0.1);
}

.composer-card:focus-within {
  border-color: #80b3ff;
  box-shadow: 0 0 0 3px rgba(51, 124, 255, 0.12);
}

.attachment-panel {
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 14px;
  background: #f6f8fb;
}

.attachment-panel label {
  display: block;
  color: #697383;
  font-size: 13px;
  margin-bottom: 7px;
}

.attachment-row {
  gap: 6px;
}

.attachment-row input {
  min-width: 0;
  width: 100%;
  height: 36px;
  border: 1px solid #dfe5ee;
  border-radius: 10px;
  padding: 0 10px;
  outline: none;
  color: #161a20;
  background: #ffffff;
}

.attachment-row input:focus {
  border-color: #8abaff;
}

#messageInput {
  width: 100%;
  max-height: 148px;
  min-height: 32px;
  border: 0;
  outline: 0;
  resize: none;
  padding: 2px 4px 8px;
  color: #161a20;
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
}

#messageInput::placeholder {
  color: #a7afba;
}

.composer-toolbar {
  min-height: 36px;
  justify-content: space-between;
  gap: 10px;
}

.tool-group {
  min-width: 0;
  gap: 4px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: #edf0f5;
  margin: 0 4px;
}

.tool-button,
.send-button {
  height: 34px;
  border-radius: 17px;
  background: transparent;
  color: #252a32;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.tool-button {
  padding: 0 7px;
}

.tool-button:hover,
.send-button:hover {
  background: #f1f4f8;
}

.chat-dot {
  width: 15px;
  height: 15px;
  border: 1.8px solid #1d222a;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.chat-dot::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -2px;
  width: 5px;
  height: 5px;
  border-right: 1.8px solid #1d222a;
  border-bottom: 1.8px solid #1d222a;
  border-bottom-right-radius: 2px;
}

.grid-icon {
  width: 15px;
  height: 15px;
  display: grid;
  grid-template-columns: repeat(2, 5px);
  grid-template-rows: repeat(2, 5px);
  gap: 3px;
}

.grid-icon::before,
.grid-icon::after,
.grid-icon span {
  content: "";
}

.grid-icon {
  background:
    radial-gradient(circle at 2.5px 2.5px, #1d222a 2px, transparent 2.2px),
    radial-gradient(circle at 12.5px 2.5px, #1d222a 2px, transparent 2.2px),
    radial-gradient(circle at 2.5px 12.5px, #1d222a 2px, transparent 2.2px),
    radial-gradient(circle at 12.5px 12.5px, #1d222a 2px, transparent 2.2px);
}

.send-button {
  flex: 0 1 auto;
  min-width: 98px;
  padding: 0 2px 0 10px;
  color: #323945;
}

.send-button.is-ready {
  color: var(--brand-strong);
  background: rgba(51, 124, 255, 0.08);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.send-mark {
  font-size: 24px;
  line-height: 1;
  transform: translateY(-1px);
}

.drawer {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.drawer.is-open {
  pointer-events: auto;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(14, 18, 26, 0);
  transition: background 0.2s ease;
}

.drawer.is-open .drawer-scrim {
  background: rgba(14, 18, 26, 0.26);
}

.drawer-panel {
  width: min(320px, 82vw);
  height: 100%;
  padding: 18px 14px;
  background: #ffffff;
  transform: translateX(-102%);
  transition: transform 0.22s ease;
  box-shadow: 20px 0 60px rgba(15, 23, 42, 0.14);
}

.drawer.is-open .drawer-panel {
  transform: translateX(0);
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  margin-bottom: 18px;
}

.brand-orb {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background:
    linear-gradient(150deg, #3a86ff 0%, #27c4a9 52%, #ffc44d 100%);
  color: #ffffff;
  font-weight: 760;
}

.drawer-action,
.history-item,
.sheet-panel button {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  background: #f5f7fa;
  color: #171b22;
  text-align: left;
  padding: 0 13px;
}

.drawer-action:hover,
.history-item:hover,
.sheet-panel button:hover {
  background: #edf2f8;
}

.drawer-section p {
  margin: 22px 0 8px 4px;
  color: #8d96a3;
  font-size: 13px;
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: grid;
  align-items: end;
  background: rgba(14, 18, 26, 0.24);
  padding: 0 12px max(12px, env(safe-area-inset-bottom));
}

.sheet-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 126px;
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(14, 18, 26, 0.86);
  color: #ffffff;
  font-size: 13px;
  z-index: 30;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  white-space: nowrap;
}

.toast.is-visible {
  opacity: 1;
}

@media (max-width: 760px) {
  body {
    display: block;
    background: #ffffff;
  }

  .app {
    width: min(100%, 430px);
    height: 100dvh;
    min-height: 100dvh;
    box-shadow: none;
  }

  .desktop-button {
    padding: 0 12px;
  }

  .welcome h1 {
    font-size: 27px;
  }
}

@media (max-width: 360px) {
  .topbar {
    padding-left: 12px;
    padding-right: 10px;
  }

  .desktop-button {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tool-button {
    padding: 0 5px;
  }

  .send-button {
    min-width: 82px;
  }

  #modelLabel {
    max-width: 78px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
