:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #647084;
  --line: #dfe3ea;
  --accent: #1f7a6d;
  --accent-strong: #155d54;
  --soft: #edf3f2;
  --warn: #955a13;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { border: 0; background: var(--accent); color: white; border-radius: 6px; padding: 0.68rem 0.9rem; cursor: pointer; font-weight: 700; }
button:hover { background: var(--accent-strong); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button.secondary { background: var(--soft); color: var(--accent-strong); padding: 0.45rem 0.65rem; }
.icon-button { width: 30px; height: 30px; padding: 0 !important; display: grid; place-items: center; border-radius: 999px; font-size: 18px; line-height: 1; }
.mini-link { display: inline-block; text-decoration: none; border-radius: 6px; font-weight: 800; }
.app-shell { height: 100vh; display: grid; grid-template-columns: 320px minmax(0, 1fr) auto; overflow: hidden; }
.sidebar { border-right: 1px solid var(--line); background: #fbfcfd; padding: 1rem; overflow-y: auto; }
.brand { display: flex; gap: 0.85rem; align-items: center; margin-bottom: 1rem; }
.mark { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; background: #22313f; color: white; font-weight: 800; flex: 0 0 auto; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.15rem; }
h2 { font-size: 0.95rem; }
h3 { font-size: 1rem; }
.panel-header h2 { display: inline-flex; align-items: center; gap: 0.35rem; }
.panel-title-icon { width: 16px; height: 16px; border-radius: 4px; display: inline-grid; place-items: center; color: var(--accent-strong); background: var(--soft); font-size: 0.7rem; line-height: 1; }
.brand p, .muted, small, .chat-header p { color: var(--muted); }
.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 0.9rem; margin-bottom: 1rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.panel-actions { display: flex; gap: 0.4rem; align-items: center; }
.session-list, .book-list { display: grid; gap: 0.55rem; }
.session-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3rem; align-items: stretch; border: 1px solid transparent; border-radius: 7px; }
.session-row:hover, .session-row.active { background: #eef1f5; border-color: var(--line); }
.session-item { width: 100%; border: 0; background: transparent; color: var(--text); display: grid; gap: 0.18rem; text-align: left; padding: 0.65rem; border-radius: 7px; min-width: 0; }
.session-action { align-self: center; background: transparent; color: var(--muted); border: 1px solid transparent; padding: 0.35rem; font-size: 0.72rem; }
.session-action:hover { background: var(--soft); color: var(--accent-strong); border-color: var(--line); }
.session-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-actions { position: relative; display: grid; place-items: center; padding-right: 0.25rem; }
.session-more { opacity: 0; pointer-events: none; width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 900; line-height: 1; padding: 0 0 0.16rem; }
.session-row:hover .session-more, .session-row:focus-within .session-more { opacity: 1; pointer-events: auto; }
.session-more:hover, .session-more:focus { background: #fff; border-color: var(--line); color: var(--accent-strong); }
.session-menu { position: absolute; right: 0.25rem; top: calc(100% - 0.1rem); z-index: 30; min-width: 104px; display: grid; gap: 0.25rem; padding: 0.3rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: 0 12px 28px rgba(24, 32, 42, 0.14); }
.session-menu-item { width: 100%; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--text); padding: 0.42rem 0.55rem; text-align: left; font-size: 12px; font-weight: 800; }
.session-menu-item:hover { background: var(--soft); color: var(--accent-strong); }
.session-menu-item.danger { color: #a12b2b; }
.session-menu-item.danger:hover { background: #fff2f2; border-color: #ddb2b2; }
.book-item { display: grid; width: 100%; grid-template-columns: 1fr; align-items: start; gap: 0.65rem; padding: 0.65rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin: 0; color: var(--muted); font-size: 0.86rem; font-weight: 650; text-align: left; }
.book-item:hover, .book-item.active { background: #eef7f5; border-color: #adcfc7; color: var(--muted); }
.book-item span { display: grid; gap: 0.18rem; min-width: 0; }
.book-item strong { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-item em { color: var(--warn); font-style: normal; font-size: 0.76rem; }
.empty-mini { border: 1px dashed var(--line); border-radius: 8px; padding: 0.75rem; display: grid; gap: 0.35rem; color: var(--muted); line-height: 1.4; }
.empty-mini strong { color: var(--text); }
.empty-mini a { color: var(--accent-strong); font-weight: 800; text-decoration: none; }
.saved-source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem; align-items: stretch; }
.saved-source-row .book-item { margin: 0; }
.onboarding-steps { display: grid; gap: 0.5rem; }
.onboarding-step { border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; padding: 0.62rem; display: grid; grid-template-columns: auto 1fr; gap: 0.18rem 0.5rem; align-items: center; }
.onboarding-step span { border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.68rem; font-weight: 900; padding: 0.15rem 0.38rem; text-transform: uppercase; }
.onboarding-step strong { color: var(--text); font-size: 0.84rem; }
.onboarding-step small { grid-column: 2; color: var(--muted); line-height: 1.35; }
.onboarding-step.done { background: #f1f8f6; border-color: #b9d8d1; }
.onboarding-step.done span { color: var(--accent-strong); background: #e0f0ec; border-color: #adcfc7; }
.scope-controls { display: grid; gap: 0.65rem; margin-bottom: 0.75rem; }
.scope-controls label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.84rem; font-weight: 800; }
.scope-controls label.active { display: grid !important; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.45rem; }
.selected-scope { border: 1px solid var(--line); border-radius: 6px; background: #f7faf9; color: var(--muted); font-size: 0.82rem; line-height: 1.4; padding: 0.55rem 0.65rem; margin-bottom: 0.75rem; }
.chat-shell { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--panel); }
.chat-header { border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; }
.messages { overflow-y: auto; padding: 1.25rem; display: grid; align-content: start; gap: 1rem; }
.empty-state { color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 1rem; background: #fbfcfd; display: grid; gap: 0.75rem; }
.empty-state.guide-text { color: #8a94a6; font-size: 13px; font-weight: 600; padding: 0.8rem 0.9rem; }
.empty-state h3 { color: var(--text); font-size: 1.05rem; }
.prompt-starters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.prompt-starter { background: #eef1f5; color: var(--text); border: 1px solid var(--line); padding: 0.5rem 0.65rem; font-size: 0.84rem; text-align: left; }
.prompt-starter:hover { background: #e0f0ec; color: var(--accent-strong); }
.message { max-width: 860px; border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem; background: #fbfcfd; }
.message.user { margin-left: auto; background: #eef7f5; border-color: #cfe2dd; }
.message.assistant { margin-right: auto; }
.message-role { color: var(--muted); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; margin-bottom: 0.45rem; }
.message-content { white-space: pre-wrap; line-height: 1.6; }
.show-sources { margin-top: 0.8rem; }
.feedback-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin-top: 0.75rem; color: var(--muted); font-size: 0.82rem; }
.feedback-button { background: #eef1f5; color: var(--accent-strong); border: 1px solid var(--line); padding: 0.32rem 0.5rem; font-size: 0.78rem; }
.feedback-button:hover { background: var(--soft); }
.composer { border-top: 1px solid var(--line); padding: 1rem 1.25rem; background: #fbfcfd; display: grid; gap: 0.75rem; }
textarea, input, select { width: 100%; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: white; padding: 0.68rem 0.75rem; }
textarea { resize: vertical; min-height: 92px; max-height: 220px; }
.composer-actions { display: flex; justify-content: flex-end; align-items: end; gap: 0.75rem; }
.top-k { width: 120px; margin: 0; display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.84rem; font-weight: 700; }
.source-panel { position: relative; width: 520px; max-width: 94vw; height: 100vh; border-left: 1px solid var(--line); background: #fbfcfd; display: grid; grid-template-rows: auto auto auto 1fr; transition: width 140ms ease; }
.source-panel.closed { width: 0 !important; border-left: 0; overflow: hidden; }
.source-resizer { position: absolute; left: -4px; top: 0; width: 8px; height: 100%; cursor: col-resize; }
.source-header { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem; border-bottom: 1px solid var(--line); }
.source-nav { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.source-list { display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.source-chip { min-width: 150px; display: grid; gap: 0.15rem; text-align: left; background: #eef1f5; color: var(--text); border: 1px solid var(--line); }
.source-chip.active { background: #e0f0ec; border-color: #adcfc7; }
.source-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-reader { overflow-y: auto; padding: 1rem; display: grid; align-content: start; gap: 0.75rem; user-select: none; }
.summary { color: var(--muted); line-height: 1.5; }
.source-note-field { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.84rem; font-weight: 800; user-select: text; }
.source-note-field textarea { min-height: 88px; resize: vertical; user-select: text; }
.source-note-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
pre { white-space: pre-wrap; overflow: visible; background: #eef1f5; padding: 0.9rem; border-radius: 6px; margin: 0; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
#source-content { user-select: none; -webkit-user-select: none; position: relative; background-image: repeating-linear-gradient(-24deg, rgba(31, 122, 109, 0.08) 0 1px, transparent 1px 44px); }
.protected-page { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; pointer-events: none; user-select: none; -webkit-user-drag: none; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 280px minmax(0, 1fr); }
  .source-panel { position: fixed; right: 0; top: 0; z-index: 10; max-width: 92vw; box-shadow: -18px 0 40px rgba(24, 32, 42, 0.18); }
}
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .composer-actions { align-items: stretch; flex-direction: column; }
  .top-k { width: 100%; }
  .source-panel { width: 100vw !important; max-width: 100vw; }
}
.hidden { display: none !important; }
.chat-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.user-actions { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.9rem; }
.button-link { display: inline-block; text-decoration: none; border-radius: 6px; padding: 0.72rem 1rem; background: var(--accent); color: white; font-weight: 800; }
.secondary-link { background: var(--soft); color: var(--accent-strong); }
.landing { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: var(--panel); }
.landing section { max-width: 760px; display: grid; gap: 1.2rem; }
.marketing { align-content: start; place-items: stretch; gap: 1.5rem; overflow-x: hidden; }
.marketing section { width: min(1040px, 100%); justify-self: center; max-width: 1040px; min-width: 0; }
.hero-band { padding: 1rem 0; }
.marketing-nav { display: flex; flex-wrap: wrap; gap: 0.7rem 1rem; align-items: center; margin-bottom: 2rem; min-width: 0; }
.marketing-nav a:first-child { margin-right: auto; }
.marketing-nav a { color: var(--text); text-decoration: none; font-weight: 800; }
.marketing-nav .nav-login { background: var(--soft); color: var(--accent-strong); border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.7rem; margin-left: 0.2rem; }
.marketing-nav .nav-login:hover { background: #dfecea; }
.feature-grid, .price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0.85rem; min-width: 0; }
.feature-grid article, .price-grid article { border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; padding: 1rem; display: grid; gap: 0.55rem; min-width: 0; overflow-wrap: anywhere; }
.conversion-band { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 1.5rem 0; }
.price-grid ul { margin: 0; padding-left: 1.1rem; color: var(--muted); line-height: 1.55; }
.featured-price { border-color: #adcfc7 !important; background: #f7fbfa !important; }
.price-grid strong { font-size: 1.5rem; color: var(--accent-strong); }
.beta-pill { display: inline-flex; width: fit-content; border: 1px solid #adcfc7; border-radius: 999px; background: #e0f0ec; color: var(--accent-strong); font-size: 0.76rem; font-weight: 900; letter-spacing: 0; padding: 0.28rem 0.55rem; text-transform: uppercase; }
.notice-band { border: 1px solid var(--line); border-radius: 8px; background: #f7faf9; padding: 1rem; display: grid; gap: 0.35rem; line-height: 1.5; }
.notice-band strong { color: var(--text); }
.notice-band p { color: var(--muted); }
.beta-pricing button:disabled { background: #eef1f5; color: var(--muted); border: 1px solid var(--line); opacity: 1; }
.demo-card textarea { min-height: 130px; }
.demo-prompts { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.demo-prompts button { background: #eef1f5; color: var(--text); border: 1px solid var(--line); padding: 0.48rem 0.6rem; font-size: 0.84rem; }
.demo-answer { display: grid; gap: 0.6rem; }
.demo-answer ul { margin: 0; padding-left: 1.1rem; }
.demo-video-panel { display: grid; }
.demo-video-frame { min-height: 300px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(135deg, #162433, #253547); color: #fff; display: grid; place-items: center; text-align: center; gap: 1rem; padding: 2rem; }
.demo-video-frame p { color: #d9e1eb; max-width: 560px; line-height: 1.5; }
.play-mark { width: 58px; height: 58px; border-radius: 999px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.28); padding-left: 0.2rem; }
.signup-benefits { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.signup-benefits span { border: 1px solid var(--line); background: #f7faf9; color: var(--muted); border-radius: 999px; padding: 0.3rem 0.55rem; font-size: 0.78rem; font-weight: 800; }
.marketing-footer { width: min(1040px, 100%); justify-self: center; display: flex; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.marketing-footer a { color: var(--muted); text-decoration: none; font-weight: 700; }
.legal-copy { line-height: 1.65; }
.legal-copy h2 { margin-top: 0.8rem; font-size: 1.05rem; }
.brand.big .mark { width: 58px; height: 58px; font-size: 1.1rem; }
.landing h2 { font-size: 2.5rem; line-height: 1.05; max-width: 720px; }
.lead { color: var(--muted); font-size: 1.1rem; line-height: 1.6; }
.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(420px, 100%); display: grid; gap: 0.9rem; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 1.25rem; }
.auth-card label { display: grid; gap: 0.35rem; color: var(--muted); font-weight: 700; }
.status { color: var(--muted); line-height: 1.5; }
.admin-page { min-height: 100vh; padding: 1.25rem; display: grid; align-content: start; gap: 1rem; }
.admin-header { display: flex; justify-content: space-between; gap: 1rem; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.8rem; }
.metric-card { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 1rem; display: grid; gap: 0.35rem; }
.metric-card span { color: var(--muted); font-size: 0.85rem; }
.metric-card strong { font-size: 1.6rem; }
.admin-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.admin-tables article { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 1rem; overflow: auto; }
.admin-users { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 1rem; overflow: auto; }
.admin-users input, .admin-users select { min-width: 110px; padding: 0.45rem 0.5rem; }
.account-page .admin-users { display: grid; gap: 0.8rem; }
.account-actions { display: grid; grid-template-columns: minmax(300px, 1.35fr) minmax(0, 1fr) minmax(180px, 220px) minmax(260px, 360px); gap: 1rem; align-items: start; }
.account-page .metric-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.account-page .metric-card { min-width: 0; overflow: hidden; }
.account-page .metric-card strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.35rem; }
.account-page .metric-email { grid-column: span 2; }
.account-page .metric-email strong { font-size: 1rem; overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.account-page .danger-zone { padding: 0.85rem; }
.account-page .danger-zone .status { font-size: 0.85rem; }
.account-page .danger-zone input { min-height: 36px; }
.account-page .danger-zone button { padding: 0.55rem 0.75rem; }
.book-upload-form { display: grid; gap: 0.7rem; }
.book-upload-form label { display: grid; gap: 0.3rem; color: var(--muted); font-weight: 800; }
.book-upload-form .check-row { grid-template-columns: auto 1fr; align-items: start; color: var(--text); font-size: 0.88rem; line-height: 1.35; }
.book-upload-form .check-row input { width: auto; min-width: 0; margin-top: 0.12rem; }
.danger-zone { border-color: #e3b5b5; background: #fffafa; }
.danger-zone button { background: #9c2f2f; }
.danger-zone button:hover { background: #7f2424; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 0.55rem; }
th { color: var(--muted); }
.usage-pill { border: 1px solid var(--line); background: #f7faf9; border-radius: 999px; padding: 0.35rem 0.6rem; color: var(--muted); font-size: 0.82rem; font-weight: 800; white-space: nowrap; }
.usage-pill.near-limit { color: #8a4b08; background: #fff5e8; border-color: #f0c98d; }

/* Compact app polish */
body { font-size: 14px; line-height: 1.35; }
button { border-radius: 5px; padding: 0.5rem 0.7rem; font-size: 0.88rem; font-weight: 750; }
button.secondary { padding: 0.4rem 0.55rem; }
.button-link { border-radius: 5px; padding: 0.52rem 0.72rem; font-size: 0.86rem; font-weight: 750; white-space: nowrap; }
.app-shell { grid-template-columns: 300px minmax(0, 1fr) auto; }
.sidebar { padding: 0.75rem; }
.brand { gap: 0.65rem; margin-bottom: 0.75rem; }
.mark { width: 36px; height: 36px; border-radius: 7px; font-size: 0.9rem; }
h1 { font-size: 1rem; }
h2 { font-size: 0.86rem; }
h3 { font-size: 0.92rem; }
.brand p { font-size: 0.86rem; line-height: 1.25; }
.panel { border-radius: 7px; padding: 0.7rem; margin-bottom: 0.75rem; }
.panel-header { margin-bottom: 0.55rem; }
.session-list, .book-list { gap: 0.45rem; }
.session-row { border-radius: 6px; }
.session-item { padding: 0.5rem 0.55rem; }
.book-item { border-radius: 6px; padding: 0.55rem; gap: 0.4rem; font-size: 0.82rem; }
.book-item small, .book-item em { font-size: 0.72rem; }
.scope-controls { gap: 0.5rem; margin-bottom: 0.55rem; }
.scope-controls label { gap: 0.25rem; font-size: 0.78rem; }
.selected-scope { margin-bottom: 0.55rem; padding: 0.45rem 0.55rem; font-size: 0.78rem; }
.onboarding-step { border-radius: 6px; padding: 0.5rem; }
.onboarding-step strong { font-size: 0.78rem; }
.onboarding-step small { font-size: 0.76rem; }
.onboarding-step span { font-size: 0.62rem; }
.chat-header {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}
.chat-header > div:first-child { min-width: 0; }
.chat-header h2 { font-size: 0.98rem; margin-bottom: 0.12rem; }
.chat-header p { max-width: 640px; font-size: 0.86rem; line-height: 1.25; }
.user-actions { justify-content: flex-end; flex-wrap: wrap; gap: 0.45rem; font-size: 0.82rem; min-width: 0; }
#current-user { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-pill { padding: 0.28rem 0.5rem; font-size: 0.76rem; }
.messages { padding: 1rem; gap: 0.8rem; background: #fcfdfe; }
.message { max-width: min(780px, 78%); border-radius: 7px; padding: 0.75rem 0.85rem; background: #fff; }
.message.user { max-width: min(620px, 70%); }
.message-role { font-size: 0.68rem; margin-bottom: 0.35rem; }
.message-content { line-height: 1.5; font-size: 0.92rem; }
.feedback-row { margin-top: 0.55rem; font-size: 0.76rem; }
.feedback-button { padding: 0.25rem 0.42rem; font-size: 0.74rem; }
.composer { padding: 0.75rem 1rem; gap: 0.55rem; }
textarea, input, select { border-radius: 5px; padding: 0.52rem 0.6rem; font-size: 0.88rem; }
textarea { min-height: 76px; max-height: 180px; }
.composer-actions { gap: 0.55rem; }
.top-k { width: 110px; gap: 0.22rem; font-size: 0.76rem; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 280px minmax(0, 1fr) auto; }
  .chat-header { grid-template-columns: 1fr; align-items: start; }
  .chat-header p { display: none; }
  .user-actions { justify-content: flex-start; }
  .message, .message.user { max-width: 92%; }
}

/* Final compact app shell */
.app-shell { grid-template-columns: 260px minmax(0, 1fr) auto; font-size: 12px; }
.sidebar { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.6rem; font-size: 12px; line-height: 1.25; }
.brand { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.55rem; align-items: center; margin-bottom: 0.25rem; }
.brand h1 { font-size: 14px; line-height: 1.15; }
.mark { width: 32px; height: 32px; font-size: 12px; }
.panel { padding: 0.6rem; margin-bottom: 0; border-radius: 7px; }
.panel h2, .source-header h2 { font-size: 13px; }
.panel-header { margin-bottom: 0.45rem; }
button, .button-link, textarea, input, select { font-size: 12px; border-radius: 5px; }
button { padding: 0.42rem 0.58rem; }
button.secondary { padding: 0.34rem 0.5rem; }
textarea, input, select { padding: 0.45rem 0.55rem; }
.scope-controls { gap: 0.42rem; margin-bottom: 0; }
.scope-controls label, .top-k, .source-note-field { font-size: 11px; gap: 0.2rem; }
.session-list, .book-list { gap: 0.35rem; }
.session-item, .book-item { padding: 0.45rem; font-size: 12px; }
.session-item span, .book-item strong { font-size: 12px; }
.session-item small, .book-item small, .book-item em { font-size: 11px; }
.chat-shell { grid-template-rows: 42px minmax(0, 1fr) auto; }
.chat-header { display: flex; justify-content: flex-end; padding: 0.45rem 0.85rem; min-height: 42px; }
.user-actions, .usage-pill { font-size: 12px; }
.usage-pill { padding: 0.22rem 0.48rem; }
.messages { padding: 0.85rem; gap: 0.7rem; font-size: 13px; }
.empty-state { padding: 0.75rem; }
.empty-state h3 { font-size: 13px; }
.prompt-starter { font-size: 12px; padding: 0.38rem 0.5rem; }
.message { font-size: 13px; max-width: min(760px, 82%); padding: 0.65rem 0.72rem; }
.message-content { font-size: 13px; line-height: 1.42; }
.message-role, .feedback-row, .feedback-button { font-size: 11px; }
.composer { display: flex; align-items: stretch; gap: 0.5rem; padding: 0.6rem 0.85rem; }
.composer textarea { flex: 1 1 auto; min-width: 0; min-height: 58px; max-height: none; resize: none; overflow-y: hidden; line-height: 1.35; }
.composer #ask { flex: 0 0 auto; align-self: flex-end; width: auto !important; min-width: 54px; height: 34px; padding-inline: 0.8rem; }
.source-panel { font-size: 12px; }
.source-reader, .source-header, .source-nav, .source-list { font-size: 12px; }
.source-reader h3 { font-size: 13px; }
pre, #source-content, .summary { font-size: 12px; line-height: 1.42; }
.sidebar-footer { margin-top: auto; position: sticky; bottom: 0; display: grid; justify-content: start; justify-items: start; gap: 0.45rem; padding-top: 0.55rem; background: #fbfcfd; }
.settings-toggle, .sidebar-toggle, .home-button { width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; border: 1px solid var(--line); background: #fff; color: var(--muted); text-decoration: none; font-weight: 800; padding: 0; }
.help-button { width: 30px !important; height: 30px !important; min-width: 30px !important; min-height: 30px !important; border-radius: 999px !important; display: grid !important; place-items: center !important; border: 1px solid var(--line) !important; background: #fff !important; color: var(--muted) !important; text-decoration: none !important; font-weight: 900 !important; padding: 0 !important; font-size: 13px !important; line-height: 1 !important; }
.help-button:hover, .settings-toggle:hover, .sidebar-toggle:hover, .home-button:hover { background: var(--soft); color: var(--accent-strong); }
.sidebar-toggle { border: 1px solid var(--line) !important; border-radius: 999px !important; background: #fff !important; color: #1e2b38 !important; }
.sidebar-toggle:hover { background: var(--soft) !important; color: #14202b !important; }
.sidebar-icon { width: 14px; height: 12px; border: 1.5px solid #1e2b38; border-radius: 3px; display: block; position: relative; }
.sidebar-icon::before { content: ""; position: absolute; left: 4px; top: 2px; bottom: 2px; width: 1.5px; border-radius: 999px; background: currentColor; }
.sidebar-toggle .sidebar-icon::before { background: #1e2b38; }
.sidebar-settings { position: relative; }
.settings-menu { position: absolute !important; left: 38px !important; bottom: 0 !important; min-width: 184px !important; display: grid; gap: 0.35rem !important; padding: 0.45rem !important; border: 1px solid var(--line) !important; border-radius: 8px !important; background: #fff !important; box-shadow: 0 14px 35px rgba(24, 32, 42, 0.13) !important; z-index: 20 !important; }
.settings-menu.hidden { display: none !important; }
.settings-menu-button { display: flex !important; align-items: center !important; justify-content: center !important; width: 100% !important; min-height: 32px !important; border: 1px solid var(--line) !important; border-radius: 6px !important; padding: 0.42rem 0.55rem !important; background: var(--soft) !important; color: var(--accent-strong) !important; text-align: center !important; text-decoration: none !important; font-size: 12px !important; font-weight: 800 !important; cursor: pointer !important; }
.settings-menu-button:hover { background: #dfecea !important; color: var(--accent-strong) !important; }
.settings-menu-button.danger { border-color: #ddb2b2 !important; background: #fff2f2 !important; color: #a12b2b !important; }
.settings-menu-button.danger:hover { background: #a12b2b !important; color: #fff !important; }
.settings-user { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; padding: 0.25rem 0.5rem 0.35rem; border-bottom: 1px solid var(--line); margin-bottom: 0.2rem; }
.settings-usage { display: block; width: 100%; border-radius: 6px; padding: 0.42rem 0.5rem; white-space: normal; }
.sidebar-collapsed .app-shell { grid-template-columns: 52px minmax(0, 1fr) auto; }
.sidebar-collapsed .sidebar { padding: 0.55rem 0.6rem; overflow: visible; align-items: center; background: #171717; border-right-color: #262626; }
.sidebar-collapsed .brand { grid-template-columns: 1fr; justify-items: center; gap: 0.45rem; }
.sidebar-collapsed .brand div, .sidebar-collapsed .panel { display: none; }
.sidebar-collapsed .mark { background: #2d2d2d; color: #f7f7f7; border-radius: 9px; }
.sidebar-collapsed .sidebar-toggle, .sidebar-collapsed .settings-toggle, .sidebar-collapsed .help-button, .sidebar-collapsed .home-button { background: transparent !important; border-color: transparent !important; color: #c9c9c9 !important; }
.sidebar-collapsed .sidebar-toggle:hover, .sidebar-collapsed .settings-toggle:hover, .sidebar-collapsed .help-button:hover, .sidebar-collapsed .home-button:hover { background: #2d2d2d !important; color: #fff !important; }
.sidebar-collapsed .sidebar-icon { border-color: #c9c9c9; }
.sidebar-collapsed .sidebar-toggle .sidebar-icon::before { background: #c9c9c9; }
.sidebar-collapsed .sidebar-footer { background: #171717; justify-items: center; width: 100%; }
.sidebar-collapsed .settings-menu { left: 36px !important; bottom: 0 !important; }
.icon-picker { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.icon-choice { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; font-weight: 800; }
.icon-choice:hover, .icon-choice.active { background: #1e2b38; color: #fff; border-color: #1e2b38; }
.guide-page { min-height: 100vh; background: var(--panel); padding: 2rem; display: grid; align-content: start; gap: 1rem; }
.guide-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.guide-header p { color: var(--muted); margin-top: 0.3rem; }
.guide-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.8rem; }
.guide-steps article { border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem; display: grid; gap: 0.35rem; }
.guide-steps span { width: 24px; height: 24px; border-radius: 999px; display: grid; place-items: center; background: var(--soft); color: var(--accent-strong); font-weight: 800; font-size: 12px; }
.guide-steps p { color: var(--muted); line-height: 1.45; }
@media (max-width: 820px) {
  .account-actions { grid-template-columns: 1fr; }
  .account-page .metric-email { grid-column: 1 / -1; }
  .landing { padding: 1rem; }
  .landing h2 { font-size: 2rem; }
  .lead { font-size: 1rem; }
  .marketing-nav a:first-child { flex-basis: 100%; margin-right: 0; }
}
