:root {
  color-scheme: light;
  --bg: #fff;
  --sidebar: #f7f7f8;
  --surface: #f4f4f5;
  --hover: #ebebed;
  --text: #242529;
  --muted: #707178;
  --border: #e8e8eb;
  --accent: #303238;
  --on-accent: #fff;
  --danger: #b33d40;
  --focus: #557bc2;
  --shadow: 0 16px 64px #00000012;
  --radius: 16px;
  --sidebar-width: 232px;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  font-size: 15px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191a1c;
  --sidebar: #151618;
  --surface: #24262a;
  --hover: #303238;
  --text: #ececef;
  --muted: #aaaab2;
  --border: #33353a;
  --accent: #eeeeef;
  --on-accent: #202124;
  --danger: #ff9b9d;
  --focus: #91b9ff;
  --shadow: 0 16px 64px #0005;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
button,
input,
textarea {
  font: inherit;
}
button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  touch-action: manipulation;
}
button {
  border: 0;
  background: none;
  color: inherit;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
a {
  color: inherit;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
button:hover:not(:disabled) {
  background: var(--hover);
}
[hidden] {
  display: none !important;
}
svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  flex-shrink: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  top: -60px;
  left: 250px;
  z-index: 100;
  background: var(--bg);
  padding: 12px;
}
.skip-link:focus {
  top: 10px;
}
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
}
.sidebar {
  background: var(--sidebar);
  padding: 18px 12px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-left: 10px;
}
.brand {
  font-size: 21px;
  font-weight: 650;
  text-decoration: none;
  letter-spacing: -0.8px;
}
.brand-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 0 2px 3px;
  border-radius: 50%;
  background: var(--text);
}
.icon-button {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}
.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-weight: 550;
}
.shortcut {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  margin: 12px 0 14px;
  min-height: 44px;
  color: var(--muted);
}
.search svg {
  width: 17px;
}
.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 13px;
  outline-offset: 6px;
}
.conversation-list {
  flex: 1;
  overflow: auto;
  min-height: 0;
  scrollbar-width: thin;
}
.group-label {
  font-size: 11px;
  letter-spacing: 0.5px;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 12px;
  margin: 8px 0 3px;
}
.conversation-row {
  display: flex;
  align-items: center;
  position: relative;
  border-radius: 10px;
  margin: 3px 0;
}
.conversation-row:hover,
.conversation-row.active {
  background: var(--bg);
}
.conversation-row.active {
  box-shadow: 0 1px 4px #00000004;
}
.conversation-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  padding: 0 0 0 11px;
  min-height: 44px;
  border-radius: 10px;
  font-size: 13px;
}
.conversation-link svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.conversation-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-menu-button {
  width: 36px;
  min-height: 44px;
  flex-shrink: 0;
  border-radius: 8px;
}
.row-menu-button svg {
  width: 16px;
}
.row-menu {
  position: absolute;
  right: 4px;
  top: 42px;
  z-index: 20;
  min-width: 150px;
  padding: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.row-menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: left;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
}
.danger {
  color: var(--danger);
}
.sidebar-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
  margin: 12px;
}
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 12px;
}
.identity-detail {
  font-size: 11px;
  color: var(--muted);
  margin: 0 10px 4px;
  line-height: 1.6;
}
.identity-button {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 9px;
  padding: 8px;
  border-radius: 12px;
  min-height: 58px;
}
.identity-button > span:nth-child(2) {
  flex: 1;
  min-width: 0;
}
.identity-button strong,
.identity-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-button strong {
  font-size: 13px;
  font-weight: 550;
}
.identity-button small {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}
.identity-button > svg {
  width: 15px;
}
.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--hover);
  border-radius: 50%;
  flex-shrink: 0;
}
.avatar svg {
  width: 18px;
}
.footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.quiet-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 12px;
  color: var(--muted);
}
.quiet-button svg {
  width: 15px;
}
.text-button {
  font-size: 12px;
  min-height: 36px;
  border-radius: 6px;
  padding: 6px;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.main {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
}
.header-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  max-width: 70%;
  gap: 3px;
}
.header-title > span {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 500;
}
.header-title small {
  font-size: 10px;
  color: var(--muted);
}
.chat-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
  scroll-behavior: auto;
}
.welcome {
  max-width: 760px;
  width: 100%;
  padding: 24px;
  text-align: center;
  margin: 0 auto;
}
.is-welcome .chat-scroll {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.welcome-eyebrow {
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--muted);
}
.welcome h1 {
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 550;
  letter-spacing: -1px;
  margin: 17px 0 14px;
}
.welcome p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 27px;
}
.suggestions {
  display: flex;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
}
.suggestions button {
  display: flex;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--border);
  padding: 0 14px;
  border-radius: 22px;
  min-height: 40px;
  font-size: 12px;
}
.suggestions span {
  color: var(--muted);
}
.history {
  width: 100%;
  max-width: 808px;
  margin: auto;
  padding: 22px 24px 12px;
}
.older {
  display: flex;
  margin: 0 auto 20px;
}
.message {
  margin: 20px 0 32px;
  min-width: 0;
}
.message.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-top: 8px;
}
.user-content {
  background: var(--surface);
  border-radius: 18px 18px 5px 18px;
  padding: 12px 18px;
  max-width: 85%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
  font-size: 15px;
}
.assistant-content {
  font-size: 15px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}
