@charset "UTF-8";

/* 小栈 VI · 网页应用。主色来自 references/k12.md；深青绿用于小字与操作的可读性。 */
:root {
  font-family: Arial, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  font-synthesis: none;
  color: var(--text);
  background: var(--page);
  --brand: #18B2A2;
  --brand-secondary: #2DBFA5;
  --lime: #C1D851;
  --brand-strong: #087C72;
  --brand-hover: #06675F;
  --text: #263238;
  --muted: #63686B;
  --quiet: #828E91;
  --page: #F6FAFA;
  --tint: #EDF6F5;
  --line: #D8E4E6;
  --white: #FFFFFF;
  --danger: #A94036;
  --warning: #86601E;
  --focus: var(--brand-strong);
  --radius: 12px;
  --shadow: 0 8px 28px rgb(38 50 56 / 5%);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button, input, textarea, select { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 4px;
}
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.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; left: 20px; top: -80px; z-index: 200; background: var(--white); padding: 12px 18px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

/* Brand and navigation */
.app-shell { height: 100dvh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar { background: var(--white); border-right: 1px solid var(--line); color: var(--muted); padding: 30px 18px 0; display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 0 10px; margin-bottom: 28px; }
.brand-logo { display: block; width: 174px; height: auto; object-fit: contain; }
.brand-sub { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .75rem; line-height: 1.5; letter-spacing: .02em; }
.brand-sub > span { color: #AFBEBC; }
.new-chat { width: 100%; min-height: 46px; border: 1px solid var(--brand); background: var(--brand); border-radius: 9px; color: #133C37; display: flex; align-items: center; gap: 9px; font-size: .875rem; font-weight: 600; padding: 10px 13px; margin-bottom: 24px; transition: background .15s; }
.new-chat > span { font-size: 24px; line-height: 1; font-weight: 400; }
.new-chat:hover { background: var(--brand-secondary); border-color: var(--brand-secondary); }
.new-chat kbd { margin-left: auto; font-size: .75rem; font-family: inherit; font-weight: 400; color: inherit; }
.main-nav { display: grid; gap: 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 12px 14px; border-radius: 9px; text-align: left; font-size: .875rem; }
.nav-item:hover { background: var(--page); color: var(--text); }
.nav-item.active { background: var(--tint); color: var(--brand-strong); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 15px; bottom: 15px; width: 3px; border-radius: 3px; background: var(--brand); }
.nav-item.active > span:first-child { color: var(--brand-strong); }
.nav-count { margin-left: auto; font-size: .75rem; color: var(--brand-strong); background: var(--tint); padding: 3px 7px; border-radius: 5px; font-weight: 500; }
.history-heading { padding: 30px 12px 10px; display: flex; align-items: center; justify-content: space-between; font-size: .75rem; color: var(--muted); }
.history-heading .icon-button { width: 30px; height: 30px; }
.history-heading svg { width: 15px; height: 15px; }
.conversation-list { overflow-y: auto; flex: 1; min-height: 30px; }
.conversation-item { display: block; width: 100%; padding: 12px; text-align: left; color: var(--muted); font-size: .8125rem; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 7px; margin-bottom: 3px; }
.conversation-item:hover, .conversation-item.selected { background: var(--tint); color: var(--brand-strong); }
.history-empty { font-size: .8125rem; color: var(--muted); padding: 9px 12px; line-height: 1.9; white-space: pre-line; }
.sidebar-bottom { margin-top: 20px; }
.vault-indicator { display: flex; align-items: center; gap: 8px; font-size: .75rem; padding: 17px 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.status-dot { display: inline-block; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--quiet); }
.status-dot.green { background: var(--brand); }
.status-dot.amber { background: #AA8227; }
.profile { display: flex; gap: 10px; align-items: center; padding: 18px 7px; }
.profile-avatar { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; background: var(--tint); border: 1px solid var(--line); border-radius: 50%; color: var(--brand-strong); font-size: .875rem; }
.profile strong { font-size: .8125rem; font-weight: 600; color: var(--text); display: block; margin-bottom: 4px; }
.profile > div { min-width: 0; }
.profile div > span { font-size: .75rem; color: var(--muted); display: block; }
.profile .icon-button { margin-left: auto; }
.profile svg { width: 17px; height: 17px; }

/* Working surface */
.main-content { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 76px; flex-shrink: 0; border-bottom: 1px solid var(--line); background: var(--white); display: flex; justify-content: space-between; align-items: center; padding: 0 36px; gap: 18px; }
.topbar-title { display: flex; align-items: center; gap: 18px; min-width: 0; }
.topbar-title strong { font-weight: 600; font-size: 1rem; white-space: nowrap; }
.topbar-title > span:last-child { font-size: .8125rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-divider { height: 16px; width: 1px; background: var(--line); }
.topbar-status { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--muted); background: var(--page); border: 1px solid var(--line); padding: 7px 10px; border-radius: 20px; white-space: nowrap; max-width: 240px; min-width: 0; }
.topbar-status > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.page { min-height: 0; flex: 1; }
.chat-page { display: flex; flex-direction: column; background: var(--page); }
.chat-scroll { flex: 1; min-height: 0; overflow: auto; scroll-behavior: smooth; }
.welcome { max-width: 920px; margin: auto; padding: 52px 40px 26px; }
.welcome-eyebrow { font-size: .8125rem; letter-spacing: .08em; color: var(--brand-strong); display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.tiny-rule { width: 34px; height: 4px; border-radius: 4px; background: linear-gradient(135deg, var(--brand-secondary), var(--lime)); }
.welcome h1 { font-size: clamp(1.75rem, 2.5vw, 2.375rem); font-weight: 600; letter-spacing: -.035em; line-height: 1.4; color: var(--text); }
.welcome-description { font-size: 1rem; line-height: 1.8; color: var(--muted); margin-top: 14px; }
.knowledge-summary { display: flex; align-items: flex-start; gap: 8px; margin-top: 20px; font-size: .8125rem; line-height: 1.7; color: var(--muted); overflow-wrap: anywhere; }
.knowledge-summary svg { height: 17px; width: 17px; color: var(--brand-strong); flex-shrink: 0; margin-top: 2px; }
.knowledge-summary strong { font-weight: 600; color: var(--brand-strong); }
.start-heading { display: flex; justify-content: space-between; gap: 12px; font-size: .875rem; color: var(--text); margin-top: 32px; margin-bottom: 14px; }
.start-heading > span:last-child { font-size: .75rem; color: var(--muted); }
.starter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.starter-card { border: 1px solid var(--line); padding: 18px 20px; text-align: left; display: flex; flex-direction: column; align-items: flex-start; border-radius: var(--radius); background: var(--white); position: relative; min-height: 105px; transition: border-color .16s, box-shadow .16s, transform .16s; }
.starter-card:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-2px); }
.starter-type { font-size: .75rem; color: var(--brand-strong); margin-bottom: 12px; display: flex; align-items: center; gap: 7px; }
.starter-type svg { width: 16px; height: 16px; }
.starter-card:nth-child(2) .starter-type { color: #596822; }
.starter-card:nth-child(2) .starter-type svg { background: #F1F6D9; border-radius: 4px; box-shadow: 0 0 0 4px #F1F6D9; }
.starter-title { font-size: 1rem; font-weight: 600; padding-right: 12px; color: var(--text); line-height: 1.6; }
.starter-arrow { display: none; }
.welcome-note { display: flex; gap: 7px; align-items: flex-start; font-size: .75rem; color: var(--muted); line-height: 1.8; margin-top: 18px; }
.welcome-note svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 3px; }

/* Question composer */
.composer-area { width: 100%; max-width: 1000px; padding: 12px 40px 20px; margin: 0 auto; flex-shrink: 0; }
.configuration-notice { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; margin-bottom: 10px; line-height: 1.6; padding: 0 4px; }
.configuration-notice svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--brand-strong); }
.configuration-notice .text-button { font-size: .75rem; margin-left: auto; white-space: nowrap; }
.composer { border: 1px solid #B4D5CF; border-radius: 16px; background: var(--white); box-shadow: 0 6px 24px rgb(8 124 114 / 6%); padding: 13px 16px 12px; position: relative; }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(24 178 162 / 9%), 0 6px 24px rgb(8 124 114 / 6%); }
.composer-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mode-tabs { display: flex; gap: 3px; background: var(--page); padding: 4px; border-radius: 8px; }
.mode-tab { font-size: .8125rem; color: var(--muted); border-radius: 6px; padding: 7px 12px; white-space: nowrap; min-height: 34px; }
.mode-tab.active { background: var(--tint); color: var(--brand-strong); font-weight: 600; }
.context-label { font-size: .75rem; color: var(--muted); white-space: nowrap; }
#message-input { font-size: 1rem; color: var(--text); line-height: 1.8; resize: none; display: block; width: 100%; background: transparent; border: 0; outline: none; max-height: 160px; padding: 16px 3px 10px; min-height: 80px; }
#message-input::placeholder { color: var(--muted); }
#message-input:focus-visible { outline: none; }
.composer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.composer-tools { display: flex; align-items: center; gap: 7px; min-width: 0; }
.composer-tools > span { color: var(--muted); font-size: .75rem; }
.icon-button { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; padding: 0; color: var(--muted); flex-shrink: 0; }
.icon-button:hover { color: var(--brand-strong); background: var(--tint); }
.composer-tools svg { width: 20px; height: 20px; }
.send-button { display: flex; align-items: center; justify-content: center; gap: 9px; border-radius: 8px; background: var(--brand-strong); color: var(--white); padding: 10px 16px; font-size: .875rem; min-width: 86px; min-height: 42px; font-weight: 600; }
.send-button:hover { background: var(--brand-hover); }
.send-button svg { height: 17px; width: 17px; }
.send-button.stopping { background: var(--text); }
.composer-caption { display: flex; justify-content: space-between; gap: 14px; font-size: .75rem; color: var(--muted); padding: 11px 4px 0; line-height: 1.5; }
.attachment-previews { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 2px; }
.attachment { position: relative; width: 76px; height: 66px; border: 1px solid var(--line); border-radius: 7px; background: var(--tint); }
.attachment img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.attachment button { position: absolute; right: -6px; top: -6px; width: 25px; height: 25px; border-radius: 50%; background: var(--white); border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px; }
.drop-overlay { position: absolute; inset: 0; background: #EDF6F5F5; border: 2px dashed var(--brand); border-radius: 15px; display: grid; place-items: center; font-size: 1rem; color: var(--brand-strong); z-index: 3; }

/* Conversation and source material */
.messages { max-width: 920px; margin: auto; padding: 34px 40px 20px; }
.message { margin-bottom: 34px; }
.message-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: .875rem; color: var(--text); }
.message-avatar { height: 34px; width: 34px; display: grid; place-items: center; flex-shrink: 0; background: var(--white); border: 1px solid var(--line); color: var(--muted); border-radius: 9px; font-size: .875rem; }
.message.assistant .message-avatar { background: var(--tint); border-color: #B4D5CF; color: var(--brand-strong); font-size: 1rem; font-weight: 600; }
.message-name { font-weight: 600; }
.message-mode { font-size: .75rem; font-weight: 400; color: var(--muted); }
.message-body { margin-left: 44px; font-size: 1rem; line-height: 1.9; color: var(--text); overflow-wrap: anywhere; }
.message.user .message-body { white-space: pre-wrap; }
.message.assistant .message-body { min-height: 28px; }
.message-images { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; }
.message-images img { max-width: 220px; max-height: 180px; border: 1px solid var(--line); border-radius: 9px; object-fit: contain; }
.message-actions { display: flex; align-items: center; gap: 12px; margin-left: 44px; margin-top: 10px; color: var(--muted); font-size: .75rem; }
.message-actions button { font-size: .8125rem; color: var(--brand-strong); display: flex; align-items: center; gap: 5px; padding: 7px 0; }
.message-actions svg { width: 15px; height: 15px; }
.message-actions button:hover { color: var(--brand-hover); }
.message-note { font-size: .8125rem; color: var(--muted); margin-left: 44px; margin-top: 10px; line-height: 1.8; }
.message-note.error { color: var(--danger); }
.sources { margin-left: 44px; margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.sources-label { font-size: .75rem; color: var(--muted); margin-bottom: 9px; }
.source-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.source-chip { display: flex; gap: 6px; align-items: center; font-size: .8125rem; max-width: 100%; min-height: 34px; padding: 7px 10px; color: var(--brand-strong); border: 1px solid var(--line); border-radius: 7px; background: var(--white); }
.source-chip:hover { border-color: var(--brand); background: var(--tint); }
.source-chip > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-chip svg { width: 15px; height: 15px; flex-shrink: 0; }
.typing { display: inline-flex; gap: 7px; align-items: center; color: var(--muted); font-size: .875rem; }
.typing::after { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--brand); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.markdown p { margin: 0 0 13px; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { color: var(--text); font-weight: 600; line-height: 1.55; margin: 24px 0 12px; }
.markdown h1 { font-size: 1.625rem; }
.markdown h2 { font-size: 1.375rem; }
.markdown h3 { font-size: 1.125rem; }
.markdown h4 { font-size: 1rem; }
.markdown h1:first-child, .markdown h2:first-child, .markdown h3:first-child { margin-top: 0; }
.markdown strong { font-weight: 600; color: var(--text); }
.markdown ul, .markdown ol { padding-left: 24px; margin: 10px 0 16px; }
.markdown li { padding-left: 3px; margin-bottom: 5px; }
.markdown pre { padding: 16px; background: var(--tint); border: 1px solid var(--line); border-radius: 8px; overflow: auto; line-height: 1.7; margin: 16px 0; }
.markdown code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--tint); border-radius: 4px; padding: 2px 5px; }
.markdown pre code { padding: 0; background: transparent; }
.markdown blockquote { padding: 8px 15px; margin: 12px 0; border-left: 3px solid var(--brand); background: var(--tint); color: var(--muted); border-radius: 0 6px 6px 0; }
.markdown blockquote + blockquote { margin-top: -12px; }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.markdown a { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }
.markdown table { width: 100%; max-width: 100%; border-collapse: collapse; font-size: .875rem; margin: 16px 0; display: block; overflow: auto; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; min-width: 100px; }
.markdown th { background: var(--tint); font-weight: 600; }

/* Library and administration */
.content-page { padding: 38px 40px; overflow: auto; background: var(--page); }
.page-intro { display: flex; justify-content: space-between; gap: 24px; align-items: center; margin-bottom: 30px; }
.eyebrow { font-size: .75rem; letter-spacing: .12em; color: var(--brand-strong); margin-bottom: 14px; }
.page-intro h1 { font-size: 1.875rem; line-height: 1.5; font-weight: 600; letter-spacing: -.02em; }
.page-intro p:not(.eyebrow) { font-size: .9375rem; line-height: 1.8; color: var(--muted); margin-top: 10px; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; white-space: nowrap; font-size: .875rem; padding: 11px 17px; line-height: 1.5; min-height: 44px; font-weight: 500; }
.primary-button { background: var(--brand-strong); color: var(--white); border: 1px solid var(--brand-strong); }
.primary-button:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.secondary-button { background: var(--white); border: 1px solid var(--line); color: var(--brand-strong); }
.secondary-button:hover { background: var(--tint); border-color: #99C8C0; }
.secondary-button svg { width: 17px; height: 17px; }
.text-button { color: var(--brand-strong); padding: 3px 0; font-size: .875rem; }
.text-button:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 4px; }
.knowledge-stats { display: grid; grid-template-columns: 1fr 1fr 1.35fr; border: 1px solid var(--line); background: var(--white); border-radius: var(--radius); margin-bottom: 28px; }
.stat { padding: 23px 26px; border-right: 1px solid var(--line); }
.stat:last-child { border: 0; }
.stat-label { display: block; font-size: .8125rem; color: var(--muted); margin-bottom: 11px; }
.stat-value { font-size: 2rem; font-weight: 600; letter-spacing: -.04em; color: var(--text); }
.stat-value small { font-size: .8125rem; color: var(--muted); letter-spacing: 0; margin-left: 8px; font-weight: 400; }
.stat:last-child .stat-value { font-size: .875rem; letter-spacing: 0; line-height: 2.5; color: var(--brand-strong); }
.library-toolbar { display: flex; gap: 12px; margin-bottom: 24px; }
.search-field { display: flex; align-items: center; gap: 10px; background: var(--white); border: 1px solid var(--line); border-radius: 9px; padding: 0 14px; flex: 1; min-width: 0; }
.search-field svg { width: 19px; height: 19px; color: var(--muted); flex-shrink: 0; }
.search-field input { border: 0; flex: 1; min-width: 0; font-size: .9375rem; padding: 13px 0; color: var(--text); background: transparent; }
.search-field input::placeholder { color: var(--muted); }
.search-field input:focus { outline: none; }
.search-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(24 178 162 / 9%); }
.library-toolbar select { background: var(--white); border: 1px solid var(--line); border-radius: 9px; color: var(--text); padding: 11px 30px 11px 14px; font-size: .875rem; max-width: 225px; }
.library-heading { display: flex; justify-content: space-between; gap: 12px; font-size: .75rem; color: var(--muted); margin-bottom: 12px; padding: 0 3px; }
.library-heading > span:first-child { font-weight: 600; color: var(--text); }
.document-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); overflow: hidden; }
.document-row { display: flex; align-items: flex-start; text-align: left; width: 100%; gap: 16px; padding: 24px; border-bottom: 1px solid var(--line); }
.document-row:last-child { border-bottom: 0; }
.document-row:hover { background: #F2F9F7; }
.document-icon { height: 40px; width: 36px; flex-shrink: 0; color: var(--brand-strong); background: var(--tint); display: grid; place-items: center; border-radius: 7px; }
.document-icon svg { width: 20px; height: 20px; }
.document-row-content { flex: 1; min-width: 0; }
.document-row h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 8px; line-height: 1.5; overflow-wrap: anywhere; }
.document-excerpt { font-size: .875rem; color: var(--muted); line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.document-meta { font-size: .75rem; color: var(--muted); display: flex; gap: 14px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.document-meta > span:first-child { background: var(--tint); color: var(--brand-strong); padding: 3px 8px; border-radius: 4px; }
.document-row-arrow { display: none; }
.empty-state { text-align: center; padding: 48px 24px; font-size: .9375rem; line-height: 1.9; color: var(--muted); }
.empty-state.error { color: var(--danger); }
.settings-page > .page-intro, .settings-page > #settings-form, .settings-page > #settings-loading { max-width: 980px; margin-left: auto; margin-right: auto; }
.admin-tag { font-size: .75rem; color: var(--brand-strong); border: 1px solid #BEDBD5; padding: 7px 10px; border-radius: 6px; background: var(--tint); white-space: nowrap; }
.settings-card { padding: 28px 30px; margin-bottom: 22px; border: 1px solid var(--line); background: var(--white); border-radius: var(--radius); }
.card-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 26px; }
.section-number { color: var(--brand-strong); background: var(--tint); border-radius: 7px; font-size: .8125rem; font-variant-numeric: tabular-nums; padding: 7px 8px; min-width: 33px; }
.card-heading h2 { font-size: 1.125rem; font-weight: 600; line-height: 1.6; }
.card-heading p { font-size: .8125rem; color: var(--muted); margin-top: 7px; line-height: 1.8; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.field { margin-bottom: 22px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: .875rem; font-weight: 600; display: block; margin-bottom: 9px; color: var(--text); }
.field input:not([type=checkbox]), .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: .9375rem; color: var(--text); background: var(--white); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.field textarea { resize: vertical; min-height: 110px; line-height: 1.8; }
.field p, .field-help { font-size: .8125rem; line-height: 1.8; color: var(--muted); margin-top: 9px; }
.optional { font-size: .75rem; font-weight: 400; color: var(--muted); margin-left: 6px; }
.field-badge { font-size: .75rem; color: var(--brand-strong); margin-left: 6px; font-weight: 400; }
.field .checkbox-label { font-size: .8125rem; font-weight: 400; color: var(--muted); margin-top: 11px; display: flex; align-items: center; gap: 7px; }
.checkbox-label input { accent-color: var(--brand-strong); width: 16px; height: 16px; }
.toggle-line { display: flex; align-items: center; justify-content: space-between; padding-top: 22px; border-top: 1px solid var(--line); gap: 22px; }
.toggle-line strong { font-size: .875rem; font-weight: 600; color: var(--text); display: block; }
.toggle-line small { font-size: .8125rem; color: var(--muted); display: block; margin-top: 8px; line-height: 1.8; }
.toggle-line input { appearance: none; width: 42px; height: 24px; border-radius: 20px; background: #B8C8C6; position: relative; flex-shrink: 0; cursor: pointer; transition: background .2s; }
.toggle-line input::after { content: ""; display: block; background: var(--white); width: 18px; height: 18px; position: absolute; top: 3px; left: 3px; border-radius: 50%; box-shadow: 0 1px 3px #0002; transition: transform .2s; }
.toggle-line input:checked { background: var(--brand-strong); }
.toggle-line input:checked::after { transform: translateX(18px); }
.setting-explanation { font-size: .875rem; line-height: 1.9; color: var(--muted); padding: 15px 17px; background: var(--tint); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 24px; }
.settings-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin: 24px 0 14px; }
.settings-actions > span { margin-right: auto; flex: 1; font-size: .8125rem; line-height: 1.7; color: var(--brand-strong); }
.settings-actions > span.error { color: var(--danger); }

/* Document drawer and sign-in */
.document-dialog { position: fixed; inset: 20px 20px 20px auto; margin: 0; width: min(800px, calc(100vw - 40px)); height: calc(100dvh - 40px); max-height: none; max-width: none; border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: 0 16px 70px rgb(38 50 56 / 18%); padding: 0; color: var(--text); }
dialog::backdrop { background: rgb(38 50 56 / 30%); backdrop-filter: blur(3px); }
.document-dialog[open] { display: flex; flex-direction: column; }
.document-dialog-head { padding: 26px 30px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-shrink: 0; background: var(--page); }
.document-category { font-size: .8125rem; color: var(--brand-strong); }
.document-dialog-head h2 { font-size: 1.5rem; font-weight: 600; margin: 10px 0; line-height: 1.5; overflow-wrap: anywhere; }
.document-dialog-head p { font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; line-height: 1.7; }
.document-content { padding: 30px 32px; font-size: 1rem; line-height: 1.95; overflow: auto; overflow-wrap: anywhere; min-height: 0; }
.login-dialog { width: min(440px, calc(100vw - 32px)); padding: 34px; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 70px rgb(38 50 56 / 15%); color: var(--text); }
.login-logo { display: block; width: 178px; max-width: 100%; height: auto; margin-bottom: 30px; object-fit: contain; }
.login-dialog h1 { font-size: 1.5rem; font-weight: 600; line-height: 1.5; }
.login-dialog > p { font-size: .875rem; color: var(--muted); line-height: 1.8; margin-top: 10px; margin-bottom: 26px; }
.login-dialog form { display: flex; flex-direction: column; }
.login-dialog label { font-size: .875rem; color: var(--text); margin-bottom: 9px; }
.login-dialog input, .login-dialog select { border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--text); padding: 12px 14px; font-size: 1rem; margin-bottom: 20px; }
.login-dialog .primary-button { width: 100%; }
.login-dialog .text-button { margin-top: 14px; font-size: .875rem; }
#login-error { font-size: .8125rem; line-height: 1.7; color: var(--danger); margin: 0 0 16px; min-height: 0; }
.toast { position: fixed; bottom: 26px; left: calc(50% + 132px); transform: translateX(-50%); z-index: 100; background: var(--text); color: var(--white); padding: 13px 20px; border-radius: 10px; box-shadow: var(--shadow); font-size: .875rem; max-width: min(85vw, 600px); line-height: 1.7; }
.toast.error { background: var(--danger); }
.mobile-menu, .sidebar-backdrop { display: none; }

@media (min-width: 1450px) {
  .welcome { padding-top: 64px; }
  .starter-card { min-height: 112px; }
  .composer-area { padding-bottom: 26px; }
}
@media (max-height: 820px) and (min-width: 761px) {
  .welcome { padding-top: 28px; }
  .welcome h1 { font-size: 1.875rem; }
  .welcome-eyebrow { margin-bottom: 14px; }
  .welcome-description { margin-top: 10px; }
  .knowledge-summary { margin-top: 12px; }
  .start-heading { margin-top: 23px; margin-bottom: 12px; }
  .starter-card { min-height: 96px; padding-top: 14px; padding-bottom: 14px; }
  .welcome-note { margin-top: 14px; }
  .composer-area { padding-top: 7px; padding-bottom: 12px; }
}
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 234px minmax(0, 1fr); }
  .sidebar { padding-left: 14px; padding-right: 14px; }
  .brand-logo { width: 168px; }
  .brand-sub { gap: 6px; }
  .topbar { padding: 0 26px; }
  .topbar-title > span:last-child, .topbar-divider { display: none; }
  .welcome { padding-left: 28px; padding-right: 28px; }
  .composer-area { padding-left: 26px; padding-right: 26px; }
  .context-label { display: none; }
  .content-page { padding: 30px 28px; }
  .page-intro h1 { font-size: 1.625rem; }
  .settings-card { padding: 24px; }
  .messages { padding-left: 28px; padding-right: 28px; }
  .toast { left: calc(50% + 117px); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 85vw); z-index: 60; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 6px 0 24px rgb(38 50 56 / 6%); padding-top: 25px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; background: rgb(38 50 56 / 30%); z-index: 59; }
  .main-content { height: 100dvh; }
  .topbar { height: 64px; padding: 0 16px; gap: 10px; }
  .mobile-menu { display: inline-flex; margin-left: -7px; }
  .icon-button { width: 40px; height: 40px; }
  .topbar-title { gap: 7px; }
  .topbar-title strong { font-size: .9375rem; }
  .topbar-status { max-width: 145px; padding: 6px 9px; }
  .welcome { padding: 30px 22px 20px; max-width: 610px; }
  .welcome-eyebrow { margin-bottom: 17px; font-size: .75rem; }
  .welcome h1 { font-size: 1.75rem; letter-spacing: -.035em; line-height: 1.5; }
  .welcome-description { font-size: .9375rem; line-height: 1.85; margin-top: 12px; }
  .knowledge-summary { font-size: .75rem; margin-top: 15px; }
  .start-heading { margin-top: 25px; font-size: .8125rem; }
  .start-heading > span:last-child { font-size: .75rem; }
  .starter-grid { gap: 10px; }
  .starter-card { padding: 16px 14px; min-height: 110px; border-radius: 10px; }
  .starter-type { font-size: .75rem; margin-bottom: 10px; gap: 6px; }
  .starter-type svg { width: 14px; height: 14px; }
  .starter-title { font-size: .9375rem; padding-right: 0; }
  .welcome-note { font-size: .75rem; line-height: 1.8; margin-top: 18px; }
  .composer-area { padding: 8px 14px max(12px, env(safe-area-inset-bottom)); max-width: 640px; background: var(--page); }
  .composer { padding: 10px 12px; border-radius: 14px; }
  .mode-tabs { gap: 2px; padding: 3px; }
  .mode-tab { font-size: .8125rem; padding: 7px 10px; min-height: 36px; }
  .composer-top { gap: 3px; }
  #message-input { font-size: 1rem; min-height: 76px; padding-top: 13px; }
  .composer-tools { gap: 4px; }
  .composer-tools > span { font-size: .75rem; }
  .send-button { min-height: 42px; min-width: 78px; padding: 10px 13px; }
  .composer-caption { font-size: .75rem; padding-top: 9px; justify-content: center; }
  .composer-caption > span:first-child { display: none; }
  .configuration-notice { font-size: .75rem; margin-bottom: 9px; gap: 6px; }
  .configuration-notice .text-button { font-size: .75rem; }
  .messages { padding: 26px 19px 16px; }
  .message-body { font-size: 1rem; margin-left: 0; }
  .message-header { margin-bottom: 12px; }
  .sources, .message-actions, .message-note { margin-left: 0; }
  .message-images img { max-width: 170px; max-height: 150px; }
  .content-page { padding: 28px 20px; }
  .page-intro { align-items: flex-start; margin-bottom: 24px; gap: 14px; flex-wrap: wrap; }
  .page-intro h1 { font-size: 1.5rem; }
  .page-intro p:not(.eyebrow) { font-size: .875rem; }
  .eyebrow { font-size: .75rem; }
  .knowledge-stats { grid-template-columns: 1fr 1fr; margin-bottom: 22px; }
  .stat { padding: 19px; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); padding: 14px 19px; display: flex; align-items: center; gap: 18px; }
  .stat:last-child .stat-label { margin: 0; }
  .stat-value { font-size: 1.75rem; }
  .library-toolbar { gap: 9px; margin-bottom: 22px; flex-wrap: wrap; }
  .library-toolbar select { max-width: none; width: 100%; font-size: 1rem; padding: 11px 13px; }
  .search-field { padding: 0 12px; gap: 8px; flex-basis: 100%; }
  .search-field input { font-size: 1rem; }
  .document-row { padding: 19px 16px; gap: 12px; }
  .document-row h3 { font-size: .9375rem; }
  .document-excerpt { font-size: .875rem; }
  .document-icon { width: 30px; height: 36px; }
  .document-meta { font-size: .75rem; gap: 9px; }
  .settings-card { padding: 22px 18px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .card-heading { gap: 10px; margin-bottom: 22px; }
  .card-heading h2 { font-size: 1.0625rem; }
  .card-heading p { font-size: .8125rem; line-height: 1.8; }
  .field { margin-bottom: 22px; }
  .field input:not([type=checkbox]), .field textarea { font-size: 1rem; }
  .settings-actions { flex-wrap: wrap; gap: 10px; }
  .settings-actions > span { flex-basis: 100%; margin-bottom: 3px; }
  .settings-actions .primary-button, .settings-actions .secondary-button { flex: 1; font-size: .8125rem; padding-left: 10px; padding-right: 10px; }
  .document-dialog { inset: 8px; width: calc(100vw - 16px); height: calc(100dvh - 16px); border-radius: 12px; }
  .document-dialog-head { padding: 22px 20px; gap: 12px; }
  .document-dialog-head h2 { font-size: 1.25rem; }
  .document-content { padding: 24px 20px; font-size: 1rem; }
  .toast { left: 50%; bottom: 20px; font-size: .875rem; }
  .login-dialog { padding: 28px; }
}
@media (max-width: 370px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar-status { max-width: 125px; }
  .welcome { padding-left: 18px; padding-right: 18px; }
  .welcome h1 { font-size: 1.5rem; }
  .start-heading > span:last-child { display: none; }
  .starter-card { padding: 14px 12px; }
  .composer-area { padding-left: 10px; padding-right: 10px; }
  .configuration-notice > span { flex: 1; }
  .context-label { display: none; }
  .mode-tab { padding-left: 9px; padding-right: 9px; }
  .composer-tools > span { max-width: 130px; line-height: 1.5; }
  .library-heading > span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}
