:root {
  color-scheme: light;
  --forest: #142B4C;
  --forest-soft: #1F3A61;
  --paper: #FAF7F2;
  --surface: #ffffff;
  --surface-quiet: #F1ECE1;
  --ink: #1E2229;
  --muted: #5B6472;
  --line: #E5DFD2;
  --line-strong: #D6CDB9;
  --coral: #A8501A;
  --coral-soft: #F6E2D3;
  --teal: #0F7A73;
  --gold: #F4C35A;
  --quiet: #5A6670;
  --shadow: 0 16px 46px rgba(20, 43, 76, .09);
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(20, 43, 76, .12) .75px, transparent .75px);
  background-size: 21px 21px;
  background-attachment: fixed;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, label:focus-within { outline: 3px solid rgba(168, 80, 26, .35); outline-offset: 2px; }
button:disabled { opacity: .55; cursor: not-allowed; }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 27px 17px 18px; color: var(--ink); background: var(--surface-quiet); border-right: 1px solid var(--line); z-index: 20; }
.brand-lockup { display: flex; align-items: center; padding: 0 6px 28px; }
.brand-logo { display: block; width: 100%; max-width: 172px; height: auto; }
.brand-logo-dark { display: none; }
body[data-theme="dark"] .brand-logo-light { display: none; }
body[data-theme="dark"] .brand-logo-dark { display: block; }
.new-chat-button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 1px solid var(--forest); border-radius: 6px; color: #fff; background: var(--forest); text-align: left; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.new-chat-button:hover { background: var(--forest-soft); border-color: var(--forest-soft); }
.new-chat-button .icon-plus { color: var(--gold); flex-shrink: 0; }
.primary-nav { display: grid; gap: 5px; margin: 22px 0 27px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 11px; border: 0; border-radius: 5px; color: var(--quiet); background: transparent; text-align: left; cursor: pointer; transition: color .18s ease, background .18s ease; }
.nav-item:hover { color: var(--forest); background: rgba(20, 43, 76, .06); }
.nav-item.is-active { color: var(--forest); background: var(--surface); }
.nav-glyph { color: var(--quiet); font-size: 10px; font-variant-numeric: tabular-nums; }
.nav-item.is-active .nav-glyph { color: var(--coral); }
.sidebar-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 9px; color: var(--quiet); font-size: 9px; font-weight: 700; letter-spacing: 1.1px; }
.muted-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); }
.chat-history { display: grid; align-content: start; gap: 3px; overflow: auto; min-height: 70px; }
.history-row { display: grid; grid-template-columns: minmax(0, 1fr) 28px; align-items: center; gap: 2px; }
.history-item { display: block; width: 100%; overflow: hidden; padding: 9px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.history-item:hover, .history-item.is-active { color: var(--forest); background: var(--surface); }
.history-delete { width: 26px; height: 28px; padding: 0; border: 0; border-radius: 4px; color: var(--quiet); background: transparent; opacity: 0; cursor: pointer; transition: opacity .16s ease, color .16s ease, background .16s ease; }
.history-row:hover .history-delete, .history-row:focus-within .history-delete { opacity: 1; }
.history-delete:hover { color: var(--coral); background: var(--surface); }
.history-empty { padding: 9px; color: var(--quiet); font-size: 12px; line-height: 1.5; }
.sidebar-bottom { display: grid; gap: 14px; margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--line); }
.privacy-line { display: flex; align-items: center; gap: 8px; color: var(--quiet); font-size: 11px; }
.privacy-mark { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px rgba(15, 122, 115, .15); }
.sidebar-version { display: flex; justify-content: space-between; color: var(--quiet); font-size: 10px; }
.sidebar-version span { color: var(--line-strong); }

