:root {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #202723;
  background: #f3f5f3;
  font-synthesis: none;
  --ground: #f3f5f3;
  --surface: #ffffff;
  --raised: #f7f8f7;
  --active: #e4e8e5;
  --border: #e3e7e4;
  --control: #c8ceca;
  --text: #202723;
  --muted: #5b665f;
  --accent: #287d68;
  --primary: #26352e;
  --negative: #98402f;
  --radius: 8px;
  --answer-size: 16px;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; }
button:disabled { cursor: default; color: var(--muted); background: var(--raised); border-color: var(--border); }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select { min-width: 0; color: var(--text); background: var(--surface); border: 1px solid var(--control); border-radius: 6px; }
input { width: 100%; min-height: 44px; padding: 10px 12px; }
input::placeholder { color: #667069; opacity: 1; }
input:focus { border-color: var(--accent); }
label { display: block; font-weight: 600; line-height: 20px; }
h1, h2, h3, p { margin: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 650; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); stroke-width: 2; }
.brand-name { color: var(--muted); font-size: 14px; font-weight: 400; margin-left: 4px; }
.primary, .secondary { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 40px; padding: 9px 16px; font-weight: 600; border: 1px solid transparent; border-radius: 6px; line-height: 20px; }
.primary { color: #ffffff; background: var(--primary); }
.primary:hover { background: #17271e; }
.primary:disabled { color: #ffffff; background: #5b665f; }
.secondary { color: var(--text); border-color: var(--control); background: var(--surface); }
.secondary:hover { border-color: #8a968e; background: var(--raised); }
.compact { min-height: 34px; padding: 6px 12px; font-size: 12px; }
.text-button { color: var(--text); background: none; min-height: 36px; padding: 6px 0; line-height: 24px; }
.text-button:hover { text-decoration: underline; text-underline-offset: 4px; }
.icon-button { width: 36px; min-width: 36px; height: 36px; padding: 8px; display: inline-grid; place-items: center; color: var(--muted); border: 1px solid transparent; border-radius: 6px; background: transparent; }
.icon-button:hover { background: var(--active); color: var(--text); }
.auth-screen { min-height: 100dvh; display: flex; flex-direction: column; }
.auth-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 28px 40px; }
.auth-layout { display: grid; grid-template-columns: minmax(320px, 420px) minmax(400px, 504px); align-items: start; justify-content: center; gap: 96px; padding: 48px 40px 64px; margin: auto 0; }
.auth-form { padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.auth-form h1 { font-size: 28px; line-height: 36px; font-weight: 600; }
.auth-description { color: var(--muted); margin: 12px 0 28px; line-height: 24px; }
.field { margin-top: 20px; }
.field label { margin-bottom: 8px; }
.field-hint { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 20px; }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-field .icon-button { position: absolute; right: 0; top: 0; width: 44px; height: 44px; }
.form-error { color: var(--negative); font-size: 12px; line-height: 20px; margin: 12px 0; }
.form-error:empty { display: none; }
.auth-submit { width: 100%; min-height: 44px; margin-top: 20px; }
.auth-toggle { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 16px; color: var(--muted); }
.auth-toggle .text-button { font-weight: 600; }
.auth-companion { padding-top: 24px; }
.auth-companion h2 { font-size: 24px; line-height: 32px; font-weight: 500; }
.auth-companion > p { margin-top: 12px; font-size: 16px; line-height: 28px; color: var(--muted); }
.reading-example { display: grid; grid-template-columns: .8fr 1.2fr; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 28px; overflow: hidden; }
.example-question, .example-answer { padding: 24px; }
.example-question { background: #eef1ee; }
.example-label { font-size: 12px; color: var(--muted); }
.reading-example p { line-height: 28px; margin-top: 14px; }
.reading-example .example-equation { font-size: 18px; white-space: nowrap; margin-top: 10px; }
.example-caption { display: block; margin-top: 14px; font-size: 12px; line-height: 20px; color: var(--muted); }
.setup-list { padding: 0; margin: 28px 0 0; list-style: none; display: grid; gap: 20px; }
.setup-list li { display: grid; grid-template-columns: 132px 1fr; gap: 16px; line-height: 24px; }
.setup-list strong { font-weight: 500; }
.setup-list span { color: var(--muted); }
.auth-footer { text-align: center; padding: 16px 24px 24px; font-size: 12px; color: var(--muted); }
/* 1440 = 248 sidebar + 8 gap + 1184 canvas; canvas = 32 + 304 question + 24 gap + 792 answer + 32. */
.workspace { height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 8px; overflow: hidden; }
.sidebar { min-width: 0; display: flex; flex-direction: column; padding: 28px 16px 16px; background: var(--ground); }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.sidebar .brand { font-size: 16px; gap: 8px; }
.sidebar .brand-mark { width: 28px; height: 28px; }
.sidebar .brand-name { font-size: 12px; }
.new-conversation { margin-top: 32px; justify-content: flex-start; padding-left: 14px; }
.search-field { position: relative; margin-top: 16px; }
.search-field > svg { position: absolute; left: 12px; top: 11px; color: var(--muted); width: 16px; height: 16px; }
.search-field input { padding-left: 36px; min-height: 38px; font-size: 14px; }
.list-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); padding: 24px 10px 12px; font-size: 12px; }
.conversation-list { overflow-y: auto; flex: 1; min-height: 80px; }
.conversation-item { display: block; width: 100%; color: var(--text); background: none; text-align: left; border: 1px solid transparent; border-radius: 6px; padding: 12px; margin-bottom: 4px; min-height: 64px; }
.conversation-item:hover { border-color: var(--control); }
.conversation-item.active { background: var(--active); }
.conversation-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; line-height: 22px; }
.conversation-date { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 18px; }
.list-empty { font-size: 12px; color: var(--muted); line-height: 22px; padding: 12px; }
.sidebar-help { display: flex; justify-content: space-between; padding: 12px; font-size: 12px; margin-top: 16px; text-align: left; }
.account { display: flex; gap: 10px; align-items: center; padding: 16px 8px 0; border-top: 1px solid var(--border); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; background: #e0e5e1; border-radius: 50%; color: #414f45; font-size: 14px; }
.account-info { min-width: 0; flex: 1; }
.account-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.account-info > span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.main { display: flex; flex-direction: column; min-width: 0; background: var(--surface); border-radius: 8px 0 0 0; overflow: hidden; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 28px 32px 24px; }
.header-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.heading-content { min-width: 0; }
.workspace-context { color: var(--muted); font-size: 12px; line-height: 20px; margin-bottom: 6px; }
.workspace-header h1 { font-size: 24px; font-weight: 600; line-height: 32px; overflow-wrap: anywhere; }
.session-label { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 20px; }
.header-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.connection-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection-state i { width: 6px; height: 6px; border-radius: 50%; background: #838c86; }
.connection-state.connected i { background: var(--accent); }
.connection-state.reconnecting i { background: #986d27; }
.reading-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 32px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.jump-field { display: flex; align-items: center; gap: 12px; min-width: 0; }
.jump-field label { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.jump-field select { max-width: 360px; width: 260px; min-height: 34px; padding: 6px 32px 6px 10px; font-size: 12px; text-overflow: ellipsis; }
.reading-options { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.question-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#reading-size[aria-pressed="true"] { background: var(--active); border-color: #8b978f; }
.workspace-error { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 16px 32px 0; padding: 12px 16px; border: 1px solid #e6cdc3; background: #fbf5f2; border-radius: 6px; font-size: 14px; color: #793f2b; }
.workspace-error p { line-height: 24px; }
.workspace-error .text-button { white-space: nowrap; }
.reading-area { padding: 28px 32px 32px; flex: 1; overflow-y: auto; min-height: 0; scroll-padding-top: 24px; }
.history-loading { padding: 24px; background: var(--raised); color: var(--muted); border-radius: var(--radius); }
.empty-state { max-width: 560px; margin: 48px auto; text-align: left; padding: 28px; background: var(--raised); border: 1px solid var(--border); border-radius: var(--radius); }
.empty-mark { width: 32px; height: 32px; color: var(--muted); margin-bottom: 20px; }
.empty-state h2 { font-size: 24px; line-height: 32px; font-weight: 500; }
.empty-state > p { margin: 12px 0 20px; color: var(--muted); font-size: 16px; line-height: 28px; }
.empty-guide { display: grid; gap: 12px; margin-top: 28px; font-size: 12px; color: var(--muted); line-height: 20px; }
.messages { display: flex; flex-direction: column; gap: 40px; }
.message { display: grid; grid-template-columns: minmax(230px, 304px) minmax(0, 1fr); gap: 24px; align-items: start; scroll-margin-top: 24px; }
.question-card { min-width: 0; padding: 20px; background: var(--raised); border: 1px solid var(--border); border-radius: var(--radius); }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; font-size: 12px; line-height: 20px; color: var(--muted); }
.meta-tag { color: var(--text); font-weight: 600; }
.card-meta time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.question-text { font-size: 16px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.question-source { margin-top: 16px; color: var(--muted); font-size: 12px; line-height: 20px; }
.answer-card { min-width: 0; padding: 0 0 28px; border-bottom: 1px solid var(--border); }
.answer-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; min-height: 32px; }
.answer-heading h2 { font-size: 16px; font-weight: 600; line-height: 24px; }
.message-status { flex: none; white-space: nowrap; color: var(--muted); background: #f0f2f0; border-radius: 4px; padding: 3px 7px; font-size: 12px; line-height: 18px; }
.message-status.streaming { color: #256149; background: #eaf3ed; }
.message-status.error { color: #87432e; background: #fbede6; }
.copy-answer { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); background: none; padding: 6px 0 6px 8px; min-height: 32px; white-space: nowrap; font-size: 12px; }
.copy-answer svg { width: 16px; height: 16px; }
.copy-answer:hover { color: var(--text); }
.copy-answer:disabled { background: none; color: var(--muted); }
.answer-content { font-size: var(--answer-size); line-height: 1.95; color: var(--text); overflow-wrap: anywhere; }
.answer-content p { white-space: pre-wrap; margin-bottom: 16px; }
.answer-content p:last-child { margin-bottom: 0; }
.answer-content h3, .answer-content h4 { font-size: 16px; line-height: 26px; font-weight: 600; margin: 24px 0 10px; }
.answer-content h3:first-child, .answer-content h4:first-child { margin-top: 0; }
.answer-content ul, .answer-content ol { padding-left: 24px; margin: 12px 0 20px; }
.answer-content li { padding-left: 4px; white-space: pre-wrap; }
.answer-content code { font-family: Consolas, monospace; font-size: 14px; background: var(--raised); padding: 2px 5px; border-radius: 4px; }
.answer-content pre { overflow-x: auto; padding: 18px; border: 1px solid var(--border); background: var(--raised); border-radius: 6px; white-space: pre; line-height: 1.7; }
.answer-content pre code { padding: 0; background: none; white-space: pre; }
.answer-content blockquote { margin: 20px 0 0; padding: 12px 16px; background: var(--raised); border-left: 2px solid #aebbb2; color: var(--muted); font-size: 14px; }
.katex { font-size: 1.12em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 12px 0; margin: 12px 0; }
.katex-display > .katex { white-space: nowrap; }
.answer-waiting { color: var(--muted); }
.answer-waiting::after { content: ""; width: 4px; height: 16px; margin-left: 8px; display: inline-block; vertical-align: middle; background: var(--accent); animation: blink 1.2s infinite; }
.message-error { color: var(--negative); border-top: 1px solid var(--border); padding-top: 14px; margin-top: 20px; font-size: 14px; line-height: 24px; white-space: pre-wrap; overflow-wrap: anywhere; }
.workspace-footer { min-height: 56px; padding: 10px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.workspace-footer > span { line-height: 20px; }
dialog { color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 440px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 48px); overflow-y: auto; box-shadow: 0 16px 60px #20272324; }
dialog::backdrop { background: #20272360; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { font-size: 24px; line-height: 32px; font-weight: 600; }
.dialog-description { color: var(--muted); line-height: 24px; margin: 12px 0 24px; }
dialog label { margin-bottom: 8px; }
dialog .primary { width: 100%; }
.help-steps { margin: 20px 0 0; padding-left: 22px; }
.help-steps li { padding-left: 8px; margin-bottom: 20px; }
.help-steps strong { font-size: 14px; font-weight: 600; }
.help-steps p { margin-top: 8px; line-height: 26px; color: var(--muted); }
.help-note { padding: 16px; background: var(--raised); border-radius: 6px; font-size: 12px; color: var(--muted); line-height: 22px; }
kbd { font: 12px "Segoe UI", "Microsoft YaHei", sans-serif; border: 1px solid var(--control); border-radius: 4px; padding: 1px 4px; white-space: nowrap; background: var(--surface); color: var(--text); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); border-radius: 6px; padding: 12px 20px; color: #ffffff; background: #26352e; font-size: 14px; line-height: 24px; z-index: 30; max-width: calc(100vw - 32px); box-shadow: 0 4px 20px #20272320; }
.mobile-only, .sidebar-backdrop { display: none; }
[data-reading="large"] { --answer-size: 18px; }
[hidden] { display: none !important; }
@keyframes blink { 50% { opacity: .25; } }
@media (min-width: 1700px) { .reading-area, .workspace-header { padding-left: 48px; padding-right: 48px; } .reading-toolbar { margin-left: 48px; margin-right: 48px; } .message { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 40px; } }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .main { border-radius: 0; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 292px; z-index: 21; transform: translateX(-100%); visibility: hidden; transition: transform .18s ease, visibility .18s; }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: #20272360; z-index: 20; }
  .mobile-only { display: inline-grid; }
  .workspace-header { padding-top: 24px; }
  .message { grid-template-columns: minmax(200px, .3fr) minmax(0, .7fr); }
  .auth-layout { gap: 40px; padding: 32px; grid-template-columns: minmax(300px, 400px) minmax(300px, 440px); }
  .auth-header { padding: 24px 32px; }
  .example-question, .example-answer { padding: 20px; }
  .reading-example { grid-template-columns: 1fr; }
  .example-question p br { display: none; }
}
@media (max-width: 780px) {
  .auth-layout { display: block; padding: 20px 24px 48px; }
  .auth-form { max-width: 440px; margin: auto; }
  .auth-companion { display: none; }
  .auth-header { padding: 20px 24px; }
  .message { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .question-card { padding: 18px 20px; }
  .question-source { display: none; }
  .answer-card { padding-bottom: 28px; }
  .reading-toolbar { gap: 12px; }
  .jump-field { flex: 1; }
  .jump-field select { width: 100%; max-width: 340px; }
}
@media (max-width: 520px) {
  .auth-layout { padding: 16px 16px 32px; margin: 0; }
  .auth-form { padding: 24px; }
  .auth-header { padding: 20px 24px; }
  .auth-form h1 { font-size: 24px; line-height: 32px; }
  .auth-header .brand-name { display: none; }
  .auth-footer { margin-top: auto; }
  .workspace-header { padding: 16px 20px; align-items: flex-start; gap: 8px; }
  .header-heading { gap: 8px; align-items: flex-start; }
  .header-heading > .icon-button { margin: 16px 0 0 -8px; }
  .workspace-context { margin-bottom: 4px; }
  .workspace-header h1 { font-size: 20px; line-height: 28px; }
  .session-label { display: none; }
  .header-actions { gap: 4px; padding-top: 18px; }
  .header-actions .connection-state { font-size: 12px; gap: 6px; }
  .header-actions #refresh-conversations { display: none; }
  .reading-toolbar { margin: 0 20px; padding: 12px 0; }
  .jump-field label, .question-count { display: none; }
  .jump-field select { min-height: 44px; max-width: 210px; font-size: 14px; }
  .reading-options { gap: 8px; }
  .compact { min-height: 44px; font-size: 12px; padding: 8px 12px; }
  .reading-area { padding: 24px 20px; }
  .messages { gap: 32px; }
  .question-card { padding: 16px; }
  .question-text { font-size: 16px; }
  .answer-heading { gap: 8px; margin-bottom: 16px; }
  .answer-heading h2 { font-size: 16px; }
  .copy-answer { min-height: 44px; padding-left: 0; }
  .copy-answer svg { display: none; }
  .answer-content { line-height: 1.9; }
  .answer-content blockquote { padding: 12px; }
  .workspace-footer { padding: 12px 20px; min-height: 52px; }
  .workspace-footer > span { font-size: 12px; }
  .workspace-footer:has(#latest-answer:not([hidden])) > span { max-width: 170px; }
  #latest-answer { flex-shrink: 0; }
  #latest-answer svg { display: none; }
  .workspace-error { margin: 12px 20px 0; }
  .empty-state { margin: 24px 0; padding: 24px; }
  .empty-state h2 { font-size: 20px; line-height: 28px; }
  .empty-guide { gap: 10px; }
  .sidebar { width: min(320px, 100vw); padding-top: 20px; }
  .icon-button { width: 44px; min-width: 44px; height: 44px; }
  .sidebar .new-conversation { min-height: 44px; }
  .sidebar-help { min-height: 44px; }
  dialog { padding: 24px; }
  .password-field .icon-button { width: 36px; min-width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
