:root {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #24322e;
  background: #fff;
  font-synthesis: none;
  --green: #235e4b;
  --green-dark: #174735;
  --muted: #707973;
  --line: #e5e9e5;
  --soft: #f3f5f2;
  --amber: #805e11;
  --red: #9c3333;
  --reading-width: 940px;
}
* { box-sizing: border-box; }
/* Original illustrated posts stay visible even when the evidence list is closed. */
.xhs-illustrations { margin: 18px 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft, #f7f8f5); }
.xhs-illustrations[hidden], .xhs-note-item[hidden] { display: none; }
.xhs-intro { margin: 0 0 8px; color: var(--text, #24322e); font-size: 13px; line-height: 1.7; }
.xhs-note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.xhs-note-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 100%; padding: 7px 10px; border: 1px solid var(--action-border, #d1dfd7); border-radius: 10px; color: var(--green); background: var(--surface, #fff); text-decoration: none; font-size: 13px; line-height: 1.6; }
.xhs-note-link:hover { border-color: var(--green); background: var(--soft); }
.xhs-note-link:focus-visible { outline: 2px solid var(--focus, #235e4b); outline-offset: 3px; }
.xhs-link-label { flex-shrink: 0; font-weight: 600; }
.xhs-link-title { min-width: 0; overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 3px; }
.xhs-link-arrow { flex-shrink: 0; }
.xhs-link-hint { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
body { margin: 0; font-size: 15px; line-height: 1.75; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid #75a890; outline-offset: 3px;
}
button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 16px; font-weight: 650; line-height: 1.5; }
h2 { margin: 0; font-size: 21px; }
h3 { margin: 0 0 12px; font-size: 17px; }
.app-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 22px; flex: 0 0 auto; }
.brand { min-width: 0; }
.mode-text { margin: 1px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.header-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.header-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: #57645e; border-radius: 9px; height: 36px; flex-shrink: 0; }
.header-button { gap: 6px; padding: 0 10px; font-size: 13px; white-space: nowrap; }
.icon-button { width: 36px; padding: 0; }
.header-button:hover:enabled, .icon-button:hover:enabled { background: var(--soft); color: var(--green); }
.header-button.active { background: var(--soft); color: var(--green); }
.header-divider { height: 18px; border-left: 1px solid var(--line); margin: 0 3px; }
.app-shell > main { flex: 1; min-height: 0; overflow: hidden; }
#chat-panel, .conversation-card { height: 100%; min-height: 0; }
.conversation-card { display: flex; flex-direction: column; }
/* Only the reading area scrolls. Controls never reserve a second header or sidebar. */
.conversation { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable both-edges; padding: 22px 24px 32px; }
.conversation > .message { width: 100%; max-width: var(--reading-width); margin: 0 auto 32px; }
.welcome { width: 100%; max-width: 620px; margin: clamp(24px, 16vh, 180px) auto 20px; text-align: center; }
.welcome h2 { font-size: 26px; font-weight: 600; margin-bottom: 14px; }
.welcome p { font-size: 14px; color: var(--muted); }
.welcome .help { font-size: 12px; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 24px 0 20px; }
.suggestions button { color: #4f6057; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 8px 13px; font-size: 13px; }
.suggestions button:hover:enabled { background: var(--soft); }
.composer-dock { flex: 0 0 auto; width: min(100%, calc(var(--reading-width) + 48px)); margin: 0 auto; padding: 6px 24px max(10px, env(safe-area-inset-bottom)); background: #fff; }
.composer { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; align-items: end; gap: 9px; border: 1px solid #dde3dc; border-radius: 26px; background: #f7f8f5; padding: 10px 12px; box-shadow: 0 2px 8px #1c342a05; }
.composer:focus-within { border-color: #9bb6a5; }
.composer textarea { border: 0; background: transparent; width: 100%; min-width: 0; min-height: 44px; max-height: min(144px, 26dvh); padding: 8px 2px; resize: none; overflow-y: auto; color: inherit; line-height: 28px; font-size: 16px; }
.composer textarea:focus-visible { outline: 0; }
textarea::placeholder, input::placeholder { color: #8b938c; }
.composer .icon-button { margin-bottom: 4px; border-radius: 50%; }
.profile-toggle { position: relative; }
.profile-toggle.has-profile::after { content: ""; position: absolute; top: 4px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--green); border: 1px solid #fff; }
.send-button { background: var(--green); color: #fff; }
.send-button:hover:enabled { background: var(--green-dark); color: #fff; }
.composer-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 12px; padding: 7px 5px 0; color: #828a83; font-size: 10px; line-height: 1.6; }
.message-label { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 10px; }
.message.user { text-align: right; }
.message.user .message-label { display: none; }
.message.user .message-body { display: inline-block; max-width: 88%; text-align: left; background: #f0f3ee; padding: 10px 17px; border-radius: 20px; }
.message.assistant .message-body { padding: 0; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.95; }
.response-header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.status-badge { display: inline-flex; font-size: 12px; font-weight: 600; border-radius: 6px; background: #eaf2e8; color: var(--green); padding: 2px 8px; }
.status-badge.warning { background: #f6efd9; color: var(--amber); }
.status-badge.error { background: #f8e9e6; color: var(--red); }
.response-mode { color: #8b938b; font-size: 11px; }
.follow-up, .conflict-notice { font-size: 14px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px 15px; margin-top: 18px; }
.follow-up { border-left: 3px solid #ccbd83; background: #faf8f0; }
.conflict-notice { border: 1px solid #e9dfc1; border-radius: 9px; background: #fcf9f0; color: #725b22; }
.evidence-group { margin-top: 18px; }
.evidence-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; max-width: 100%; padding: 4px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--soft); color: var(--green); font-size: 13px; line-height: 1.6; }
.evidence-toggle:hover { background: #eaf0e8; border-color: #cedace; }
.evidence-chevron { width: 10px; text-align: center; }
.evidence-list[hidden] { display: none; }
.evidence-item { border: 1px solid var(--line); background: #fff; border-radius: 10px; margin-top: 8px; overflow: hidden; }
.evidence-item summary { cursor: pointer; padding: 11px 14px; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.evidence-id { color: var(--green); font-size: 12px; margin-right: 8px; }
.evidence-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.evidence-text { white-space: pre-wrap; overflow-wrap: anywhere; border-top: 1px solid var(--line); padding: 16px; margin: 0; font-family: inherit; line-height: 1.95; font-size: 14px; background: #fafbf8; }
.evidence-details { padding: 0 14px 12px; font-size: 12px; color: var(--muted); }
.retry-button { margin-top: 15px; }
#retry-connection { margin-left: 12px; }
.message.pending .message-body { font-size: 14px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.spinner { width: 15px; height: 15px; border: 2px solid #d5dfd0; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
.button { border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 38px; }
.button.primary { background: var(--green); color: #fff; }
.button.primary:hover:enabled { background: var(--green-dark); }
.button.secondary { background: #fff; border-color: #cedace; color: var(--green); }
.button.secondary:hover:enabled { background: var(--soft); }
.card { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.help { color: var(--muted); font-size: 13px; line-height: 1.8; margin: 9px 0 15px; }
.small-badge { display: inline-block; font-size: 11px; font-weight: 400; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); padding: 2px 8px; }
/* Native dialog is out of flow: opening student details never shrinks the answer. */
.profile-dialog { color: inherit; border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: 0 20px 80px #12352326; }
.profile-dialog::backdrop { background: #18352b40; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-heading h2 { font-size: 19px; }
.dialog-heading h2 .small-badge { margin-left: 4px; }
#profile-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; margin: 22px 0; }
.profile-field { min-width: 0; }
#profile-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
input:not([type=checkbox]) { width: 100%; border: 1px solid #d9e1d7; border-radius: 8px; padding: 10px; color: inherit; background: #fcfdfb; font-size: 14px; }
.dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.privacy-note { color: #828b82; font-size: 12px; }
#sources-panel, #settings-panel { height: 100%; overflow-y: auto; padding: 12px max(24px, calc((100% - 1120px) / 2)) 40px; }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 600; letter-spacing: 1.2px; margin: 0 0 5px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 18px 0 22px; }
.panel-heading h2 { font-size: 24px; }
.panel-heading .help { margin-bottom: 0; max-width: 650px; }
.panel-heading > .button { flex-shrink: 0; }
.sources-notice { background: #faf6e9; color: #786329; border: 1px solid #e8ddbb; border-radius: 9px; padding: 12px 16px; font-size: 13px; margin-bottom: 20px; }
.source-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.summary-chip { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; font-size: 12px; color: var(--muted); }
.summary-chip strong { color: var(--green); font-size: 18px; margin-right: 7px; }
.sources-list { display: grid; gap: 12px; }
.source-card { padding: 17px 20px; }
.source-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.source-top > .button { flex-shrink: 0; }
.source-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.source-badges { display: flex; flex-wrap: wrap; gap: 7px; margin: 7px 0; }
.source-meta { font-size: 12px; line-height: 1.9; color: var(--muted); overflow-wrap: anywhere; }
.source-error { font-size: 13px; color: var(--red); margin-top: 9px; white-space: pre-wrap; }
.source-details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 9px; }
.source-details summary { cursor: pointer; font-size: 13px; color: var(--green); }
.source-details pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 12px; line-height: 1.85; background: #f7f9f5; padding: 12px; border-radius: 6px; max-height: 400px; overflow: auto; }
.source-card.disabled { background: #f8f9f6; }
.settings-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 20px; }
.settings-card { padding: 25px; }
.settings-card p, .settings-card li { font-size: 14px; }
.settings-card li { margin: 7px 0; }
.settings-card .help { font-size: 13px; }
.settings-status { display: grid; grid-template-columns: 1fr 1fr; font-size: 14px; gap: 13px; margin: 23px 0; }
.settings-status dt { color: var(--muted); }
.settings-status dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 600; color: var(--green); }
.checkbox-label { display: flex; align-items: flex-start; gap: 10px; margin: 22px 0 15px; font-size: 13px; }
.checkbox-label input { accent-color: var(--green); margin: 4px 0 0; width: 16px; height: 16px; flex-shrink: 0; }
.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.alert { border: 1px solid #e5d5a6; background: #fff8e5; color: #705923; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 12px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.alert.error { border-color: #e6c2bc; background: #fff2ef; color: var(--red); }
#global-alert { flex: 0 0 auto; margin: 0 20px 8px; max-height: 20dvh; overflow-y: auto; }
.hidden, [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; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 800px) {
  .header-button { width: 36px; padding: 0; }
  .header-button > span { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .site-header { padding: 9px 12px; gap: 5px; }
  h1 { font-size: 14px; }
  .brand-divider, .brand-school { display: none; }
  .mode-text { font-size: 10px; max-width: 160px; }
  .header-actions { gap: 1px; }
  .header-actions .header-button, .header-actions .icon-button { width: 30px; height: 34px; }
  .header-divider { margin: 0 1px; }
  .conversation { padding: 18px 12px 24px; scrollbar-gutter: auto; }
  .conversation > .message { margin-bottom: 26px; }
  .message-text { font-size: 16px; }
  .welcome { margin-top: clamp(24px, 12vh, 110px); }
  .welcome h2 { font-size: 22px; }
  .welcome p { font-size: 13px; }
  .suggestions { gap: 7px; margin: 20px 0; }
  .suggestions button { font-size: 12px; }
  .composer-dock { padding: 6px 10px max(8px, env(safe-area-inset-bottom)); }
  .composer { padding: 8px; gap: 6px; border-radius: 24px; }
  .composer-meta { justify-content: center; font-size: 9px; padding-top: 6px; }
  #loading-text { flex-basis: 100%; text-align: center; }
  .response-mode { font-size: 10px; }
  #sources-panel, #settings-panel { padding: 4px 12px 24px; }
  .panel-heading { display: block; margin: 14px 0 18px; }
  .panel-heading > .button { margin-top: 12px; }
  .panel-heading h2 { font-size: 21px; }
  .source-card, .settings-card { padding: 16px; }
  .source-name { font-size: 14px; }
  .source-top { gap: 8px; }
  .source-top .button { padding: 7px 10px; }
  .profile-dialog { padding: 18px; }
}
@media (max-width: 360px) {
  .site-header { padding: 8px; }
  h1 { font-size: 13px; }
  .header-actions .header-button, .header-actions .icon-button { width: 28px; }
  .header-divider { display: none; }
  #profile-form { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; scroll-behavior: auto !important; } }

/* Appearance is a local preference. The original rules above remain the minimal theme. */
.brand-name, .profile-button-text, .new-session-text { display: none; }
.appearance-card { padding: 22px 25px; margin-bottom: 22px; }
.appearance-card > .help { margin-bottom: 16px; }
.appearance-card #theme-status { margin: 12px 0 0; }
.theme-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; min-width: 0; padding: 0; margin: 0; border: 0; }
.theme-option { position: relative; display: block; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface, #fff); cursor: pointer; }
.theme-option:hover { border-color: var(--green); }
.theme-option:has(input:checked) { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.theme-option:has(input:focus-visible) { outline: 3px solid var(--focus, #235e4b); outline-offset: 4px; }
.theme-option input[type=radio] { position: absolute; right: 15px; top: 15px; z-index: 1; width: 18px; height: 18px; padding: 0; margin: 0; accent-color: var(--green); }
.theme-preview { display: flex; flex-direction: column; gap: 9px; min-height: 88px; border-radius: 8px; padding: 12px 36px 12px 13px; border: 1px solid #0000000d; }
.theme-preview > span { display: block; height: 9px; border-radius: 4px; }
.theme-preview > span:first-child { width: 62%; }
.theme-preview > span:nth-child(2) { width: 82%; margin-top: 5px; }
.theme-preview > span:last-child { width: 48%; }
.theme-preview-light { background: linear-gradient(120deg, #e1effe, #edf9f5); }
.theme-preview-light > span { background: #ffffffec; }
.theme-preview-light > span:last-child { background: #9ad8dc; }
.theme-preview-dark { background: linear-gradient(120deg, #15253b, #223c50); }
.theme-preview-dark > span { background: #819bb7; }
.theme-preview-dark > span:last-child { background: #7bdce2; }
.theme-preview-minimal { background: #f5f7f3; }
.theme-preview-minimal > span { background: #cdd9cf; }
.theme-preview-minimal > span:last-child { background: #49735f; }
.theme-option-copy { display: flex; flex-direction: column; padding: 8px 3px 2px; line-height: 1.6; overflow-wrap: anywhere; }
.theme-option-copy strong { font-size: 14px; }
.theme-option-copy small { color: var(--muted); font-size: 12px; }

html[data-theme=light] {
  color-scheme: light;
  color: #1d2b40;
  background: #eaf3fa;
  --green: #086c7b;
  --green-dark: #075461;
  --muted: #53677f;
  --line: #d7e4ee;
  --soft: #edf5fb;
  --amber: #755210;
  --red: #a3363b;
  --surface: #ffffff;
  --surface-soft: #f4f8fc;
  --surface-disabled: #edf1f5;
  --text: #1d2b40;
  --accent: #2463d5;
  --focus: #2366ce;
  --glass: #ffffffb8;
  --glass-line: #ffffffed;
  --shadow: 0 12px 38px #36658912;
  --user-bubble: #dceeff;
  --notice-bg: #fff7e6;
  --notice-line: #e3cf9c;
  --error-bg: #fff0ee;
  --error-line: #e5b8b8;
  --action-bg: #e8f5f5;
  --action-border: #bfdee2;
  --primary-text: #ffffff;
  --disabled-text: #5b6878;
  --backdrop: #152d4c59;
  --reading-width: 960px;
}
html[data-theme=dark] {
  color-scheme: dark;
  color: #ecf3fc;
  background: #102036;
  --green: #91e5e8;
  --green-dark: #b8f3f2;
  --muted: #b1c3d9;
  --line: #3a506a;
  --soft: #293f57;
  --amber: #ffde9c;
  --red: #ffb8ba;
  --surface: #1d2c40;
  --surface-soft: #24354b;
  --surface-disabled: #233044;
  --text: #ecf3fc;
  --accent: #96d8ff;
  --focus: #8ee6ef;
  --glass: #253c55c4;
  --glass-line: #486785;
  --shadow: 0 12px 38px #00000024;
  --user-bubble: #294c6e;
  --notice-bg: #3e3526;
  --notice-line: #78613a;
  --error-bg: #462f39;
  --error-line: #865463;
  --action-bg: #243f4d;
  --action-border: #476b7c;
  --primary-text: #102d36;
  --disabled-text: #a4b2c4;
  --backdrop: #040e1dc7;
  --reading-width: 960px;
}
html[data-theme=minimal] {
  color-scheme: light;
  --muted: #5c6b61;
}
/* Keep the original minimal layout; strengthen its inherited faint helper text. */
html[data-theme=minimal] :is(.response-mode, .composer-meta, .privacy-note) { color: var(--muted); }
html[data-theme=minimal] :is(textarea, input)::placeholder { color: var(--muted); opacity: 1; }
html[data-theme=light] body {
  background: radial-gradient(ellipse at 6% 8%, #d6eafa 0, transparent 56%), radial-gradient(ellipse at 97% 72%, #dcefeb 0, transparent 58%), linear-gradient(135deg, #f0f6ff, #e7f3f8 60%, #edf6fa);
}
html[data-theme=dark] body {
  background: radial-gradient(ellipse at 4% 9%, #243d60 0, transparent 55%), radial-gradient(ellipse at 97% 72%, #173b49 0, transparent 55%), linear-gradient(135deg, #142239, #101e31 62%, #152940);
}
html:is([data-theme=light], [data-theme=dark]) body { color: var(--text); }
html:is([data-theme=light], [data-theme=dark]) :is(button, input, textarea, summary):focus-visible { outline-color: var(--focus); }
html:is([data-theme=light], [data-theme=dark]) a { color: var(--accent); }
html:is([data-theme=light], [data-theme=dark]) :is(button, .theme-option) { -webkit-tap-highlight-color: transparent; }
html:is([data-theme=light], [data-theme=dark]) button:disabled { opacity: 1; color: var(--disabled-text); background: var(--surface-disabled); border-color: var(--line); }
html:is([data-theme=light], [data-theme=dark]) .site-header {
  margin: clamp(10px, 2.4vh, 24px) clamp(16px, 5vw, 88px) 14px;
  padding: 10px 20px;
  min-height: 66px;
  border: 1px solid var(--glass-line);
  border-radius: 22px;
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
html:is([data-theme=light], [data-theme=dark]) .brand h1 { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; }
html:is([data-theme=light], [data-theme=dark]) .brand-name { display: inline; font-size: 21px; font-weight: 700; white-space: nowrap; letter-spacing: .02em; }
html:is([data-theme=light], [data-theme=dark]) .brand-subtitle { font-size: 12px; font-weight: 400; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line); }
html:is([data-theme=light], [data-theme=dark]) .mode-text { color: var(--muted); font-size: 11px; margin-top: 3px; }
html:is([data-theme=light], [data-theme=dark]) .header-actions { gap: 6px; }
html:is([data-theme=light], [data-theme=dark]) :is(.header-button, .icon-button) { color: var(--muted); min-width: 44px; height: 44px; border-radius: 12px; }
html:is([data-theme=light], [data-theme=dark]) .header-button { padding: 0 14px; gap: 8px; font-size: 14px; }
html:is([data-theme=light], [data-theme=dark]) :is(.header-button, .icon-button):hover:enabled { background: var(--soft); color: var(--green); }
html:is([data-theme=light], [data-theme=dark]) .header-button.active { background: var(--surface); color: var(--accent); box-shadow: 0 2px 8px #10203907; }
html:is([data-theme=light], [data-theme=dark]) #new-session { gap: 6px; width: auto; padding: 0 10px; }
html:is([data-theme=light], [data-theme=dark]) .new-session-text { display: inline; white-space: nowrap; font-size: 12px; }
html:is([data-theme=light], [data-theme=dark]) #chat-panel { padding: 2px clamp(16px, 6vw, 108px) 0; }
html:is([data-theme=light], [data-theme=dark]) .conversation-card { width: 100%; max-width: 1200px; margin: 0 auto; }
html:is([data-theme=light], [data-theme=dark]) .conversation { background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 26px 30px 28px; box-shadow: var(--shadow); scrollbar-color: var(--line) transparent; }
html:is([data-theme=light], [data-theme=dark]) .conversation > .message { margin-bottom: 28px; }
html:is([data-theme=light], [data-theme=dark]) .welcome { margin-top: clamp(32px, 11vh, 120px); }
html:is([data-theme=light], [data-theme=dark]) .welcome p { color: var(--muted); }
html:is([data-theme=light], [data-theme=dark]) .suggestions button { background: var(--surface-soft); color: var(--text); min-height: 44px; }
html:is([data-theme=light], [data-theme=dark]) .suggestions button:hover:enabled { background: var(--soft); border-color: var(--action-border); }
html:is([data-theme=light], [data-theme=dark]) .message.user .message-body { background: var(--user-bubble); border-radius: 20px 20px 5px 20px; padding: 11px 18px; }
html:is([data-theme=light], [data-theme=dark]) .message-text { color: var(--text); }
html:is([data-theme=light], [data-theme=dark]) .message-label { color: var(--muted); margin-bottom: 8px; }
html:is([data-theme=light], [data-theme=dark]) .composer-dock { width: 100%; background: transparent; padding: 16px 0 max(10px, env(safe-area-inset-bottom)); }
html:is([data-theme=light], [data-theme=dark]) .composer { grid-template-columns: minmax(0, 1fr) auto 44px; gap: 10px; padding: 10px 12px 10px 22px; border: 1px solid var(--action-border); border-radius: 30px; background: var(--surface); box-shadow: var(--shadow); }
html:is([data-theme=light], [data-theme=dark]) .composer:focus-within { border-color: var(--green); }
html:is([data-theme=light], [data-theme=dark]) .composer textarea { grid-column: 1; grid-row: 1; color: var(--text); }
html:is([data-theme=light], [data-theme=dark]) .composer .profile-toggle { grid-column: 2; grid-row: 1; display: flex; width: auto; min-width: 44px; height: 44px; margin: 0; padding: 0 12px; gap: 7px; border: 1px solid var(--line); border-radius: 23px; background: var(--surface-soft); color: var(--green); }
html:is([data-theme=light], [data-theme=dark]) .profile-button-text { display: inline; font-size: 12px; white-space: nowrap; }
html:is([data-theme=light], [data-theme=dark]) .profile-toggle.has-profile::after { background: var(--green); border-color: var(--surface); }
html:is([data-theme=light], [data-theme=dark]) .composer .send-button { grid-column: 3; grid-row: 1; width: 44px; height: 44px; margin: 0; border-radius: 50%; background: var(--green); color: var(--primary-text); }
html:is([data-theme=light], [data-theme=dark]) .composer .send-button:hover:enabled { background: var(--green-dark); color: var(--primary-text); }
html:is([data-theme=light], [data-theme=dark]) .composer .send-button:disabled { background: var(--surface-disabled); color: var(--disabled-text); }
html:is([data-theme=light], [data-theme=dark]) :is(textarea, input)::placeholder { color: var(--muted); opacity: 1; }
html:is([data-theme=light], [data-theme=dark]) :is(.composer-meta, .response-mode, .privacy-note) { color: var(--muted); }
html:is([data-theme=light], [data-theme=dark]) .composer-meta { font-size: 11px; padding: 7px 10px 0; }
html:is([data-theme=light], [data-theme=dark]) .response-header { margin-bottom: 12px; }
html:is([data-theme=light], [data-theme=dark]) .status-badge { background: var(--action-bg); color: var(--green); }
html:is([data-theme=light], [data-theme=dark]) :is(.status-badge.warning, .follow-up, .conflict-notice, .sources-notice, .alert) { background: var(--notice-bg); color: var(--amber); border-color: var(--notice-line); }
html:is([data-theme=light], [data-theme=dark]) :is(.status-badge.error, .alert.error) { background: var(--error-bg); color: var(--red); border-color: var(--error-line); }
html:is([data-theme=light], [data-theme=dark]) .evidence-toggle { min-height: 44px; padding: 7px 14px; background: var(--action-bg); color: var(--green); border-color: var(--action-border); border-radius: 22px; }
html:is([data-theme=light], [data-theme=dark]) .evidence-toggle:hover { background: var(--soft); border-color: var(--green); }
html:is([data-theme=light], [data-theme=dark]) :is(.evidence-item, .card, .summary-chip) { background: var(--surface); }
html:is([data-theme=light], [data-theme=dark]) :is(.evidence-text, .source-details pre) { background: var(--surface-soft); color: var(--text); }
html:is([data-theme=light], [data-theme=dark]) .source-card.disabled { background: var(--surface-disabled); }
html:is([data-theme=light], [data-theme=dark]) .button { min-height: 44px; border-radius: 11px; }
html:is([data-theme=light], [data-theme=dark]) .button.primary { background: var(--green); color: var(--primary-text); }
html:is([data-theme=light], [data-theme=dark]) .button.primary:hover:enabled { background: var(--green-dark); }
html:is([data-theme=light], [data-theme=dark]) .button.secondary { background: var(--surface); color: var(--green); border-color: var(--action-border); }
html:is([data-theme=light], [data-theme=dark]) .button.secondary:hover:enabled { background: var(--soft); }
html:is([data-theme=light], [data-theme=dark]) .button:disabled { background: var(--surface-disabled); color: var(--disabled-text); border-color: var(--line); }
html:is([data-theme=light], [data-theme=dark]) .profile-dialog { background: var(--surface); box-shadow: 0 24px 80px #00000040; }
html:is([data-theme=light], [data-theme=dark]) .profile-dialog::backdrop { background: var(--backdrop); }
html:is([data-theme=light], [data-theme=dark]) input:not([type=checkbox]):not([type=radio]) { background: var(--surface-soft); color: var(--text); border-color: var(--line); }
html:is([data-theme=light], [data-theme=dark]) .spinner { border-color: var(--line); border-top-color: var(--green); }
html:is([data-theme=light], [data-theme=dark]) :is(#sources-panel, #settings-panel) { padding: 2px max(24px, calc((100% - 1120px) / 2)) 36px; scrollbar-color: var(--line) transparent; }
html:is([data-theme=light], [data-theme=dark]) :is(.settings-card, .source-card, .appearance-card) { border-radius: 20px; }
html:is([data-theme=light], [data-theme=dark]) .settings-card ul { padding-left: 22px; }
html:is([data-theme=light], [data-theme=dark]) #global-alert { margin: 0 clamp(16px, 5vw, 88px) 12px; }

@media (max-width: 1100px) {
  html:is([data-theme=light], [data-theme=dark]) .brand-subtitle { display: none; }
  html:is([data-theme=light], [data-theme=dark]) .site-header { margin-inline: 24px; }
  html:is([data-theme=light], [data-theme=dark]) #chat-panel { padding-inline: 24px; }
}
@media (max-width: 800px) {
  html:is([data-theme=light], [data-theme=dark]) .site-header { padding: 8px 12px; margin: 12px 16px; }
  html:is([data-theme=light], [data-theme=dark]) .header-button { width: 44px; padding: 0; }
  html:is([data-theme=light], [data-theme=dark]) .new-session-text { display: none; }
  html:is([data-theme=light], [data-theme=dark]) #new-session { padding: 0; width: 44px; }
  html:is([data-theme=light], [data-theme=dark]) #chat-panel { padding-inline: 16px; }
  html:is([data-theme=light], [data-theme=dark]) .conversation { padding-inline: 20px; border-radius: 20px; }
}
@media (max-width: 600px) {
  .appearance-card { padding: 16px; }
  .theme-picker { gap: 9px; }
  .theme-option { padding: 7px; border-radius: 11px; }
  .theme-option input[type=radio] { right: 10px; top: 10px; }
  .theme-preview { min-height: 70px; padding: 11px 27px 10px 8px; gap: 6px; }
  .theme-preview > span { height: 7px; }
  .theme-option-copy small { font-size: 11px; }
  html:is([data-theme=light], [data-theme=dark]) .site-header { flex-wrap: wrap; gap: 4px; margin: 8px 10px; padding: 8px 10px 5px; border-radius: 18px; }
  html:is([data-theme=light], [data-theme=dark]) .brand { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  html:is([data-theme=light], [data-theme=dark]) .brand-name { font-size: 18px; }
  html:is([data-theme=light], [data-theme=dark]) .mode-text { margin: 0; max-width: 70%; font-size: 10px; text-align: right; }
  html:is([data-theme=light], [data-theme=dark]) .header-actions { width: 100%; gap: 2px; justify-content: flex-end; }
  html:is([data-theme=light], [data-theme=dark]) .header-actions :is(.header-button, .icon-button) { width: 44px; min-width: 44px; height: 44px; }
  html:is([data-theme=light], [data-theme=dark]) .header-actions .header-button:first-child { margin-right: auto; }
  html:is([data-theme=light], [data-theme=dark]) #chat-panel { padding: 0 10px; }
  html:is([data-theme=light], [data-theme=dark]) .conversation { padding: 18px 14px 20px; border-radius: 18px; }
  html:is([data-theme=light], [data-theme=dark]) .conversation > .message { margin-bottom: 24px; }
  html:is([data-theme=light], [data-theme=dark]) .welcome { margin-top: clamp(24px, 8vh, 70px); }
  html:is([data-theme=light], [data-theme=dark]) .welcome h2 { font-size: 21px; }
  html:is([data-theme=light], [data-theme=dark]) .composer-dock { padding-top: 10px; }
  html:is([data-theme=light], [data-theme=dark]) .composer { grid-template-columns: minmax(0, 1fr) 44px 44px; padding: 8px 8px 8px 14px; gap: 5px; border-radius: 26px; }
  html:is([data-theme=light], [data-theme=dark]) .composer .profile-toggle { width: 44px; padding: 0; }
  html:is([data-theme=light], [data-theme=dark]) .profile-button-text { display: none; }
  html:is([data-theme=light], [data-theme=dark]) .composer-meta { justify-content: center; font-size: 10px; padding-inline: 0; }
  html:is([data-theme=light], [data-theme=dark]) :is(#sources-panel, #settings-panel) { padding: 0 12px 24px; }
  html:is([data-theme=light], [data-theme=dark]) .panel-heading { margin-top: 10px; }
  html:is([data-theme=light], [data-theme=dark]) .settings-status { gap: 10px; }
}
@media (max-width: 360px) {
  .theme-picker { grid-template-columns: 1fr; }
  .theme-option { display: grid; grid-template-columns: 75px minmax(0, 1fr); align-items: center; gap: 12px; padding-right: 30px; }
  .theme-option-copy small { font-size: 12px; }
  .theme-preview { min-height: 58px; padding-right: 12px; }
  html:is([data-theme=light], [data-theme=dark]) .site-header { margin-inline: 8px; }
  html:is([data-theme=light], [data-theme=dark]) .conversation { padding-inline: 12px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  html:is([data-theme=light], [data-theme=dark]) .site-header { min-height: 56px; margin-block: 6px; padding-block: 5px; }
  html:is([data-theme=light], [data-theme=dark]) .brand-subtitle { display: none; }
  html:is([data-theme=light], [data-theme=dark]) .composer-dock { padding-top: 8px; padding-bottom: 5px; }
  html:is([data-theme=light], [data-theme=dark]) .composer { padding-block: 6px; }
  html:is([data-theme=light], [data-theme=dark]) .conversation { padding-block: 16px; }
  html:is([data-theme=light], [data-theme=dark]) .welcome { margin-top: 12px; }
}
