:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7f7f7;
  --surface-hover: #efefef;
  --ink: #0d0d0d;
  --muted: #676767;
  --faint: #9b9b9b;
  --line: #e5e5e5;
  --line-strong: #d6d6d6;
  --accent: #0f7f54;
  --accent-soft: #e6f4ee;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.1);
  --rail: 58px;
  --composer: 870px;
  font-family: "Aptos", "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  color: var(--ink);
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(15, 127, 84, 0.1);
}

.is-hidden {
  display: none !important;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  background: var(--bg);
}

.rail {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 14px 9px;
  border-right: 1px solid var(--line);
  background: #fbfbfb;
}

.rail-logo,
.rail-btn,
.rail-account,
.icon-btn,
.mobile-menu {
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink);
}

.rail-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.rail-logo span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.rail-actions {
  display: grid;
  gap: 10px;
}

.rail-btn,
.rail-account,
.icon-btn,
.mobile-menu {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  transition: background 0.16s ease, transform 0.16s ease;
}

.rail-btn:hover,
.rail-account:hover,
.icon-btn:hover,
.mobile-menu:hover {
  background: var(--surface-hover);
}

.rail-account {
  margin-top: auto;
}

.rail-account span,
.avatar-small,
.assistant-mark {
  display: grid;
  place-items: center;
  background: var(--surface-hover);
  color: var(--ink);
  font-weight: 850;
}

.rail-account span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.history-panel {
  position: fixed;
  inset: 0 auto 0 var(--rail);
  z-index: 20;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: #f7f7f7;
  transform: translateX(calc(-100% - var(--rail)));
  transition: transform 0.22s ease;
  box-shadow: 22px 0 54px rgba(0, 0, 0, 0.12);
}

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

.history-head,
.topbar,
.brand-switch,
.top-actions,
.prompt-row,
.settings-row,
.message-meta,
.image-actions,
.history-foot,
.user-row,
.balance-card,
.new-chat-wide,
.tool-pill,
.style-drawer,
.auth-badges {
  display: flex;
  align-items: center;
}

.history-head {
  justify-content: space-between;
  min-height: 38px;
}

.history-head strong {
  font-size: 15px;
}

.new-chat-wide {
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}

.new-chat-wide:hover {
  background: var(--surface-hover);
}