.main-column { display: flex; min-width: 0; min-height: 100vh; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 30px; border-bottom: 1px solid rgba(207, 205, 222, .72); background: rgba(250, 247, 242, .92); backdrop-filter: blur(14px); }
.topbar-context, .topbar-actions { display: flex; align-items: center; gap: 13px; }
.topbar-kicker { color: var(--quiet); font-size: 9px; font-weight: 700; letter-spacing: 1.2px; }
.topbar-divider { color: #b1b5bd; font-size: 14px; }
.topbar-current { max-width: 260px; overflow: hidden; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.gateway-status { display: flex; align-items: center; gap: 7px; color: #656a75; font-size: 11px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #d4a846; box-shadow: 0 0 0 3px rgba(212, 168, 70, .14); }
.gateway-status.is-online .status-dot { background: #0F7A73; box-shadow: 0 0 0 3px rgba(15, 122, 115, .15); }
.gateway-status.is-offline .status-dot { background: var(--coral); box-shadow: 0 0 0 3px rgba(168, 80, 26, .14); }
.topbar-action, .theme-toggle, .topbar-menu { display: inline-flex; align-items: center; padding: 7px 10px; border: 1px solid transparent; border-radius: 5px; color: #535964; background: transparent; font-size: 12px; cursor: pointer; }
.topbar-action:hover, .theme-toggle:hover, .topbar-menu:hover { border-color: var(--line); background: var(--surface); }
.topbar-menu { display: none; }
.btn-icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }
.icon-moon { display: none; }
body[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
body[data-theme="dark"] .theme-toggle .icon-moon { display: inline-block; }
.workspace { display: grid; flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 286px; }
.content-area { display: flex; min-width: 0; min-height: calc(100vh - 68px); flex-direction: column; }
.chat-view { display: flex; flex: 1; min-height: 0; flex-direction: column; padding: 0 clamp(20px, 5vw, 76px); animation: arrive .38s ease both; }
.message-stream { display: flex; flex: 1; flex-direction: column; gap: 22px; overflow-y: auto; width: min(100%, 850px); margin: 0 auto; padding: 34px 0 24px; }
.empty-state { display: flex; flex: 1; flex-direction: column; justify-content: center; min-height: 390px; padding: 45px 0 28px; animation: arrive .52s ease both; }
.archive-stamp { display: flex; align-items: center; gap: 11px; width: fit-content; margin: 0 0 18px; color: var(--teal); font-size: 9px; font-weight: 700; letter-spacing: 1.4px; }
.stamp-rule { width: 21px; height: 1px; background: var(--coral); }
.empty-state h1, .library-heading-row h1 { margin: 0; color: var(--forest); font-family: "Fraunces", Georgia, serif; font-size: clamp(32px, 4vw, 49px); font-weight: 400; line-height: 1.1; letter-spacing: 0; }
.empty-subtitle { margin: 12px 0 28px; color: #6b707a; font-size: 14px; }
.starter-questions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; width: min(100%, 680px); }
.starter-question { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 5px; color: #353b48; background: rgba(255, 255, 255, .65); text-align: left; line-height: 1.35; cursor: pointer; transition: border-color .18s ease, transform .18s ease, background .18s ease; animation: arrive .42s ease both; }
.starter-question:nth-child(2) { animation-delay: .05s; }
.starter-question:nth-child(3) { animation-delay: .1s; }
.starter-question:nth-child(4) { animation-delay: .15s; }
.starter-question:hover { transform: translateY(-2px); border-color: #aeb4bf; background: #fff; }
.starter-question span:last-child { margin-left: 10px; color: var(--coral); }
.message { display: grid; grid-template-columns: 98px minmax(0, 1fr); gap: 16px; animation: arrive .24s ease both; }
.message-meta { display: flex; align-items: center; gap: 6px; padding-top: 3px; color: var(--quiet); font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; }
.message-meta::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--quiet); }
.message.assistant .message-meta { color: var(--teal); }
.message.assistant .message-meta::before { background: var(--coral); }
.message-body { min-width: 0; color: #292f3a; font-size: 14px; line-height: 1.72; overflow-wrap: anywhere; }
.message.user .message-body { padding: 2px 0 4px; font-weight: 600; }
.message.assistant .message-body { padding-bottom: 3px; }
.message-body h1, .message-body h2, .message-body h3 { margin: 1.1em 0 .4em; color: var(--forest); font-family: "Fraunces", Georgia, serif; font-weight: 400; line-height: 1.25; }
.message-body h1 { font-size: 25px; }
.message-body h2 { font-size: 21px; }
.message-body h3 { font-size: 17px; }
.message-body p { margin: 0 0 12px; }
.message-body ul, .message-body ol { margin: 5px 0 15px; padding-left: 22px; }
.message-body li { padding: 2px 0; }
.message-body strong { color: #1e2534; }
.message-body code { padding: 2px 5px; border-radius: 3px; color: #7d402f; background: #f4ebe2; font-family: Menlo, Consolas, monospace; font-size: .9em; }
.message-body pre { overflow: auto; padding: 12px 14px; border-radius: 5px; color: #eff1f5; background: #20293a; }
.message-body pre code { padding: 0; color: inherit; background: transparent; }
.message-body blockquote { margin: 12px 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--gold); color: #656a73; }
.source-details { margin: 12px 0 2px 114px; border-top: 1px solid var(--line); }
.source-details summary { padding: 10px 0; color: #606774; font-size: 11px; font-weight: 700; cursor: pointer; list-style: none; }
.source-details summary::-webkit-details-marker { display: none; }
.source-details summary::before { content: "+"; display: inline-block; width: 19px; color: var(--coral); }
.source-details[open] summary::before { content: "-"; }
.source-card { padding: 10px 12px; border-left: 2px solid #939bab; background: rgba(255, 255, 255, .56); }
.source-card + .source-card { margin-top: 7px; }
.source-card-title { color: var(--forest); font-size: 11px; font-weight: 700; }
.source-card-title a { color: inherit; text-decoration-color: #9ca2ae; text-underline-offset: 2px; }
.source-card-title a:hover { color: var(--coral); }
.source-card-snippet { margin-top: 5px; color: #656a74; font-size: 12px; line-height: 1.55; }
.message-error { color: #a5422d; }
.typing-indicator { display: inline-flex; gap: 4px; margin: 6px 0; }
.typing-indicator i { width: 5px; height: 5px; border-radius: 50%; background: #7c869b; animation: pulse 1s infinite alternate; }
.typing-indicator i:nth-child(2) { animation-delay: .18s; }
.typing-indicator i:nth-child(3) { animation-delay: .36s; }

.composer { width: min(100%, 850px); margin: 0 auto 25px; padding: 12px 14px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 26px rgba(20, 43, 76, .06); transition: box-shadow .2s ease, border-color .2s ease; }
.composer:focus-within { border-color: #9199aa; box-shadow: 0 10px 32px rgba(20, 43, 76, .11); }
.composer textarea { display: block; width: 100%; min-height: 34px; max-height: 180px; resize: none; padding: 6px 3px 8px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 14px; line-height: 1.5; }
.composer textarea::placeholder { color: #9a9ea6; }
.composer textarea:focus-visible { outline: 0; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; min-height: 32px; border-top: 1px solid #ecedf0; }
.composer-note { display: flex; align-items: center; gap: 7px; color: var(--quiet); font-size: 10px; }
.composer-mark { display: grid; width: 17px; height: 17px; place-items: center; border-radius: 4px 4px 4px 1px; color: white; background: var(--teal); font-family: "Fraunces", Georgia, serif; font-size: 11px; }
.composer-actions { display: flex; align-items: center; gap: 12px; }
.key-hint { color: var(--quiet); font-size: 10px; }
.send-button { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 0; border-radius: 4px; color: #fff; background: var(--forest); font-size: 11px; cursor: pointer; transition: background .18s ease; }
.send-button:hover { background: #283754; }
.send-button:disabled { background: #9a9fa8; }
.send-arrow { color: var(--gold); }

.options-panel { position: sticky; top: 68px; align-self: start; display: flex; flex-direction: column; height: calc(100vh - 68px); overflow-y: auto; padding: 25px 18px; border-left: 1px solid var(--line); background: var(--surface-quiet); transition: transform .25s ease, opacity .2s ease; }
.options-panel.is-hidden { display: none; }
.workspace.options-closed { grid-template-columns: minmax(0, 1fr); }
.export-menu { position: relative; }
.export-menu > summary { list-style: none; cursor: pointer; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 40; display: grid; width: 165px; padding: 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); box-shadow: var(--shadow); }
.export-popover button { padding: 9px 8px; border: 0; border-radius: 3px; color: var(--ink); background: transparent; text-align: left; font-size: 11px; cursor: pointer; }
.export-popover button:hover { background: var(--surface-quiet); }
.options-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.options-heading h2 { margin: 6px 0 0; color: var(--forest); font-family: "Fraunces", Georgia, serif; font-size: 19px; font-weight: 400; }
.section-overline { color: var(--quiet); font-size: 9px; font-weight: 700; letter-spacing: 1.15px; }
.options-close { padding: 4px 0; border: 0; color: var(--quiet); background: transparent; font-size: 10px; cursor: pointer; }
.control-label { display: block; margin: 0 0 7px; color: #434955; font-size: 11px; font-weight: 700; }
.control-label-row { display: flex; align-items: center; justify-content: space-between; margin-top: 17px; }
.control-label-row .control-label { margin-bottom: 7px; }
.field-control { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid #d4d7dd; border-radius: 4px; color: #2b3240; background-color: #fff; font-size: 12px; }
.field-control:focus { border-color: #838da2; }
.text-action { padding: 3px 0; border: 0; color: var(--coral); background: transparent; font-size: 10px; cursor: pointer; }
.settings-divider { height: 1px; margin: 19px 0; background: var(--line); }
.key-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.key-entry .field-control { min-width: 0; }
.key-entry button { padding: 0 10px; border: 1px solid #d4d7dd; border-radius: 4px; color: var(--forest); background: #fff; font-size: 11px; cursor: pointer; }
.key-state { min-height: 27px; padding-top: 6px; color: var(--quiet); font-size: 9px; line-height: 1.4; }
.temperature-slider { width: 100%; margin: 5px 0 0; accent-color: var(--coral); }
.control-label-row output { color: var(--teal); font-size: 11px; font-variant-numeric: tabular-nums; }
.range-labels { display: flex; justify-content: space-between; color: var(--quiet); font-size: 9px; }
.options-footnote { margin-top: auto; padding-top: 20px; color: var(--quiet); font-size: 10px; line-height: 1.5; }

.library-view { width: min(100%, 1120px); margin: 0 auto; padding: 39px clamp(20px, 4vw, 55px) 50px; animation: arrive .35s ease both; }
.library-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 25px; padding-bottom: 27px; border-bottom: 1px solid var(--line); }
.library-heading-row h1 { margin-top: 8px; font-size: 36px; }
.library-summary { margin: 9px 0 0; color: var(--quiet); font-size: 12px; }
.library-actions { display: flex; gap: 8px; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 37px; padding: 0 12px; border: 1px solid var(--forest); border-radius: 4px; font-size: 11px; cursor: pointer; transition: background .17s ease, color .17s ease; }
.primary-button { color: white; background: var(--forest); }
.primary-button:hover { background: #283754; }
.secondary-button { color: var(--forest); background: transparent; }
.secondary-button:hover { background: #e9ebef; }
.upload-button { cursor: pointer; }
.index-progress { margin: 16px 0 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, .7); }
.progress-heading { display: flex; justify-content: space-between; margin-bottom: 7px; color: #606673; font-size: 10px; }
.progress-track { height: 4px; overflow: hidden; border-radius: 3px; background: #dfe2e7; }
.progress-fill { width: 0; height: 100%; background: var(--teal); transition: width .25s ease; }
.library-toolbar { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--line-strong); }
.library-search-wrap { display: block; width: min(100%, 360px); }
.library-search-wrap input { width: 100%; padding: 8px 10px 8px 30px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Ccircle cx='7.8' cy='7.8' r='5' stroke='%235A6670' stroke-width='1.5' fill='none'/%3E%3Cpath d='M11.7 11.7 15.5 15.5' stroke='%235A6670' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 9px center / 14px 14px; font-size: 11px; }
.library-sort-label { color: var(--quiet); font-size: 9px; font-weight: 700; letter-spacing: .9px; }
.transcript-list { display: grid; }
.transcript-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 130px; align-items: center; gap: 12px; min-height: 58px; border-bottom: 1px solid #e5e7eb; animation: arrive .25s ease both; }
.transcript-name { overflow: hidden; color: #303744; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.transcript-meta { color: var(--quiet); font-size: 10px; text-align: right; }
.topic-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.topic-chip { padding: 3px 6px; border: 1px solid #d8dbe2; border-radius: 3px; color: #545e73; background: #f3f4f7; font-size: 9px; }
.library-empty { padding: 35px 0; color: var(--quiet); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.toast { position: fixed; right: 22px; bottom: 20px; z-index: 60; max-width: min(440px, calc(100vw - 32px)); padding: 12px 15px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 5px; color: #fff; background: #20293a; box-shadow: var(--shadow); font-size: 12px; line-height: 1.45; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: #863f31; }
.is-busy { cursor: progress !important; }
.library-view[hidden] { display: none; }

@keyframes arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { from { opacity: .35; transform: translateY(0); } to { opacity: 1; transform: translateY(-2px); } }

body[data-theme="dark"] {
  color-scheme: dark;
  --paper: #141A22;
  --surface: #1C2630;
  --surface-quiet: #232E3B;
  --ink: #FAF7F2;
  --muted: #A7B0BC;
  --line: #2E3A48;
  --line-strong: #3E4F60;
  --coral: #E8833A;
  --coral-soft: #3A2A1C;
  --teal: #5FC4B8;
  --quiet: #AEB7C2;
  --shadow: 0 16px 46px rgba(0, 0, 0, .23);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(180, 190, 215, .09) .75px, transparent .75px);
}
body[data-theme="dark"] .topbar { background: rgba(20, 26, 34, .92); }
body[data-theme="dark"] .topbar-current,
body[data-theme="dark"] .empty-state h1,
body[data-theme="dark"] .library-heading-row h1,
body[data-theme="dark"] .options-heading h2,
body[data-theme="dark"] .message-body h1,
body[data-theme="dark"] .message-body h2,
body[data-theme="dark"] .message-body h3,
body[data-theme="dark"] .message-body strong { color: #e0e4eb; }
body[data-theme="dark"] .empty-subtitle,
body[data-theme="dark"] .library-summary,
body[data-theme="dark"] .message-body,
body[data-theme="dark"] .source-card-snippet { color: #a8adb8; }
body[data-theme="dark"] .starter-question,
body[data-theme="dark"] .field-control,
body[data-theme="dark"] .composer,
body[data-theme="dark"] .library-search-wrap input,
body[data-theme="dark"] .key-entry button { color: #dce0e8; background-color: #1C2630; }
body[data-theme="dark"] .library-search-wrap input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Ccircle cx='7.8' cy='7.8' r='5' stroke='%23AEB7C2' stroke-width='1.5' fill='none'/%3E%3Cpath d='M11.7 11.7 15.5 15.5' stroke='%23AEB7C2' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); }
body[data-theme="dark"] .starter-question:hover { background: #282e3b; }
body[data-theme="dark"] .options-panel { background: rgba(35, 46, 59, .96); }
body[data-theme="dark"] .control-label,
body[data-theme="dark"] .transcript-name { color: #d4d8e1; }
body[data-theme="dark"] .field-control { border-color: #454c59; }
body[data-theme="dark"] .source-card { background: #242a35; }
body[data-theme="dark"] .source-card-title { color: #d9dee8; }
body[data-theme="dark"] .message-body code { color: #f1b59e; background: #3e302a; }
body[data-theme="dark"] .message-body pre { background: #10141b; }
body[data-theme="dark"] .message-body pre code { background: transparent; }
body[data-theme="dark"] .message-body blockquote { color: #a3a8b3; }
body[data-theme="dark"] .topic-chip { color: #b8c1d2; background: #272d3a; border-color: #3a4251; }
body[data-theme="dark"] .index-progress { background: #1C2630; }
body[data-theme="dark"] .secondary-button { color: #d8dce5; }
body[data-theme="dark"] .secondary-button:hover { background: #292f3c; }
/* The sidebar is light (Sand) in light mode but reverts to a dark panel in dark mode via
   --surface-quiet, so its hover/active overlays need to flip direction too: a light tint
   here instead of the navy tint used in light mode. */
body[data-theme="dark"] .nav-item:hover { color: #fff; background: rgba(255, 255, 255, .08); }
body[data-theme="dark"] .nav-item.is-active { color: #fff; background: rgba(255, 255, 255, .1); }
body[data-theme="dark"] .history-item:hover, body[data-theme="dark"] .history-item.is-active { color: #fff; background: rgba(255, 255, 255, .09); }
body[data-theme="dark"] .history-delete:hover { color: var(--coral); background: rgba(255, 255, 255, .08); }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .options-panel { position: fixed; top: 68px; right: 0; z-index: 30; width: 300px; height: calc(100vh - 68px); border-left: 1px solid var(--line); background: var(--surface-quiet); box-shadow: var(--shadow); transform: translateX(105%); }
  .options-panel:not(.is-hidden) { transform: translateX(0); }
  .options-panel.is-hidden { display: none; }
  .topbar-kicker { display: none; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; width: 244px; transform: translateX(-102%); transition: transform .24s ease; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: translateX(0); }
  .history-delete { opacity: 1; }
  .topbar { min-height: 58px; gap: 8px; padding: 0 13px; }
  .topbar-menu { display: inline-flex; padding: 7px 8px; }
  .topbar-context { min-width: 0; gap: 7px; }
  .topbar-kicker { display: none; }
  .topbar-current { max-width: 145px; font-size: 11px; }
  .topbar-actions { gap: 4px; }
  .gateway-status { gap: 5px; font-size: 0; }
  .gateway-status .status-dot { width: 8px; height: 8px; }
  .topbar-action, .theme-toggle { padding: 6px 7px; font-size: 10px; }
  .content-area { min-height: calc(100vh - 58px); }
  .chat-view { padding: 0 15px; }
  .message-stream { padding-top: 20px; }
  .empty-state { min-height: 330px; padding-top: 28px; }
  .empty-state h1 { max-width: 400px; font-size: 35px; }
  .empty-subtitle { max-width: 320px; font-size: 12px; line-height: 1.5; }
  .starter-questions { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .starter-question { min-height: 47px; font-size: 11px; }
  .message { grid-template-columns: 1fr; gap: 5px; }
  .message-meta { font-size: 9px; }
  .message-body { font-size: 13px; }
  .source-details { margin-left: 0; }
  .composer { margin-bottom: 12px; padding: 9px 10px 7px; }
  .composer textarea { font-size: 13px; }
  .composer-note { font-size: 9px; }
  .key-hint { display: none; }
  .library-view { padding: 25px 15px 40px; }
  .library-heading-row { align-items: flex-start; flex-direction: column; gap: 16px; }
  .library-heading-row h1 { font-size: 31px; }
  .library-actions { width: 100%; }
  .library-actions > * { flex: 1; }
  .transcript-row { grid-template-columns: minmax(0, 1fr) 65px; gap: 7px; padding: 9px 0; }
  .transcript-row .topic-chips { grid-column: 1 / -1; justify-content: flex-start; }
  .transcript-name { font-size: 11px; }
  .transcript-meta { font-size: 9px; }
  .options-panel { top: 58px; width: min(320px, 90vw); height: calc(100vh - 58px); }
}

@media print {
  body { color: #1E2229; background: #fff; }
  .sidebar, .options-panel, .composer, .starter-questions, .library-view, .topbar-actions, .topbar-menu { display: none !important; }
  .app-shell, .main-column, .workspace, .content-area, .chat-view { display: block; min-height: 0; height: auto; background: #fff; }
  .topbar { min-height: 0; padding: 0 0 16px; border: 0; background: #fff; }
  .chat-view { padding: 0; }
  .message-stream { display: block; width: 100%; overflow: visible; padding: 0; }
  .message { margin: 0 0 22px; break-inside: avoid; }
  .message-body { color: #1E2229; }
  .source-details { display: block; }
  .source-details > * { display: block; }
}