:root {
  --ink: #15130F;
  --ink-soft: #1E1B15;
  --panel: #242019;
  --panel-2: #2B261E;
  --line: #3A3327;
  --paper: #EFE6D4;
  --paper-dim: #B8AD96;
  --turmeric: #E8A23D;
  --turmeric-soft: #4A3A1F;
  --peacock: #2C8A84;
  --peacock-soft: #173430;
  --danger: #D2685A;
  --danger-soft: #3A1E1A;
  --amber-soft: #3B311C;
  --radius: 14px;
  --font-display: Georgia, "Tiro Devanagari Hindi", "Noto Serif", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--ink); color: var(--paper); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
button, input, select, textarea { font-family: inherit; }
::selection { background: var(--turmeric); color: var(--ink); }
:focus-visible { outline: 2px solid var(--turmeric); outline-offset: 2px; }
a { color: var(--peacock); }
code { background: var(--panel); padding: 1px 5px; border-radius: 5px; font-size: 0.92em; }
mark { background: var(--turmeric-soft); color: var(--paper); border-radius: 3px; padding: 0 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

input:not([type=checkbox]):not([type=file]), select, textarea {
  background: var(--panel); color: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 13.5px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--turmeric); outline: none; }
input[type="file"] { display: none; }
input[type=checkbox] { accent-color: var(--peacock); }
input[type=date] { color-scheme: dark; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--ink-soft); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-mark { font-family: var(--font-display); font-size: 21px; font-weight: 700; color: var(--turmeric); white-space: nowrap; background: none; border: none; padding: 0; cursor: pointer; }
.brand-n { color: var(--peacock); }
.brand-sub { font-family: var(--font-body); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--peacock); font-weight: 600; margin-left: 2px; }
.brand-doc { font-size: 13px; color: var(--paper-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.status-pill { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--paper-dim); white-space: nowrap; cursor: pointer; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--paper-dim); flex-shrink: 0; }
.status-dot.ready { background: var(--peacock); box-shadow: 0 0 6px var(--peacock); }
.status-dot.busy { background: var(--turmeric); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.off { background: #6b6253; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--paper); cursor: pointer; font-size: 16px; }
.icon-btn:hover { border-color: var(--turmeric); }
.icon-btn.small { width: 30px; height: 30px; font-size: 13px; }

/* ---------- Nav ---------- */
.navbar { display: flex; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--ink); overflow-x: auto; scrollbar-width: none; position: sticky; top: 61px; z-index: 9; }
.navbar::-webkit-scrollbar { display: none; }
.navbar button { flex-shrink: 0; background: none; border: 1px solid transparent; color: var(--paper-dim); padding: 7px 12px; border-radius: 9px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.navbar button:hover:not(:disabled) { color: var(--paper); border-color: var(--line); }
.navbar button.active { background: var(--panel); color: var(--turmeric); border-color: var(--line); }
.navbar button:disabled { opacity: .35; cursor: not-allowed; }
.nav-sep { width: 1px; background: var(--line); margin: 4px 6px; flex-shrink: 0; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view { padding: 20px clamp(14px, 3vw, 36px) 60px; max-width: 1280px; width: 100%; margin: 0 auto; }
.view-chat { padding: 0; max-width: none; flex: 1; display: flex; flex-direction: column; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.view-title, .title-input { font-family: var(--font-display); font-size: 24px; margin: 0 0 4px; color: var(--paper); font-weight: 700; }
.title-input { background: transparent !important; border: 1px solid transparent !important; padding: 2px 6px !important; margin-left: -7px; width: min(640px, 90vw); font-size: 24px !important; }
.title-input:hover, .title-input:focus { border-color: var(--line) !important; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.head-actions.left { justify-content: flex-start; margin: 12px 0; }
.meta { color: var(--paper-dim); font-size: 12.5px; }
.warn { color: var(--turmeric); }
.empty { color: var(--paper-dim); font-size: 13.5px; font-style: italic; }
.small-note { font-size: 12px; color: var(--paper-dim); line-height: 1.55; }
.sub-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--paper-dim); margin: 16px 0 8px; font-weight: 600; }
.linkish { background: none; border: none; color: var(--peacock); cursor: pointer; padding: 0; text-decoration: underline; font-size: inherit; }
.grow { flex: 1; min-width: 220px; }

/* ---------- Buttons ---------- */
.btn { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--paper); font-size: 13.5px; cursor: pointer; text-align: center; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { border-color: var(--turmeric); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--turmeric); color: var(--ink); border-color: var(--turmeric); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.drawer .btn { margin-top: 12px; width: 100%; justify-content: center; }

/* ---------- Panels ---------- */
.panel { background: var(--ink-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel h2 { font-family: var(--font-display); font-size: 17px; margin: 0; color: var(--paper); }
.warn-panel { border-color: var(--turmeric); background: var(--amber-soft); }
.info-panel ol { padding-left: 20px; line-height: 1.6; font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 + .panel, .grid-2 + .warn-panel { margin-top: 16px; }
.plain-list { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.6; }
.plain-list li { margin-bottom: 3px; }

/* ---------- Home ---------- */
.home-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(300px, 1.1fr); gap: 18px; align-items: stretch; }
@media (max-width: 820px) { .home-grid { grid-template-columns: 1fr; } }
.dropzone { border: 1.5px dashed var(--line); border-radius: 20px; padding: 40px 26px; text-align: center; cursor: pointer; background: var(--ink-soft); position: relative; overflow: hidden; transition: border-color .2s, background .2s; display: flex; flex-direction: column; justify-content: center; }
.dropzone:hover, .dropzone.drag-over { border-color: var(--turmeric); }
.dropzone.drag-over { background: var(--turmeric-soft); }
.dropzone-glyph { width: 56px; height: 56px; margin: 0 auto 16px; }
.dropzone-glyph svg { width: 100%; height: 100%; }
.dropzone h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 8px; }
.dropzone p { margin: 0 0 4px; color: var(--paper-dim); font-size: 14px; line-height: 1.5; }
.dropzone .hint { font-size: 12px; opacity: .8; margin-top: 14px; }
.scan-line { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--turmeric), transparent); opacity: 0; }
.matter-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.matter-item { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.matter-item.current { border-color: var(--peacock); }
.matter-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; cursor: pointer; }
.matter-main b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matter-actions { display: flex; gap: 6px; flex-shrink: 0; }
.quick-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 18px; }
.tool-card { text-align: left; background: var(--ink-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--paper); cursor: pointer; display: flex; flex-direction: column; gap: 5px; }
.tool-card:hover { border-color: var(--turmeric); }
.tool-card b { font-family: var(--font-display); font-size: 15px; color: var(--turmeric); }
.tool-card span { font-size: 12.5px; color: var(--paper-dim); line-height: 1.45; }

/* ---------- Overview ---------- */
.cat-list { display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.cat-row input { margin-top: 3px; }
.cat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.cat-main b { font-size: 14px; }
.cat-main .meta { font-size: 11px; overflow-wrap: anywhere; }
.pct { font-size: 13px; color: var(--turmeric); font-weight: 600; }
.bar { height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--peacock); }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.inline-form select { max-width: 100%; }
.subtypes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
.chip-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 4px 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.chip-check.wide { margin-top: 12px; border-radius: 10px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 24px; font-family: var(--font-display); }
.stat span { font-size: 11.5px; color: var(--paper-dim); }
.stat.found b { color: var(--peacock); } .stat.check b { color: var(--turmeric); } .stat.missing b { color: var(--danger); }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.fact-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.fact-box h4 { margin: 0 0 6px; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--turmeric); }
.fact { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.fact:last-child { border-bottom: none; }
.fact > span { overflow-wrap: anywhere; }
.concord { color: var(--peacock); font-size: 11.5px; }
.cite { background: var(--peacock-soft); color: var(--peacock); border: 1px solid transparent; border-radius: 6px; font-size: 10.5px; padding: 1px 6px; white-space: nowrap; cursor: pointer; flex-shrink: 0; font-family: var(--font-body); }
.cite:hover { border-color: var(--peacock); }
.timeline { max-height: 520px; overflow-y: auto; display: flex; flex-direction: column; }
.tl-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; align-items: baseline; }
.tl-date { color: var(--turmeric); font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-ctx { color: var(--paper); line-height: 1.5; overflow-wrap: anywhere; }
.mini-input { width: 120px; padding: 6px 9px !important; font-size: 12.5px !important; }
.mini-select { padding: 5px 8px !important; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { color: var(--paper-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.table-scroll { max-height: 480px; overflow: auto; }

/* ---------- Questionnaire ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; background: var(--ink); padding: 8px 0; }
@media (min-width: 900px) { .filters { position: sticky; top: 112px; z-index: 5; } }
@media (max-width: 600px) { .filters select, .filters input { flex: 1 1 45%; } .navbar { top: 0; position: relative; } .topbar { position: relative; } }
.tier-h { font-family: var(--font-display); font-size: 18px; margin: 22px 0 10px; color: var(--turmeric); }
.q-card { background: var(--ink-soft); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.q-card.st-found { border-left-color: var(--peacock); }
.q-card.st-check, .q-card.st-partial { border-left-color: var(--turmeric); }
.q-card.st-missing, .q-card.st-conflict { border-left-color: var(--danger); }
.q-card summary { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; cursor: pointer; list-style: none; }
.q-card summary::-webkit-details-marker { display: none; }
.q-num { color: var(--paper-dim); font-size: 12px; min-width: 22px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.q-text { flex: 1; font-size: 14.5px; line-height: 1.45; }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--turmeric-soft); color: var(--turmeric); white-space: nowrap; margin-left: 4px; vertical-align: 1px; }
.tag.dim { background: var(--panel); color: var(--paper-dim); }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; border: 1px solid; }
.badge.found { color: var(--peacock); border-color: var(--peacock); background: var(--peacock-soft); }
.badge.check, .badge.partial { color: var(--turmeric); border-color: var(--turmeric); background: var(--turmeric-soft); }
.badge.missing, .badge.conflict { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.q-body { padding: 0 14px 14px 46px; display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 600px) { .q-body { padding-left: 14px; } }
.q-why { font-size: 13px; color: var(--paper-dim); margin: 0; line-height: 1.5; }
.ai-answer { background: var(--peacock-soft); border: 1px solid var(--peacock); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; line-height: 1.55; }
.label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--paper-dim); margin-bottom: 4px; font-weight: 600; }
.ask-line { margin: 6px 0 0; color: var(--turmeric); font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; padding: 4px 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; color: var(--paper); cursor: default; }
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--turmeric); }
.evidence { display: flex; flex-direction: column; gap: 6px; }
.ev { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.55; color: var(--paper-dim); background: var(--panel); padding: 8px 10px; border-radius: 8px; }
.ev span { overflow-wrap: anywhere; }
.precs { background: var(--panel-2); border-radius: 10px; padding: 8px 12px; }
.prec { font-size: 12.5px; line-height: 1.5; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.prec:last-child { border-bottom: none; }
.prec b { color: var(--paper); }
.prec span { color: var(--paper-dim); }
.archive-hits:empty { display: none; }
.archive-hits { background: var(--panel-2); border-radius: 10px; padding: 8px 12px; }
.q-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.q-controls select { font-size: 12.5px; padding: 6px 8px; }
textarea.note { width: 100%; min-height: 54px; resize: vertical; font-size: 13px; }

/* ---------- Drafting ---------- */
.draft-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .draft-layout { grid-template-columns: 1fr; } }
.tpl-list { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 120px; max-height: calc(100vh - 140px); overflow-y: auto; }
@media (max-width: 820px) { .tpl-list { position: static; max-height: 260px; } }
.tpl-btn { text-align: left; background: none; border: 1px solid transparent; color: var(--paper-dim); padding: 7px 10px; border-radius: 8px; font-size: 13px; cursor: pointer; line-height: 1.35; }
.tpl-btn:hover { color: var(--paper); border-color: var(--line); }
.tpl-btn.active { background: var(--panel); color: var(--turmeric); border-color: var(--line); }
.draft-main h2 { font-family: var(--font-display); font-size: 19px; margin: 0 0 10px; }
.fields-box { background: var(--ink-soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.fields-box summary { cursor: pointer; font-size: 13.5px; color: var(--paper-dim); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.field-grid.one { grid-template-columns: 1fr; }
.field-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--paper-dim); min-width: 0; }
.field-grid label:has(textarea[rows="5"]) { grid-column: 1 / -1; }
.ip-group { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.ip-group > summary { cursor: pointer; font-size: 13px; color: var(--turmeric); font-weight: 600; }
.field-grid input, .field-grid textarea { width: 100%; }
.draft-editor { width: 100%; min-height: 520px; font-family: "Times New Roman", Georgia, serif !important; font-size: 15px !important; line-height: 1.6; background: #F6F1E6 !important; color: #1b1814 !important; border-radius: 10px; padding: 18px 20px !important; resize: vertical; }
.draft-editor.short { min-height: 280px; }

/* ---------- IP studio ---------- */
.subtabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.subtabs button { background: var(--ink-soft); border: 1px solid var(--line); color: var(--paper-dim); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13.5px; }
.subtabs button.active { color: var(--ink); background: var(--turmeric); border-color: var(--turmeric); font-weight: 600; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; margin-top: 6px; }
.class-chip { display: flex; gap: 6px; align-items: flex-start; font-size: 11.5px; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; line-height: 1.35; }
.class-chip b { color: var(--turmeric); min-width: 18px; }
.class-chip span { color: var(--paper-dim); }
.class-chip:has(input:checked) { border-color: var(--peacock); background: var(--peacock-soft); }
.flags { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.flag { font-size: 13px; line-height: 1.5; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.flag.high { border-color: var(--danger); background: var(--danger-soft); }
.flag.medium { border-color: var(--turmeric); background: var(--amber-soft); }
.flag.ok { border-color: var(--peacock); background: var(--peacock-soft); }
.flag b { margin-right: 6px; }

/* ---------- Judgment / archive ---------- */
.role-panel summary { display: flex; justify-content: space-between; align-items: baseline; cursor: pointer; list-style: none; }
.role-panel summary::-webkit-details-marker { display: none; }
.role-para { font-size: 13.5px; line-height: 1.6; color: var(--paper); border-left: 2px solid var(--line); padding-left: 10px; margin: 10px 0; }
.ai-text { font-size: 14px; line-height: 1.6; }
.ai-text h4 { color: var(--turmeric); margin: 12px 0 4px; font-family: var(--font-display); }
.arch-item summary { display: flex; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; align-items: flex-start; }
.arch-item summary::-webkit-details-marker { display: none; }
.arch-item p { font-size: 13px; line-height: 1.6; }
.dl-out { margin-top: 12px; font-size: 15px; }

/* ---------- Chat ---------- */
.chat-wrap { flex: 1; display: flex; flex-direction: column; min-height: calc(100dvh - 112px); }
.chat-thread { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 80%; padding: 12px 14px; border-radius: var(--radius); font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin-bottom: 0; } .msg ul { margin: 4px 0 8px; padding-left: 20px; } .msg h4 { margin: 8px 0 4px; color: var(--turmeric); }
.msg.user { align-self: flex-end; background: var(--turmeric); color: var(--ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.error { background: var(--ink-soft); border: 1px solid var(--danger); color: var(--danger); align-self: center; max-width: 90%; font-size: 13px; }
.source-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.source-chip { font-size: 10.5px; padding: 3px 8px; border-radius: 999px; background: var(--peacock-soft); color: var(--peacock); border: 1px solid var(--peacock); white-space: nowrap; cursor: pointer; }
.chat-suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 18px 10px; }
.composer { flex-shrink: 0; display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--ink-soft); position: sticky; bottom: 0; }
.composer textarea { flex: 1; resize: none; border-radius: 12px; padding: 12px 14px; font-size: 14.5px; max-height: 140px; min-height: 44px; }
.send-btn { flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; border: none; background: var(--turmeric); color: var(--ink); font-size: 17px; cursor: pointer; }
@media (min-width: 900px) { .chat-thread, .chat-suggest { padding-left: 12%; padding-right: 12%; } .composer { padding: 14px 12%; } .msg { max-width: 72%; } }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; width: min(380px, 94vw); height: 100%; background: var(--ink-soft); border-left: 1px solid var(--line); z-index: 21; transform: translateX(100%); transition: transform .25s; display: flex; flex-direction: column; gap: 8px; padding: 20px; overflow-y: auto; }
.drawer.open { transform: translateX(0); }
.drawer h2 { font-family: var(--font-display); font-size: 18px; margin: 0 0 8px; color: var(--turmeric); }
.drawer input:not([type=checkbox]), .drawer-select { width: 100%; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-label { font-size: 12px; color: var(--paper-dim); margin: 14px 0 2px; display: block; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.drawer-select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--paper-dim) 50%), linear-gradient(135deg, var(--paper-dim) 50%, transparent 50%); background-position: calc(100% - 16px) center, calc(100% - 11px) center; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--panel); border-radius: 10px; border: 1px solid var(--line); }
.toggle-row span { font-size: 13px; }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: background .2s; }
.switch-track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--paper); border-radius: 50%; transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--peacock); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.model-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; font-size: 13px; }
.model-row .meta { font-size: 11.5px; }
.model-row.selectable { cursor: pointer; }
.model-row.selectable:hover { border-color: var(--turmeric); }
.model-row.active { border-color: var(--peacock); background: var(--peacock-soft); }
.model-row .row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.model-row .row-action { font-size: 11.5px; color: var(--turmeric); white-space: nowrap; margin-left: 8px; }
.offline-progress-row { padding: 0 4px 8px; }
.drawer-close { position: absolute; top: 16px; right: 16px; background: none; border: none; color: var(--paper-dim); font-size: 18px; cursor: pointer; }

/* ---------- Modals ---------- */
.gate-backdrop { position: fixed; inset: 0; background: rgba(12,11,9,.92); z-index: 50; display: none; align-items: center; justify-content: center; padding: 20px; }
.gate-backdrop.open { display: flex; }
#gateBackdrop { background: var(--ink); z-index: 60; }
.gate-card { width: 100%; max-width: 400px; background: var(--ink-soft); border: 1px solid var(--line); border-radius: 20px; padding: 30px 24px; text-align: center; position: relative; }
.gate-card h3 { font-family: var(--font-display); margin: 0 0 8px; }
.gate-message { color: var(--paper-dim); font-size: 14px; line-height: 1.5; margin: 14px 0 18px; }
#gateKeyInput { width: 100%; padding: 12px 14px; font-size: 15px; text-align: center; letter-spacing: .04em; font-family: monospace; text-transform: uppercase; }
.gate-error { color: var(--danger); font-size: 12.5px; min-height: 16px; margin: 10px 0; }
.progress-card { max-width: 460px; }
.progress-card .btn { margin-top: 16px; }
.gate-card .btn { justify-content: center; }
.progress-track { width: 100%; height: 6px; background: var(--panel); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress-fill { height: 100%; background: var(--turmeric); width: 0%; transition: width .2s; }
.passage-card { max-width: 820px; text-align: left; max-height: 86vh; display: flex; flex-direction: column; }
.passage-text { overflow-y: auto; white-space: pre-wrap; font-size: 14px; line-height: 1.65; font-family: Georgia, serif; padding-right: 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(30px); background: var(--panel); border: 1px solid var(--turmeric); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 70; max-width: min(640px, 92vw); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Print (questionnaire, briefs) ---------- */
@media print {
  :root { --ink: #fff; --ink-soft: #fff; --panel: #f4f1ea; --panel-2: #f4f1ea; --line: #ccc; --paper: #111; --paper-dim: #444; --turmeric: #8a5a00; --peacock: #0d5c57; --peacock-soft: #e6f2f1; --turmeric-soft: #f6ecd8; --danger-soft: #f8e4e1; --amber-soft: #fbf3e2; }
  .topbar, .navbar, .filters, .head-actions, .q-controls, textarea.note:placeholder-shown, .archive-hits, .toast, .drawer, .drawer-backdrop { display: none !important; }
  body { background: #fff; }
  .view { padding: 0; }
  .q-card { break-inside: avoid; }
}