.conversation-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.conversation-item {
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.conversation-item:hover,
.conversation-item.is-active {
  background: #ececec;
}

.conversation-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item small {
  color: var(--muted);
  font-size: 12px;
}

.history-foot {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.balance-card,
.user-row {
  width: 100%;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.balance-card:hover,
.user-row:hover {
  background: #ececec;
}

.balance-card small,
.user-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.balance-card strong,
.user-row strong {
  display: block;
  margin-top: 2px;
}

.avatar-small {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.user-row {
  justify-content: flex-start;
}

.workspace {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr) auto;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
}

.brand-switch {
  min-width: 0;
  gap: 8px;
}

.brand-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 19px;
  font-weight: 760;
}

.brand-name:hover {
  background: var(--surface-hover);
}

.top-actions {
  gap: 10px;
  margin-left: auto;
}

.plain-btn,
.outline-btn,
.primary-btn {
  min-height: 40px;
  padding: 0 17px;
  border-radius: 999px;
  font-weight: 750;
}

.plain-btn {
  background: var(--ink);
  color: #fff;
}

.outline-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.plain-btn:hover {
  background: #262626;
}

.outline-btn:hover {
  background: var(--surface-hover);
}

.balance-pill {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #0a6542;
  font-weight: 820;
}

.mobile-menu {
  display: none;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 36px max(22px, calc((100vw - var(--rail) - var(--composer)) / 2)) 28px;
}

.empty-state {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding-bottom: 12vh;
  text-align: center;
}

.empty-state h1 {
  margin: 0;
  font-size: clamp(25px, 3vw, 32px);
  font-weight: 520;
  letter-spacing: 0;
}

.empty-state p {
  max-width: 590px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.suggestion-grid {
  width: min(680px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.suggestion-card {
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.suggestion-card:hover {
  background: var(--surface-hover);
}

.message {
  width: min(var(--composer), 100%);
  margin: 0 auto 24px;
}

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

.message.assistant {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
}

.assistant-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
}

.message-body {
  min-width: 0;
}

.message.user .message-body {
  max-width: min(690px, 100%);
  padding: 11px 15px;
  border-radius: 18px;
  background: var(--surface-soft);
}

.message-body p {
  margin: 0;
  color: var(--ink);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.message-meta {
  gap: 8px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.message-meta strong {
  color: var(--ink);
  font-size: 13px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.image-card {
  position: relative;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.image-card img,
.image-skeleton {
  display: block;
  width: 100%;
  aspect-ratio: var(--ratio, 1 / 1);
  object-fit: cover;
  background: var(--surface-soft);
}

.image-skeleton {
  position: relative;
  overflow: hidden;
}

.image-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: shimmer 1.35s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.image-caption {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.image-actions {
  position: absolute;
  right: 8px;
  top: 8px;
  gap: 6px;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.image-card:hover .image-actions,
.image-card:focus-within .image-actions {
  opacity: 1;
  transform: translateY(0);
}

.image-actions .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.composer-dock {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0 22px 14px;
  background: linear-gradient(180deg, transparent, #fff 30%);
}

.style-drawer {
  width: min(var(--composer), 100%);
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  display: none;
}

.style-drawer.is-open {
  display: flex;
}

.style-chip,
.tool-pill {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 740;
}

.style-chip:hover,
.tool-pill:hover {
  background: var(--surface-hover);
}

.style-chip.is-active {
  border-color: rgba(15, 127, 84, 0.22);
  background: var(--accent-soft);
  color: #0a6542;
}

.composer {
  width: min(var(--composer), 100%);
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.09);
  overflow: hidden;
}

.prompt-row {
  gap: 8px;
  padding: 10px 12px;
}

.prompt-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  max-height: 150px;
  resize: none;
  border: 0;
  padding: 9px 4px;
  background: transparent;
  line-height: 1.5;
  box-shadow: none;
}

.prompt-row textarea:focus {
  box-shadow: none;
}

.mic-btn {
  color: var(--muted);
}

.send-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
}

.send-btn:hover {
  background: #2a2a2a;
}

.settings-row {
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 12px;
}

.settings-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.settings-row select {
  min-height: 32px;
  max-width: 190px;
  border-radius: 999px;
  padding: 0 28px 0 10px;
  background: var(--surface-soft);
}

.tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cost-preview {
  margin-left: auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dock-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(18px);
}

.auth-card {
  position: relative;
  width: min(430px, 100%);
  display: grid;
  gap: 15px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
}

.auth-close:hover {
  background: var(--surface-hover);
}

.auth-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.auth-card h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.auth-copy,
.fine-print {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.fine-print {
  font-size: 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
}

.endpoint-details {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.endpoint-details summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.compact-field {
  margin-top: 12px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 50px;
  background: var(--ink);
  color: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 60;
  max-width: min(430px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.15;
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    display: none;
  }

  .history-panel {
    inset: 0 auto 0 0;
    width: min(286px, calc(100vw - 52px));
    transform: translateX(-105%);
  }

  .workspace {
    width: 100vw;
    min-width: 0;
    grid-template-rows: 56px minmax(0, 1fr) auto;
  }

  .topbar {
    padding: 0 12px;
  }

  .mobile-menu {
    display: grid;
  }

  .brand-name {
    font-size: 17px;
    padding: 0 8px;
  }

  .outline-btn {
    display: none;
  }

  .messages {
    padding: 24px 14px 18px;
    overflow-x: hidden;
  }

  .empty-state {
    align-content: center;
    padding-bottom: 6vh;
  }

  .empty-state p {
    max-width: calc(100vw - 48px);
    font-size: 14px;
    word-break: break-all;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
    width: min(680px, calc(100vw - 48px));
  }

  .suggestion-card {
    min-height: 54px;
    padding: 11px 13px;
    font-size: 14px;
    word-break: break-all;
  }

  .message.assistant {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
  }

  .assistant-mark {
    width: 28px;
    height: 28px;
  }

  .composer-dock {
    padding: 0 10px 10px;
    overflow-x: hidden;
  }

  .composer {
    width: min(var(--composer), calc(100vw - 28px));
  }

  .settings-row label {
    flex: 1 1 132px;
    min-width: 0;
  }

  .settings-row select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .tool-pill,
  .cost-preview {
    flex: 1 1 auto;
    justify-content: center;
  }
}

@media (max-width: 520px) {
  .top-actions {
    gap: 6px;
  }

  .plain-btn,
  .outline-btn {
    min-height: 36px;
    padding: 0 12px;
  }

  .balance-pill {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .empty-state h1 {
    font-size: 25px;
  }

  .composer {
    border-radius: 22px;
  }

  .mic-btn {
    display: none;
  }

  .prompt-row {
    gap: 6px;
    padding: 9px 10px;
  }

  .settings-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .settings-row label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .prompt-row {
    align-items: flex-end;
  }

  .tool-pill,
  .cost-preview {
    width: 100%;
  }

  .auth-card {
    padding: 24px;
  }
}
