:root {
  color-scheme: light;
  --bg: #f8fbff;
  --panel: #ffffff;
  --panel-soft: #EAF4F6;
  --panel-strong: #202124;
  --text: #202124;
  --muted: #5f6368;
  --line: #dfe6f1;
  --line-strong: #c9d6e6;
  --primary: #0B3A42;
  --primary-strong: #06272D;
  --accent: #2B6CB0;
  --accent-yellow: #fbbc04;
  --danger: #ea4335;
  --warning: #f29900;
  --success: #188038;
  --shadow: 0 18px 48px rgba(60, 64, 67, 0.14);
  --shadow-soft: 0 8px 24px rgba(60, 64, 67, 0.1);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-root {
  min-height: 100dvh;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.auth-page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 460px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.18)),
    var(--bg);
}

.auth-visual {
  min-height: 100dvh;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(135deg, #F7FAFC 0%, #EAF4F6 48%, #ffffff 100%);
  border-right: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0;
  color: #3c4043;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-statement {
  max-width: 620px;
}

.auth-statement h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1.02;
  letter-spacing: 0;
  color: #202124;
}

.auth-statement p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.auth-panel-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #ffffff;
}

.auth-panel {
  width: min(100%, 380px);
}

.auth-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.auth-panel > p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 22px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f1f4f9;
}

.auth-tab {
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.auth-tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.register-type-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.register-type-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #ffffff;
  font-weight: 800;
}

.register-type-tab.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(11, 58, 66, 0.18);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  outline: 0;
  color: var(--text);
  background: #ffffff;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

.code-btn {
  height: 46px;
  border: 1px solid rgba(11, 58, 66, 0.32);
  border-radius: var(--radius);
  color: var(--primary);
  background: #f8fbff;
  font-weight: 800;
}

.code-btn:hover {
  border-color: rgba(11, 58, 66, 0.58);
  background: #EAF4F6;
}

.demo-code-banner {
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px dashed rgba(11, 58, 66, 0.42);
  border-radius: var(--radius);
  color: #0B3A42;
  background: #EAF4F6;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.demo-code-banner[hidden] {
  display: none;
}

.agreement-field {
  margin: 2px 0 16px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.agreement-field input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.text-link,
.inline-link {
  border: 0;
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 800;
}

.text-link:hover,
.inline-link:hover {
  color: var(--primary-strong);
  text-decoration: underline;
}

.forgot-link,
.back-login {
  width: max-content;
  margin: 12px auto 0;
  display: block;
}

.legal-dock {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: var(--line-strong);
  font-size: 13px;
}

.legal-dock span {
  width: 1px;
  height: 12px;
  background: var(--line);
}

.field input:focus,
.composer textarea:focus {
  border-color: rgba(11, 58, 66, 0.72);
  box-shadow: 0 0 0 4px rgba(11, 58, 66, 0.13);
}

.primary-btn,
.ghost-btn,
.icon-btn,
.toggle-btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.primary-btn {
  width: 100%;
  height: 46px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(11, 58, 66, 0.25);
}

.primary-btn:hover {
  background: var(--primary-strong);
}

.ghost-btn {
  height: 38px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.ghost-btn:hover {
  color: var(--text);
  background: #f7fafb;
}

.error-banner {
  min-height: 42px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--danger);
  background: rgba(194, 65, 81, 0.09);
  border: 1px solid rgba(194, 65, 81, 0.2);
  line-height: 1.45;
}

.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 33, 36, 0.42);
}

.legal-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.legal-head {
  min-height: 58px;
  padding: 0 14px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.legal-head strong {
  font-size: 18px;
}

.legal-body {
  padding: 16px 18px 18px;
  color: #3c4043;
  line-height: 1.72;
}

.legal-body p {
  margin: 0 0 12px;
}

.legal-body p:last-child {
  margin-bottom: 0;
}

.error-banner:empty {
  display: none;
}

.chat-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  background: var(--bg);
}