.assistant-content > :first-child {
  margin-top: 0;
}
.assistant-content h1,
.assistant-content h2,
.assistant-content h3 {
  font-size: 1.15em;
  line-height: 1.6;
  margin: 25px 0 12px;
  font-weight: 600;
}
.assistant-content p {
  margin: 10px 0 15px;
}
.assistant-content ul,
.assistant-content ol {
  padding-left: 25px;
}
.assistant-content li {
  margin: 5px 0;
}
.assistant-content a {
  color: var(--focus);
}
.assistant-content blockquote {
  border-left: 3px solid var(--border);
  padding-left: 16px;
  margin-left: 0;
  color: var(--muted);
}
.assistant-content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 16px 16px;
  position: relative;
  overflow: auto;
  font:
    13px/1.7 ui-monospace,
    Consolas,
    monospace;
  white-space: pre;
}
.assistant-content code {
  font-family: ui-monospace, Consolas, monospace;
  background: var(--surface);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.assistant-content pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}
.code-copy {
  position: absolute;
  right: 8px;
  top: 4px;
  min-height: 32px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
  border-radius: 6px;
}
.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 16px 0;
}
.assistant-content table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 13px;
}
.assistant-content th,
.assistant-content td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  min-width: 100px;
}
.assistant-content th {
  background: var(--surface);
  font-weight: 550;
}
.assistant-content tr:last-child td {
  border-bottom: 0;
}
.message-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 7px;
  color: var(--muted);
}
.message-actions button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  font-size: 12px;
}
.message-actions svg {
  width: 16px;
  height: 16px;
}
.message-actions .selected {
  color: var(--text);
  background: var(--surface);
}
.message-status {
  font-size: 12px;
  color: var(--muted);
  padding-top: 8px;
  line-height: 1.7;
}
.message-status.error {
  color: var(--danger);
}
.reasoning {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}
.reasoning summary {
  cursor: pointer;
  min-height: 36px;
  padding-top: 6px;
}
.reasoning pre {
  white-space: pre-wrap;
  margin: 5px 0;
  border-left: 2px solid var(--border);
  padding-left: 14px;
  font: inherit;
}
.history-state {
  color: var(--muted);
  font-size: 14px;
  padding: 32px;
  text-align: center;
}
.composer-area {
  width: calc(100% - 48px);
  max-width: 760px;
  justify-self: center;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.is-welcome .composer-area {
  margin-bottom: clamp(44px, 17vh, 190px);
  margin-top: 6px;
}
.composer {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 15px 16px 10px;
  background: var(--bg);
  box-shadow: 0 4px 22px #00000004;
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--text) 26%, var(--border));
}
.composer textarea {
  display: block;
  width: 100%;
  resize: none;
  min-height: 36px;
  max-height: 180px;
  border: 0;
  outline: none;
  background: none;
  color: var(--text);
  line-height: 1.65;
  padding: 0;
  font-size: 15px;
}
.composer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  gap: 12px;
}
.input-hint {
  font-size: 11px;
  color: var(--muted);
}
.send-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
}
.send-button:hover:not(:disabled),
.primary-button:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.15);
}
.send-button svg {
  width: 19px;
}
.composer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  min-height: 28px;
  margin-top: 6px;
}
.composer-meta .text-button {
  min-height: 28px;
  padding: 2px;
}
.disclaimer {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
  text-align: center;
  margin: 2px 0;
}
.mode-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 0 10px;
  color: var(--muted);
}
.app.collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}
.app.collapsed .sidebar {
  visibility: hidden;
  overflow: hidden;
  padding: 0;
}
.drawer-backdrop {
  display: none;
}
dialog {
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  width: min(440px, calc(100vw - 32px));
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  max-height: calc(100dvh - 40px);
  overflow: auto;
}
dialog::backdrop {
  background: #0006;
  backdrop-filter: blur(3px);
}
dialog h2 {
  font-size: 24px;
  font-weight: 550;
  margin: 18px 0 10px;
  letter-spacing: -0.6px;
}
.dialog-brand {
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.5px;
}
.dialog-close {
  position: absolute;
  right: 12px;
  top: 12px;
}
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}
.small {
  font-size: 11px;
}
.auth-tabs {
  display: flex;
  margin: 24px 0 20px;
  border-bottom: 1px solid var(--border);
}
.auth-tabs button {
  flex: 1;
  min-height: 44px;
  color: var(--muted);
}
.auth-tabs .active {
  color: var(--text);
  border-bottom: 2px solid var(--text);
}
.auth-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface);
}
.auth-methods button {
  min-height: 38px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
}
.auth-methods .active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 4px #00000010;
}
.field {
  margin: 16px 0;
}
.field label,
#action-label {
  display: block;
  font-size: 12px;
  margin: 0 0 8px;
}
.field input,
#action-input {
  width: 100%;
  min-height: 46px;
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.field small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
  margin-top: 7px;
}
.primary-button {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
}
#auth-submit,
#resend-code {
  width: 100%;
}
.full-width {
  width: 100%;
}
.form-error {
  font-size: 12px;
  color: var(--danger);
  line-height: 1.7;
  min-height: 10px;
}
.auth-secondary {
  display: block;
  margin: 10px auto;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
  flex-wrap: wrap;
}
.import-list {
  max-height: 200px;
  overflow: auto;
  padding-left: 22px;
  font-size: 13px;
  line-height: 2;
  overflow-wrap: anywhere;
}
.notice {
  position: fixed;
  z-index: 200;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 13px 20px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.6;
}
.hljs-keyword,
.hljs-selector-tag {
  color: #8c54a2;
}
.hljs-string,
.hljs-attr {
  color: #27774b;
}
.hljs-number,
.hljs-literal {
  color: #9d6030;
}
.hljs-comment {
  color: var(--muted);
}
[data-theme="dark"] .hljs-keyword {
  color: #c9a1e0;
}
[data-theme="dark"] .hljs-string {
  color: #9ec9a6;
}
[data-theme="dark"] .hljs-number {
  color: #e3b889;
}
@media (max-width: 768px) {
  .app,
  .app.collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar,
  .app.collapsed .sidebar {
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    visibility: hidden;
    padding: 16px 12px max(12px, env(safe-area-inset-bottom));
    overflow: visible;
    transition:
      transform 0.18s ease,
      visibility 0.18s;
  }
  .app.drawer-open .sidebar {
    visibility: visible;
    transform: translateX(0);
  }
  .drawer-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: #0005;
    z-index: 40;
    border-radius: 0;
  }
  .chat-header {
    padding: 6px 10px;
    height: 58px;
  }
  .main {
    grid-template-rows: 58px minmax(0, 1fr) auto;
  }
  .history {
    padding: 18px 18px 4px;
  }
  .composer-area {
    width: calc(100% - 24px);
  }
  .composer textarea {
    font-size: 16px;
  }
  .composer {
    border-radius: 18px;
    padding: 13px 12px 8px;
  }
  .input-hint {
    font-size: 10px;
  }
  .send-button {
    width: 44px;
    height: 44px;
  }
  .is-welcome .composer-area {
    margin-bottom: clamp(20px, 10vh, 100px);
  }
  .welcome {
    padding: 16px;
  }
  .welcome h1 {
    font-size: 28px;
  }
  .welcome p {
    font-size: 12px;
    margin-bottom: 20px;
  }
  .welcome-eyebrow {
    font-size: 10px;
  }
  .suggestions {
    gap: 6px;
  }
  .suggestions button {
    font-size: 11px;
    gap: 10px;
    min-height: 44px;
    padding: 0 12px;
  }
  .assistant-content,
  .user-content {
    font-size: 15px;
  }
  .user-content {
    max-width: 92%;
  }
  .row-menu-button {
    width: 44px;
  }
  .disclaimer {
    font-size: 9px;
  }
  .composer-meta {
    font-size: 10px;
  }
  .shortcut {
    display: none;
  }
  dialog {
    padding: 26px 22px;
  }
  .field input {
    font-size: 16px;
  }
}
@media (max-height: 600px) {
  .is-welcome .composer-area {
    margin-bottom: 12px;
  }
  .welcome-eyebrow,
  .welcome p {
    display: none;
  }
  .welcome h1 {
    font-size: 25px;
    margin: 8px 0 14px;
  }
  .welcome {
    padding: 12px;
  }
  .suggestions {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