.sidebar {
  min-height: 100dvh;
  padding: 18px 14px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.new-chat-btn {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

.new-chat-btn:hover {
  border-color: rgba(11, 58, 66, 0.36);
  background: #f8fbff;
  box-shadow: var(--shadow-soft);
}

.chat-list {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.chat-item {
  width: 100%;
  min-height: 44px;
  margin: 4px 0;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.chat-item:hover {
  background: #f1f6ff;
  color: var(--text);
}

.chat-item.active {
  background: var(--panel-soft);
  color: var(--text);
  border-color: rgba(11, 58, 66, 0.22);
}

.chat-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.delete-chat {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  display: grid;
  place-items: center;
  opacity: 0;
}

.chat-item:hover .delete-chat,
.chat-item.active .delete-chat {
  opacity: 1;
}

.delete-chat:hover {
  color: var(--danger);
  background: rgba(234, 67, 53, 0.08);
}

.user-strip {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
}

.user-chip {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #3c4043;
  color: #ffffff;
  font-weight: 800;
}

.user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-color: var(--line);
  color: var(--muted);
  background: #ffffff;
}

.icon-btn:hover {
  color: var(--primary);
  border-color: rgba(11, 58, 66, 0.38);
  background: #f8fbff;
}

.chat-main {
  min-width: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.topbar {
  width: 100%;
  min-width: 0;
  min-height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar-title {
  min-width: 0;
  flex: 1 1 0;
}

.topbar-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.topbar-title span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #3c4043;
  background: #ffffff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(60, 64, 67, 0.08);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(52, 168, 83, 0.12);
}

.status-pill.demo .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(251, 188, 4, 0.16);
}

.mobile-menu {
  display: none;
}

.messages {
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px clamp(16px, 4vw, 48px) 18px;
  scroll-behavior: smooth;
}

.message-stack {
  min-width: 0;
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.empty-state {
  min-height: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(28px, 8vh, 88px) 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.empty-state h1 {
  margin: 0 0 14px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: 0;
}

.empty-state p {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.message {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
}

.message.user .message-avatar {
  grid-column: 2;
  background: var(--primary);
}

.message.user .message-bubble {
  grid-column: 1;
  justify-self: end;
  background: #EAF4F6;
  border-color: #d2e3fc;
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: conic-gradient(from 220deg, #0B3A42, #2B6CB0, #7AA6C2, #0B3A42);
}

.message-bubble {
  min-width: 0;
  max-width: min(760px, 100%);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.message-tools {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.mini-tool {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #ffffff;
}

.mini-tool:hover {
  color: var(--primary);
  border-color: rgba(11, 58, 66, 0.36);
  background: #f8fbff;
}

.message-content {
  overflow-wrap: anywhere;
  line-height: 1.72;
  font-size: 15.5px;
}

.ai-disclaimer {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.message-content > :first-child {
  margin-top: 0;
}

.message-content > :last-child {
  margin-bottom: 0;
}

.message-content p,
.message-content ul,
.message-content ol,
.message-content blockquote,
.message-content pre,
.message-content table {
  margin: 0.86em 0;
}

.message-content pre {
  overflow: auto;
  padding: 13px 14px;
  border-radius: 7px;
  background: #202124;
  color: #f8fafc;
}

.message-content code {
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: #f1f3f4;
  color: #3c4043;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.message-content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.message-content blockquote {
  padding-left: 14px;
  border-left: 3px solid var(--primary);
  color: var(--muted);
}

.message-content a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(11, 58, 66, 0.28);
}

.message-content .table-scroll {
  max-width: 100%;
  margin: 0.86em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.message-content table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  display: table;
  margin: 0;
}

.message-content th,
.message-content td {
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  min-width: 120px;
}

.message-content th {
  background: #EAF4F6;
  color: #202124;
  font-weight: 800;
}

.message-content td:last-child,
.message-content th:last-child {
  border-right: 0;
}

.message-content tr:last-child td {
  border-bottom: 0;
}

.typing-cursor {
  display: inline-block;
  width: 7px;
  height: 1.15em;
  margin-left: 2px;
  vertical-align: -0.18em;
  background: var(--primary);
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.composer-wrap {
  width: 100%;
  min-width: 0;
  padding: 10px clamp(16px, 4vw, 48px) 18px;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0), var(--bg) 36%);
}

.composer {
  max-width: 920px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 16px 44px rgba(60, 64, 67, 0.16);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
}

.composer-input-zone {
  min-width: 0;
}

.composer textarea {
  width: 100%;
  min-height: 46px;
  max-height: 180px;
  resize: none;
  border: 1px solid transparent;
  border-radius: 6px;
  outline: 0;
  padding: 11px 12px;
  color: var(--text);
  line-height: 1.45;
}

.send-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 8px 20px rgba(11, 58, 66, 0.25);
}

.send-btn:hover {
  background: var(--primary-strong);
}

.send-btn.stop {
  background: var(--danger);
  box-shadow: 0 8px 20px rgba(234, 67, 53, 0.18);
}

.composer-meta {
  max-width: 920px;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #18212f;
  color: #ffffff;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  z-index: 20;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.sidebar-scrim {
  display: none;
}

@media (max-width: 860px) {
  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    display: none;
  }

  .auth-panel-wrap {
    min-height: 100dvh;
  }

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(288px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 30;
    box-shadow: var(--shadow);
  }

  .chat-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.38);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 25;
  }

  .chat-shell.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    padding: 0 14px;
  }

  .status-pill {
    display: none;
  }

  .messages {
    padding-inline: 14px;
  }

  .code-row {
    grid-template-columns: minmax(0, 1fr) 104px;
  }

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

  .message.user .message-avatar {
    grid-column: 1;
  }

  .message.user .message-bubble {
    grid-column: 2;
    justify-self: stretch;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
  }

  .message-bubble {
    max-width: 100%;
  }

  .composer-wrap {
    padding: 8px 12px 14px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .send-btn {
    width: 42px;
    height: 42px;
  }
}
