
/* Layout: calm two-pane app. A quiet sidebar on the left, one focused column in the middle; sources, memory and activity slide in only when asked. Reports open as CMA-branded paper. */
:root{
  --bg:#F6F7F9; --surface:#FFFFFF; --surface-2:#F0F2F5; --line:#E2E6EC; --line-strong:#CBD2DB;
  --ink:#0A1A30; --muted:#4A5568; --faint:#667386;
  --link:#2B4A72; --primary:#0A1A30; --primary-ink:#FFFFFF; --gold:#C9A45C; --gold-soft:#FBF6EC;
  --warn:#7E4A00; --warn-soft:#FFF4DC; --warn-line:#E5B862;
  --crit:#9E2A12; --crit-soft:#FBEDE9;
  --good:#276B44; --good-soft:#E5F2EA;
  --ext:#5B4392; --ext-soft:#EFEAF8;
  --c-ok:#E3EAF2; --c-ok-line:#8FA3BA; --c-r12:#E9B96B; --c-pr:#D0731F; --c-it:#9E2A12;
  --paper:#FFFFFF; --paper-ink:#0A1A30; --paper-muted:#4A5568; --paper-line:#C9D3DF; --paper-mist:#EEF2F7; --desk:#E7EAEF;
  --scrim:rgba(10,26,48,.38);
  --shadow:0 1px 2px rgba(10,26,48,.05), 0 8px 24px rgba(10,26,48,.08);
  --g-doc:#2B4A72; --g-element:#276B44; --g-person:#8A6214; --g-company:#5B4392; --g-code:#2F6F7E; --g-fact:#4A5568; --g-note:#7D8BA0; --g-alert:#9E2A12; --g-ext:#5B4392;
  --font-ui:'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-title:'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono:'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0C121A; --surface:#121A24; --surface-2:#18222E; --line:#223042; --line-strong:#33445B;
    --ink:#E8EDF3; --muted:#A9B5C6; --faint:#8492A6;
    --link:#9FC0E6; --primary:#E8EDF3; --primary-ink:#0A1A30; --gold:#D6B574; --gold-soft:#2A2416;
    --warn:#F0C26A; --warn-soft:#31270F; --warn-line:#7C5B1D;
    --crit:#F0907F; --crit-soft:#3A1B16;
    --good:#86CDA0; --good-soft:#142C1E;
    --ext:#BDA8EA; --ext-soft:#271F3D;
    --scrim:rgba(0,0,0,.6);
    --shadow:0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.45);
    --desk:#0A0F15;
    --g-doc:#9FC0E6; --g-element:#86CDA0; --g-person:#E2B866; --g-company:#BDA8EA; --g-code:#7CC4D0; --g-fact:#A9B5C6; --g-note:#8492A6; --g-alert:#F0907F; --g-ext:#BDA8EA;
    color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --bg:#0C121A; --surface:#121A24; --surface-2:#18222E; --line:#223042; --line-strong:#33445B;
  --ink:#E8EDF3; --muted:#A9B5C6; --faint:#8492A6;
  --link:#9FC0E6; --primary:#E8EDF3; --primary-ink:#0A1A30; --gold:#D6B574; --gold-soft:#2A2416;
  --warn:#F0C26A; --warn-soft:#31270F; --warn-line:#7C5B1D;
  --crit:#F0907F; --crit-soft:#3A1B16;
  --good:#86CDA0; --good-soft:#142C1E;
  --ext:#BDA8EA; --ext-soft:#271F3D;
  --scrim:rgba(0,0,0,.6);
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.45);
  --desk:#0A0F15;
  --g-doc:#9FC0E6; --g-element:#86CDA0; --g-person:#E2B866; --g-company:#BDA8EA; --g-code:#7CC4D0; --g-fact:#A9B5C6; --g-note:#8492A6; --g-alert:#F0907F; --g-ext:#BDA8EA;
  color-scheme:dark;
}
*{box-sizing:border-box}
html,body{height:100%; margin:0; padding:0}
body{background:var(--bg); color:var(--ink); font-family:var(--font-ui); font-size:14px; line-height:1.5; -webkit-font-smoothing:antialiased}
button,input,select,textarea{font:inherit; color:inherit}
button{cursor:pointer}
h1,h2,h3{margin:0; line-height:1.2; text-wrap:balance}
p{margin:0}
.mono{font-family:var(--font-mono); font-variant-numeric:tabular-nums}
.muted{color:var(--muted)} .faint{color:var(--faint)}
.ic{width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; flex:none}
:focus-visible{outline:2px solid var(--link); outline-offset:2px; border-radius:6px}
.sr{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}

/* Shell */
.app{height:100%; display:grid; grid-template-columns:256px minmax(0,1fr); padding-right:env(safe-area-inset-right,0px)}
.mtop{display:none}
.sb{border-right:1px solid var(--line); background:var(--surface); display:flex; flex-direction:column; gap:14px; padding:16px 12px 12px max(16px, env(safe-area-inset-left,0px)); min-height:0; overflow:auto}
.brand{display:flex; align-items:center; gap:10px; padding:0 4px}
.mark{width:30px; height:30px; background:var(--primary); color:var(--primary-ink); display:grid; place-items:center; font-family:var(--font-title); font-weight:600; font-size:11px; letter-spacing:.05em; flex:none}
.brand b{font-weight:600; font-size:14px}
.rel{position:relative}
.proj-btn{width:100%; display:flex; align-items:center; gap:8px; text-align:left; border:1px solid var(--line); background:var(--surface); border-radius:10px; padding:8px 10px}
.proj-btn:hover{border-color:var(--line-strong)}
.proj-btn .t{font-weight:600; display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.proj-btn .s{font-size:12px; color:var(--faint)}
.row{display:flex; gap:8px; align-items:center}
.grow{flex:1; min-width:0}
.btn{display:inline-flex; align-items:center; justify-content:center; gap:6px; border:1px solid var(--line-strong); background:var(--surface); border-radius:9px; padding:7px 12px; font-weight:500; font-size:13px; white-space:nowrap}
.btn:hover{border-color:var(--faint)}
.btn-primary{background:var(--primary); border-color:var(--primary); color:var(--primary-ink)}
.btn-primary:hover{border-color:var(--primary); opacity:.92}
.btn-quiet{border-color:transparent; background:transparent}
.btn-quiet:hover{background:var(--surface-2); border-color:transparent}
.btn-sm{padding:4px 9px; font-size:12.5px; border-radius:8px}
.btn-danger{color:var(--crit)}
.btn[disabled]{opacity:.45; cursor:not-allowed}
.kbd{font-family:var(--font-mono); font-size:11px; border:1px solid var(--line-strong); border-bottom-width:2px; border-radius:5px; padding:0 5px; color:var(--faint)}
.nav{display:flex; flex-direction:column; gap:1px}
.nav-label{font-size:11.5px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--faint); padding:6px 8px 4px}
.nav-item{display:flex; align-items:center; gap:10px; width:100%; text-align:left; border:0; background:none; border-radius:8px; padding:7px 8px; color:var(--muted)}
.nav-item:hover{background:var(--surface-2); color:var(--ink)}
.nav-item.on{background:var(--surface-2); color:var(--ink); font-weight:600}
.nav-item .t{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.count{font-size:11.5px; color:var(--faint); font-variant-numeric:tabular-nums}
.count.warn{color:var(--warn); font-weight:700}
.chat-item .s{display:block; font-size:11.5px; color:var(--faint); font-weight:400}
.sb-foot{margin-top:auto; display:flex; flex-direction:column; gap:8px}
.status-line{display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); border:0; background:none; padding:4px 8px; text-align:left; border-radius:8px}
.status-line:hover{background:var(--surface-2)}
.dot{width:7px; height:7px; border-radius:50%; background:var(--good); flex:none}
.user-btn{display:flex; align-items:center; gap:10px; width:100%; border:1px solid var(--line); background:var(--surface); border-radius:10px; padding:7px 9px; text-align:left}
.av{width:28px; height:28px; border-radius:50%; display:grid; place-items:center; font-size:12px; font-weight:600; background:var(--surface-2); color:var(--muted); border:1px solid var(--line); flex:none}
.sample{font-size:11.5px; color:var(--warn); background:var(--warn-soft); border:1px solid var(--warn-line); border-radius:999px; padding:1px 8px; white-space:nowrap}
.pop{position:absolute; z-index:40; left:0; right:0; background:var(--surface); border:1px solid var(--line-strong); border-radius:12px; box-shadow:var(--shadow); padding:6px; display:flex; flex-direction:column; gap:2px}
.pop.up{bottom:calc(100% + 6px)} .pop.down{top:calc(100% + 6px)}
.pop-item{display:flex; align-items:center; gap:10px; width:100%; text-align:left; border:0; background:none; border-radius:8px; padding:7px 9px}
.pop-item:hover, .pop-item.on{background:var(--surface-2)}
.pop-sep{height:1px; background:var(--line); margin:4px 2px}
.pop-note{font-size:12px; color:var(--faint); padding:4px 9px 6px}

/* Main */
.main{min-width:0; min-height:0; display:grid; grid-template-columns:minmax(0,1fr) auto; height:100%}
.pane{min-width:0; min-height:0; height:100%; overflow:auto}
.pane-h{display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:14px 24px; border-bottom:1px solid var(--line); background:var(--bg); position:sticky; top:0; z-index:5}
.pane-h h2{font-size:16px; font-weight:600; margin-right:auto; font-family:var(--font-ui)}
.chipbtn{display:inline-flex; align-items:center; gap:6px; border:1px solid var(--line); background:var(--surface); border-radius:999px; padding:4px 11px; font-size:12.5px; color:var(--muted)}
.chipbtn:hover{border-color:var(--line-strong); color:var(--ink)}
.chipbtn.warn{color:var(--warn); border-color:var(--warn-line); background:var(--warn-soft)}
.mode-pick{display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:var(--faint)}
.mode-pick select{border:1px solid var(--line); background:var(--surface); border-radius:999px; padding:4px 10px; font-size:12.5px; color:var(--ink)}
.router{display:inline-flex; align-items:center; gap:8px; border:1px solid var(--line); background:var(--surface); border-radius:999px; padding:4px 10px 4px 5px; font-size:13px; font-weight:500}
.router:hover{border-color:var(--line-strong)}
.router .auto{font-size:11px; font-weight:700; letter-spacing:.04em; background:var(--good-soft); color:var(--good); border-radius:999px; padding:1px 8px}
.router .auto.pinned{background:var(--surface-2); color:var(--muted)}
.router-pop{right:auto; width:min(380px, calc(100vw - 32px)); max-height:70vh; overflow:auto}
.pill{display:inline-flex; align-items:center; gap:4px; font-size:11.5px; line-height:1.5; padding:1px 8px; border-radius:999px; background:var(--surface-2); color:var(--muted); white-space:nowrap}
.pill-warn{background:var(--warn-soft); color:var(--warn)}
.pill-crit{background:var(--crit-soft); color:var(--crit)}
.pill-good{background:var(--good-soft); color:var(--good)}
.pill-ext{background:var(--ext-soft); color:var(--ext)}
.tag-plan{font-size:10.5px; font-weight:700; letter-spacing:.04em; color:var(--ext); border:1px solid var(--ext); border-radius:4px; padding:0 4px}

/* Home */
.home{max-width:760px; margin:0 auto; padding:64px 24px 48px; display:flex; flex-direction:column; gap:28px}
.home h1{font-family:var(--font-title); font-weight:600; font-size:34px}
.home .lede{color:var(--muted); margin-top:6px}
.big-composer{border:1.25px solid var(--line-strong); background:var(--surface); border-radius:16px; padding:12px 12px 10px 16px; box-shadow:var(--shadow); display:flex; flex-direction:column; gap:8px}
.big-composer:focus-within{border-color:var(--ink)}
.big-composer textarea{border:0; outline:0; resize:none; background:transparent; min-height:56px; font-size:15px}
.starters{display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:12px}
.starter{border:1px solid var(--line); background:var(--surface); border-radius:12px; padding:14px; text-align:left; display:flex; flex-direction:column; gap:6px; min-height:92px}
.starter:hover{border-color:var(--ink)}
.starter .k{font-size:11.5px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--faint)}
.starter .q{font-weight:500}
.sec-title{font-size:12px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--faint); margin-bottom:8px}
.quiet-list{border:1px solid var(--line); border-radius:12px; background:var(--surface); overflow:hidden}
.ql-row{display:flex; align-items:center; gap:12px; width:100%; text-align:left; border:0; border-bottom:1px solid var(--line); background:none; padding:11px 14px}
.ql-row:last-child{border-bottom:0}
.ql-row:hover{background:var(--surface-2)}
.ql-row .t{font-weight:500}
.ql-row .s{font-size:12.5px; color:var(--muted)}
.two{display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:20px}

/* Chat */
.chat{display:flex; flex-direction:column; height:100%; min-height:0}
.thread{flex:1; overflow:auto; min-height:0}
.thread-in{max-width:760px; margin:0 auto; padding:24px 24px 12px; display:flex; flex-direction:column; gap:20px}
.m-user{display:flex; flex-direction:column; align-items:flex-end; gap:4px}
.bubble{background:var(--surface); border:1px solid var(--line); border-radius:14px 14px 4px 14px; padding:9px 14px; max-width:85%; overflow-wrap:anywhere}
.m-meta{font-size:12px; color:var(--faint)}
.m-ai{display:flex; flex-direction:column; gap:6px}
.m-text{font-size:15px; line-height:1.7; max-width:68ch}
.cn{display:inline-flex; align-items:center; justify-content:center; min-width:18px; height:18px; padding:0 4px; margin:0 1px; font-family:var(--font-mono); font-size:11px; font-weight:500; color:var(--link); background:var(--surface); border:1px solid var(--line-strong); border-radius:6px; vertical-align:2px; line-height:1}
.cn:hover{border-color:var(--link)}
.m-src{display:flex; flex-wrap:wrap; gap:6px; align-items:center}
.src-chip{display:inline-flex; align-items:center; gap:6px; border:1px solid var(--line); background:var(--surface); border-radius:8px; padding:3px 9px; font-size:12px; color:var(--muted)}
.src-chip:hover{border-color:var(--line-strong); color:var(--ink)}
.src-chip b{font-family:var(--font-mono); font-weight:500; color:var(--link)}
.m-note{display:flex; align-items:flex-start; gap:8px; font-size:13.5px; color:var(--muted); background:var(--surface-2); border-radius:10px; padding:8px 12px; max-width:68ch}
.m-note.warn{background:var(--warn-soft); color:var(--ink)}
.m-note.warn .ic{color:var(--warn)}
.m-note .link{margin-left:auto}
.link{border:0; background:none; color:var(--link); font-weight:600; padding:0; font-size:13px; white-space:nowrap}
.link:hover{text-decoration:underline}
.m-divider{display:flex; align-items:center; gap:10px; font-size:12px; color:var(--faint)}
.m-divider::before, .m-divider::after{content:""; flex:1; height:1px; background:var(--line)}
.m-card{border:1px solid var(--line); border-radius:12px; padding:12px 14px; background:var(--surface); display:flex; flex-direction:column; gap:8px; max-width:68ch}
.m-card.req{border-color:var(--ext)}
.m-card.ext{background:var(--ext-soft); border-color:transparent}
.m-card h4{margin:0; font-size:13.5px; display:flex; gap:8px; align-items:center; flex-wrap:wrap}
details summary{cursor:pointer; color:var(--link); font-size:12.5px; font-weight:600}
.thinking{display:flex; align-items:center; gap:8px; color:var(--faint); font-size:13px}
.thinking i{width:5px; height:5px; border-radius:50%; background:var(--faint); display:inline-block; animation:blink 1.2s infinite}
.thinking i:nth-child(2){animation-delay:.2s} .thinking i:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,80%,100%{opacity:.25} 40%{opacity:1}}
.composer{padding:10px 24px 18px}
.composer-in{max-width:760px; margin:0 auto; position:relative}
.cbox{display:flex; gap:6px; align-items:flex-end; border:1.25px solid var(--line-strong); border-radius:14px; background:var(--surface); padding:6px 6px 6px 12px}
.cbox:focus-within{border-color:var(--ink)}
.cbox textarea{flex:1; border:0; outline:0; resize:none; background:transparent; min-height:40px; max-height:160px; padding:8px 0; font-size:14.5px}
.hint-line{display:flex; gap:12px; justify-content:space-between; font-size:12px; color:var(--faint); margin-top:6px; padding:0 4px; flex-wrap:wrap}
.suggest{position:absolute; bottom:calc(100% + 6px); left:0; right:0; max-height:260px; overflow:auto; background:var(--surface); border:1px solid var(--line-strong); border-radius:12px; box-shadow:var(--shadow); padding:6px; z-index:20}
.suggest button{display:flex; width:100%; gap:10px; align-items:center; text-align:left; border:0; background:none; padding:7px 9px; border-radius:8px}
.suggest button:hover{background:var(--surface-2)}
.empty-chat{margin:auto; max-width:520px; text-align:center; display:flex; flex-direction:column; gap:12px; align-items:center; padding:48px 16px}
.empty-chat h3{font-family:var(--font-title); font-size:24px}

/* Drawer */
.drawer{width:380px; border-left:1px solid var(--line); background:var(--surface); display:flex; flex-direction:column; min-height:0; height:100%}
.drawer-h{display:flex; align-items:center; gap:2px; padding:8px 8px 0 12px; border-bottom:1px solid var(--line)}
.tab{border:0; background:none; padding:9px 10px; color:var(--muted); font-weight:500; border-bottom:2px solid transparent; display:inline-flex; gap:6px; align-items:center}
.tab.on{color:var(--ink); border-bottom-color:var(--gold)}
.drawer-b{flex:1; overflow:auto; padding:14px; display:flex; flex-direction:column; gap:10px; min-height:0}
.doc-row{display:grid; grid-template-columns:26px minmax(0,1fr) auto; gap:10px; align-items:center; width:100%; text-align:left; border:0; background:none; border-radius:10px; padding:8px}
.doc-row:hover{background:var(--surface-2)}
.doc-ic{width:22px; height:28px; border:1.25px solid var(--line-strong); border-radius:3px; position:relative; background:var(--surface)}
.doc-ic::after{content:""; position:absolute; left:4px; right:4px; top:9px; height:2px; background:var(--line-strong); box-shadow:0 5px 0 var(--line-strong), 0 10px 0 var(--line-strong)}
.doc-row .nm{display:block; font-weight:500; font-size:13px; overflow-wrap:anywhere}
.doc-row .mt{display:block; font-size:12px; color:var(--faint)}
.bar{height:3px; background:var(--surface-2); border-radius:3px; overflow:hidden; margin-top:5px}
.bar i{display:block; height:100%; background:var(--ink); transition:width .2s}
.feed{display:flex; flex-direction:column}
.feed-row{display:grid; grid-template-columns:minmax(0,1fr) auto; gap:2px 10px; padding:9px 2px; border-bottom:1px solid var(--line); font-size:13px}
.feed-row .tm{font-size:12px; color:var(--faint); white-space:nowrap}
.feed-row .dt{grid-column:1 / -1; font-size:12px; color:var(--muted)}
.mem-row{display:flex; flex-direction:column; gap:3px; width:100%; text-align:left; border:1px solid var(--line); background:var(--surface); border-radius:10px; padding:9px 11px}
.mem-row:hover{border-color:var(--line-strong)}
.mem-row .nm{font-weight:500}
.mem-row .tx{font-size:12.5px; color:var(--muted)}

/* Generic view */
.view{max-width:1100px; margin:0 auto; padding:28px 24px 48px}
.view-h{display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:18px}
.view-h h1{font-family:var(--font-title); font-weight:600; font-size:28px; margin-right:auto}
.seg{display:inline-flex; border:1px solid var(--line); background:var(--surface); border-radius:10px; padding:3px; gap:2px}
.seg button{border:0; background:none; border-radius:7px; padding:5px 12px; color:var(--muted); font-weight:500}
.seg button.on{background:var(--surface-2); color:var(--ink)}
.card{background:var(--surface); border:1px solid var(--line); border-radius:12px}
.card-h{display:flex; align-items:center; gap:8px; padding:12px 16px; border-bottom:1px solid var(--line)}
.card-h h3{font-size:14px; font-weight:600; margin-right:auto}
.card-b{padding:14px 16px}
.tbl-wrap{overflow-x:auto}
.tbl{width:100%; border-collapse:collapse; font-size:13px}
.tbl th{font-size:11.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--faint); text-align:left; font-weight:600; padding:9px 12px; border-bottom:1px solid var(--line); white-space:nowrap}
.tbl td{padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:top}
.tbl tr.click{cursor:pointer}
.tbl tr.click:hover td{background:var(--surface-2)}
.tbl tr.bad td{background:var(--crit-soft)}
.tbl .detail td{background:var(--surface-2); font-size:12.5px; color:var(--muted)}
.banner{display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:11px 14px; border-radius:12px; border:1px solid var(--line); background:var(--surface); font-size:13.5px; margin-bottom:14px}
.banner.ok{border-color:transparent; background:var(--good-soft); color:var(--good)}
.banner.bad{border-color:transparent; background:var(--crit-soft); color:var(--crit)}
.filters{display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:10px}
.filters input, .filters select{border:1px solid var(--line-strong); background:var(--surface); border-radius:9px; padding:7px 10px; font-size:13px}
.locked{display:flex; flex-direction:column; gap:10px; align-items:flex-start; max-width:520px; padding:24px; margin:56px auto; border:1px solid var(--line); border-radius:14px; background:var(--surface)}
.kv{display:grid; grid-template-columns:150px minmax(0,1fr); gap:6px 14px; font-size:13px; margin:0}
.kv dt{color:var(--muted)} .kv dd{margin:0}
.field{display:flex; flex-direction:column; gap:5px}
.field label{font-size:12.5px; font-weight:600}
.field input, .field select, .field textarea, .input{border:1px solid var(--line-strong); background:var(--surface); border-radius:9px; padding:8px 10px; width:100%}
.field textarea{resize:vertical; min-height:70px}
.hint{font-size:12.5px; color:var(--muted)}
.err{font-size:12.5px; color:var(--crit)}
.legend{display:flex; gap:6px; flex-wrap:wrap}
.legend button{display:inline-flex; align-items:center; gap:6px; border:1px solid var(--line); background:var(--surface); border-radius:999px; padding:2px 10px; font-size:12px}
.legend button.off{opacity:.45}
.legend i{width:9px; height:9px; border-radius:50%; display:inline-block}
.graph-wrap svg{width:100%; height:auto; display:block}
.gnode{cursor:pointer}
.gnode text{font-size:11px; fill:var(--ink); paint-order:stroke; stroke:var(--surface); stroke-width:3px}

/* Condition codes (shared with the documents) */
.cc{display:inline-block; font-size:11.5px; font-weight:700; letter-spacing:.04em; padding:1px 6px; line-height:1.5; color:#0A1A30}
.cc-ok{background:#E3EAF2; box-shadow:inset 0 0 0 1px #8FA3BA}
.cc-r12{background:#E9B96B}
.cc-pr{background:#D0731F}
.cc-it{background:#9E2A12; color:#FFFFFF}

/* Report paper (CMA document system) */
.rep{display:grid; grid-template-columns:minmax(0,1fr) 340px; height:100%; min-height:0}
.rep.closed{grid-template-columns:minmax(0,1fr)}
.rep-main{overflow:auto; padding:20px 24px 48px; background:var(--desk); min-width:0}
.rep-bar{display:flex; align-items:center; gap:8px; flex-wrap:wrap; max-width:860px; margin:0 auto 14px}
.rep-bar h2{font-size:16px; font-weight:600; margin-right:auto}
.paper{position:relative; background:var(--paper); color:var(--paper-ink); max-width:860px; margin:0 auto; padding:52px clamp(20px,6vw,64px) 40px; box-shadow:var(--shadow); font-family:var(--font-ui)}
.paper::before{content:""; position:absolute; top:0; left:0; right:0; height:6px; background:#C9A45C}
.paper .cn{background:var(--paper); color:#2B4A72; border-color:var(--paper-line)}
.p-head{display:flex; justify-content:space-between; gap:16px; flex-wrap:wrap; align-items:baseline; border-bottom:2px solid #0A1A30; padding-bottom:10px; margin-bottom:26px}
.p-firm{font-family:var(--font-title); font-weight:600; font-size:16px}
.p-run{font-size:12px; color:var(--paper-muted)}
.p-eyebrow{font-size:12px; font-weight:600; letter-spacing:.12em; text-transform:uppercase; color:var(--paper-muted)}
.paper h1{font-family:var(--font-title); font-weight:600; font-size:32px; line-height:1.1; margin-top:10px}
.p-gold{width:72px; height:4px; background:#C9A45C; margin:16px 0 14px}
.p-lede{color:var(--paper-muted)}
.app.bare{display:block} .app.bare .sb, .app.bare .mtop{display:none}
.facts{display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); border:1px solid var(--paper-line); margin:14px 0 4px; font-size:12.5px}
.facts div{padding:7px 10px; border-right:1px solid var(--paper-line); border-bottom:1px solid var(--paper-line); margin:0 -1px -1px 0}
.facts b{display:block; font-size:10.5px; letter-spacing:.04em; text-transform:uppercase; color:var(--paper-muted); font-weight:600}
.sheet .facts{font-size:9.5px; margin:6px 0 2px} .sheet .facts div{padding:3px 6px} .sheet .facts b{font-size:7.5px}
.tpl{display:grid; grid-template-columns:220px minmax(0,1fr); gap:16px} .tpl-list{display:flex; flex-direction:column; gap:4px} .tpl-list button{text-align:left; border:1px solid transparent; background:none; border-radius:9px; padding:8px 10px} .tpl-list button.on{background:var(--surface-2); border-color:var(--line)} .tpl-list .s{display:block; font-size:12px; color:var(--faint)}
.tpl ol{margin:6px 0 14px; padding-left:20px} .tpl li{margin:2px 0}
@media (max-width:640px){ .tpl{grid-template-columns:1fr} .facts{grid-template-columns:repeat(2, minmax(0,1fr))} }
.sec{border-top:1px solid var(--paper-line); padding-top:16px; margin-top:20px}
.sec-h{display:flex; align-items:center; gap:10px}
.sec-h h3{font-family:var(--font-title); font-weight:600; font-size:19px; margin-right:auto}
.sec-n{font-family:var(--font-mono); font-size:12px; color:var(--paper-muted)}
.sec-body{margin-top:8px; line-height:1.65; border-radius:6px; padding:2px 6px; margin-left:-6px; font-size:14.5px}
.sec-body[contenteditable="true"]:hover{background:rgba(43,74,114,.05)}
.sec-body[contenteditable="true"]:focus{outline:1.5px dashed #2B4A72; outline-offset:2px}
.rate{display:inline-flex; gap:4px; transition:opacity .15s}
@media (hover:hover){ .sec .rate{opacity:.35} .sec:hover .rate, .sec:focus-within .rate{opacity:1} }
.rate button{border:1px solid var(--paper-line); background:var(--paper); color:var(--paper-muted); border-radius:7px; padding:3px 6px; display:inline-flex}
.rate button.on-up{color:#276B44; border-color:#276B44}
.rate button.on-down{color:#9E2A12; border-color:#9E2A12}
.ptbl{width:100%; border-collapse:collapse; font-size:13px; margin-top:8px}
.ptbl th{text-align:left; font-size:11.5px; font-weight:600; letter-spacing:.04em; color:var(--paper-ink); background:var(--paper-mist); border-top:1.5px solid #0A1A30; border-bottom:1.5px solid #0A1A30; padding:7px 8px}
.ptbl td{border-bottom:1px solid var(--paper-line); padding:8px; vertical-align:top}
.ptbl tr.hot td{background:#FDF4F1}
.tblock{display:grid; grid-template-columns:1.25fr 1.2fr 1.1fr .8fr .7fr 1.25fr; border:1.5px solid #0A1A30; margin-top:28px; font-size:12px; line-height:1.35}
.tblock div{padding:6px 8px; border-right:1px solid var(--paper-line); min-width:0}
.tblock div:last-child{border-right:0}
.tblock b{display:block; font-weight:400; font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--paper-muted)}
.tblock span{font-family:var(--font-mono); overflow-wrap:anywhere}
.rail{border-left:1px solid var(--line); background:var(--surface); display:flex; flex-direction:column; min-height:0; min-width:0}
.rail-b{flex:1; overflow:auto; padding:14px; display:flex; flex-direction:column; gap:12px}

/* PDF sheets */
.sheets{display:flex; flex-direction:column; gap:16px; align-items:center}
.sheet{position:relative; width:100%; max-width:600px; aspect-ratio:8.5/11; background:var(--paper); color:var(--paper-ink); box-shadow:var(--shadow); padding:30px 32px 18px; display:flex; flex-direction:column; font-size:10.5px; line-height:1.5; overflow:hidden; font-family:var(--font-ui)}
.sheet::before{content:""; position:absolute; top:0; left:0; right:0; height:5px; background:#C9A45C}
.sh-head{display:flex; justify-content:space-between; gap:12px; border-bottom:1.5px solid #0A1A30; padding-bottom:6px; margin-bottom:12px; font-size:9.5px; color:var(--paper-muted)}
.sh-head b{font-family:var(--font-title); font-size:12px; color:var(--paper-ink)}
.sheet h4{font-family:var(--font-title); font-size:13px; margin:10px 0 4px}
.sh-body{flex:1; min-height:0; overflow:hidden}
.sheet .cn{font-size:9px; height:14px; min-width:14px; background:var(--paper); color:#2B4A72; border-color:var(--paper-line)}
.sheet .ptbl{font-size:9.5px}
.sheet .ptbl th{font-size:9px; padding:4px 5px}
.sheet .ptbl td{padding:4px 5px}
.sheet .cc{font-size:9px}
.sheet .tblock{margin:8px 0 0; font-size:9px}
.sheet .tblock b{font-size:8.5px}
.wm{position:absolute; inset:0; display:grid; place-items:center; pointer-events:none; font-family:var(--font-title); font-weight:600; font-size:100px; color:rgba(158,42,18,.09); transform:rotate(-30deg)}
.dl{font-family:var(--font-mono); font-size:8.5px; color:#9E2A12; text-align:center; padding-top:4px}

/* Modal, toast, command menu */
.backdrop{position:fixed; inset:0; background:var(--scrim); display:grid; place-items:center; padding:max(16px, env(safe-area-inset-top,0px)) max(16px, env(safe-area-inset-right,0px)) max(16px, env(safe-area-inset-bottom,0px)) max(16px, env(safe-area-inset-left,0px)); z-index:60}
.backdrop.top{place-items:start center; padding-top:12vh}
.modal{background:var(--surface); border-radius:16px; width:100%; max-width:560px; max-height:100%; overflow:auto; box-shadow:var(--shadow); display:flex; flex-direction:column}
.modal.wide{max-width:760px}
.modal-h{display:flex; align-items:flex-start; gap:10px; padding:18px 20px 12px; border-bottom:1px solid var(--line); position:sticky; top:0; background:var(--surface); z-index:1}
.modal-h h3{font-family:var(--font-title); font-weight:600; font-size:20px}
.modal-h .x{margin-left:auto}
.modal-b{padding:16px 20px; display:flex; flex-direction:column; gap:14px}
.modal-f{display:flex; justify-content:flex-end; gap:8px; padding:12px 20px 18px; border-top:1px solid var(--line); flex-wrap:wrap}
.page-view{background:var(--paper); color:var(--paper-ink); border:1px solid var(--paper-line); padding:26px; min-height:240px; line-height:1.65}
.page-view mark{background:#FFE6A3; color:var(--paper-ink); padding:0 2px}
.page-view .ph{display:flex; flex-direction:column; gap:9px}
.page-view .ph i{display:block; height:8px; background:#E6EAF0; border-radius:4px}
.reasons{display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:8px}
.reasons label{display:flex; gap:8px; align-items:flex-start; border:1px solid var(--line); border-radius:10px; padding:9px 11px; cursor:pointer}
.reasons label:has(input:checked){border-color:var(--ink); background:var(--surface-2)}
.cmdk{max-width:560px; padding:0}
.cmdk input{border:0; outline:0; width:100%; font-size:16px; padding:16px 18px; border-bottom:1px solid var(--line); background:transparent}
.cmdk-list{max-height:360px; overflow:auto; padding:6px}
.cmdk-item{display:flex; align-items:center; gap:10px; width:100%; text-align:left; border:0; background:none; border-radius:8px; padding:9px 11px}
.cmdk-item.on, .cmdk-item:hover{background:var(--surface-2)}
.cmdk-item .g{margin-left:auto; font-size:11.5px; color:var(--faint)}
.toasts{position:fixed; left:50%; transform:translateX(-50%); bottom:max(16px, env(safe-area-inset-bottom,0px)); display:flex; flex-direction:column; gap:8px; z-index:70; width:min(520px, calc(100% - 32px))}
.toast{background:var(--ink); color:var(--bg); border-radius:10px; padding:10px 14px; font-size:13px; box-shadow:var(--shadow)}

/* Sign-in */
.signin{min-height:100%; display:grid; place-items:center; padding:32px 16px}
.signin-card{width:100%; max-width:420px; background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:28px; display:flex; flex-direction:column; gap:14px; box-shadow:var(--shadow); position:relative; overflow:hidden}
.signin-card::before{content:""; position:absolute; top:0; left:0; right:0; height:5px; background:var(--gold)}
.signin-card h2{font-family:var(--font-title); font-weight:600; font-size:24px}
.steps{display:flex; gap:6px}
.steps i{height:3px; flex:1; border-radius:3px; background:var(--line)}
.steps i.on{background:var(--ink)}
.code-in{font-family:var(--font-mono); font-size:22px; letter-spacing:.4em; text-align:center}

@media (max-width: 1180px){
  .rep{grid-template-columns:minmax(0,1fr)}
  .rail{border-left:0; border-top:1px solid var(--line)}
  .drawer{position:fixed; right:0; top:0; bottom:0; z-index:45; box-shadow:var(--shadow); width:min(400px, 100%)}
}
@media (max-width: 900px){
  html,body{height:auto}
  .app{grid-template-columns:minmax(0,1fr); height:auto; min-height:100%}
  .mtop{display:flex; align-items:center; gap:10px; padding:10px max(16px, env(safe-area-inset-right,0px)) 10px max(16px, env(safe-area-inset-left,0px)); border-bottom:1px solid var(--line); background:var(--surface); position:sticky; top:env(safe-area-inset-top,0px); z-index:30}
  .sb{position:fixed; left:0; top:0; bottom:0; width:min(300px, 86%); z-index:50; transform:translateX(-105%); transition:transform .2s; box-shadow:var(--shadow)}
  .sb.open{transform:none}
  .main{height:auto; grid-template-columns:minmax(0,1fr)}
  .pane{height:auto; overflow:visible}
  .chat{height:auto; min-height:calc(100vh - 60px)}
  .thread{overflow:visible}
  .pane-h{position:static}
  .home{padding:32px 16px}
  .starters{grid-template-columns:minmax(0,1fr)}
  .two{grid-template-columns:minmax(0,1fr)}
  .view{padding:20px 16px 40px}
  .thread-in{padding:18px 16px 8px} .composer{padding:8px 16px 16px; position:sticky; bottom:0; background:var(--bg)}
  .pane-h{padding:12px 16px}
  .rep{height:auto} .rep-main{padding:12px 0 24px}
  .kv{grid-template-columns:minmax(0,1fr)}
  .reasons{grid-template-columns:minmax(0,1fr)}
  .tblock{grid-template-columns:repeat(3, minmax(0,1fr))}
  .tblock div:nth-child(3){border-right:0}
  .tblock div:nth-child(-n+3){border-bottom:1px solid var(--paper-line)}
  .sheet{aspect-ratio:auto; min-height:420px} .sh-body{overflow:visible}
}
@media (prefers-reduced-motion: reduce){ *{animation:none!important; transition:none!important} }

/* ---- additions for the working app ---- */
.wm-wrap{position:relative; overflow:hidden}
.wm-tile{position:absolute; inset:-40px; display:flex; flex-wrap:wrap; gap:34px 46px; align-content:flex-start; transform:rotate(-24deg); pointer-events:none; user-select:none; opacity:.085; font-size:12px; font-weight:600; color:var(--crit); z-index:2}
.page-text{white-space:pre-wrap; overflow-wrap:anywhere; font-size:13.5px; line-height:1.6; position:relative; z-index:1}
.m-text{white-space:pre-wrap}
.drop{outline:2px dashed var(--line-strong); outline-offset:-8px}
.banner{display:flex; gap:10px; align-items:flex-start; padding:10px 14px; border:1px solid var(--warn-line); background:var(--warn-soft); color:var(--warn); border-radius:10px; font-size:13px; margin-bottom:14px}
.busy{opacity:.55; pointer-events:none}
@media print{ body{display:none !important} }

/* Editable cells in report drafts: the first-page summary and the findings table */
.cell-in{display:block; width:100%; border:1px solid transparent; border-radius:4px; background:transparent; font:inherit; color:inherit; padding:2px 4px; resize:vertical}
.cell-in:hover{border-color:var(--paper-line)} .cell-in:focus{outline:none; border-color:var(--ink); background:var(--surface)}
.facts .cell-in{margin:2px -5px 0; width:calc(100% + 10px); font-size:13px}
.fnd-edit td{padding:4px} .fnd-edit select.cell-in{padding:2px}

/* Voice: the mic button turns solid while it is listening */
.btn.mic.on{background:var(--crit); border-color:var(--crit); color:#fff}
.btn.mic:disabled{opacity:.5; cursor:progress}
.btn.mic{touch-action:none; user-select:none; -webkit-user-select:none}

/* Answers and report text: paragraphs and lists (Nov 12 evening). A wrapped line stays under its own text, like the prototype's prose. */
.m-text{white-space:normal}
.m-text p, .m-note p, .sh-text p{margin:0 0 .65em} .m-text p:last-child, .m-note p:last-child, .sh-text p:last-child{margin-bottom:0}
.m-text ul, .m-text ol, .m-note ul, .sh-text ul, .sh-text ol{margin:.15em 0 .65em; padding-left:1.35em}
.m-text ul, .m-note ul, .sh-text ul{list-style:disc} .m-text ol, .sh-text ol{list-style:decimal}
.m-text li, .m-note li, .sh-text li{margin:.2em 0; padding-left:.15em}
.m-text ul:last-child, .m-text ol:last-child{margin-bottom:0}
/* The line under the message box stays on one line; the agent and model keep priority. */
.hint-line{flex-wrap:nowrap}
.hint-line > span{min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.hint-line > span:first-child{flex:1 1 auto} .hint-line > span:last-child{flex:0 1 auto; max-width:62%}

/* Wide screens: a wider conversation column, so the chat doesn't sit in a narrow strip with empty space on both sides (owner, Nov 12). */
@media (min-width:1360px){ .thread-in, .composer-in{max-width:900px} .m-text{max-width:78ch} }
@media (min-width:1700px){ .thread-in, .composer-in{max-width:980px} }
/* A new, empty chat: the greeting, the starters and the message box sit together in the middle of the screen. */
.pane.chat.is-empty .thread{flex:0 0 auto; margin-top:auto}
.pane.chat.is-empty .composer{margin-bottom:auto; padding-bottom:12vh}
.pane.chat.is-empty .empty-chat{padding:8px 0 4px; max-width:none; width:100%}
.empty-chat .starters{width:100%; margin-top:8px; text-align:left}

/* Live conversation: a slim bar above the message box while it runs. */
.live-strip{display:flex; align-items:center; gap:10px; border:1px solid var(--line-strong); background:var(--surface); border-radius:12px; padding:7px 8px 7px 12px; margin-bottom:8px; font-size:13px}
.live-strip b{font-weight:600} .live-strip [data-live-status]{color:var(--muted); white-space:nowrap}
.live-strip [data-live-line]{min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted)}
.btn.live-btn.on{background:var(--ink); border-color:var(--ink); color:var(--bg)}

/* Message box: a single line of text and every button share one center line (owner, Nov 12: the text sat higher than the icons).
   The box still grows upward for longer messages, with the buttons staying on the bottom line. */
.cbox{align-items:flex-end; padding:5px 6px 5px 10px}
.cbox textarea{min-height:36px; padding:7px 0; line-height:22px}
.cbox > .btn, .cbox > label.btn{height:36px; min-width:36px; padding:0 9px}
.cbox > .btn-primary{height:32px; margin-bottom:2px}

/* Draft sections are edited in place, with numbered source chips (owner, Nov 12: no more raw {D3:2} codes while editing). */
.sec-rich{position:relative; z-index:3; outline:none; min-height:2.4em; cursor:text; transition:background .15s}
.sec-rich:hover{background:var(--paper-mist)} .sec-rich:focus{background:var(--paper-mist); box-shadow:inset 0 0 0 1.5px var(--paper-line)}
.sec-rich:empty::before{content:attr(data-placeholder); color:var(--paper-muted)}
.sec-rich .cn{cursor:pointer; user-select:none}
.sec-src{position:relative; z-index:3; margin-top:4px; font-size:12.5px}

/* Report top bar stays on one row: the title shortens with "…" instead of pushing the buttons onto a second row. */
.rep-bar{flex-wrap:nowrap} .rep-bar > *{flex-shrink:0}
.rep-bar h2{flex:1 1 auto; flex-shrink:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
@media (max-width:760px){ .rep-bar{flex-wrap:wrap} }

/* Drafting a report (Nov 13): the report opens at once with a timer; sections show placeholder lines until the AI draft arrives. */
.drafting{display:flex; align-items:center; gap:12px; padding:11px 14px; margin:0 auto 14px; max-width:820px; border:1px solid var(--line); background:var(--surface); border-radius:10px; font-size:13px}
.drafting b{display:block; font-weight:600; color:var(--ink)}
.drafting span:not(.mono):not(.dots){color:var(--muted)}
.drafting .mono{font-size:13px; color:var(--muted); font-variant-numeric:tabular-nums}
.drafting .dots{display:inline-flex; gap:4px}
.drafting .dots i{width:6px; height:6px; border-radius:50%; background:var(--link); animation:blink 1.2s infinite}
.drafting .dots i:nth-child(2){animation-delay:.2s}
.drafting .dots i:nth-child(3){animation-delay:.4s}
.sec-wait{display:grid; gap:8px; padding:6px 0 4px}
.sec-wait i{display:block; height:10px; border-radius:5px; background:var(--paper-line); animation:blink 1.6s infinite}
.sec-wait i:nth-child(2){width:92%; animation-delay:.15s}
.sec-wait i:nth-child(3){width:64%; animation-delay:.3s}
@media (prefers-reduced-motion: reduce){.drafting .dots i, .sec-wait i{animation:none; opacity:.6}}
/* Sources in the editable findings table: numbered chips, × removes, + adds. */
.fsrc{display:flex; flex-wrap:wrap; gap:4px; align-items:center; min-width:64px}
.fsrc-c{display:inline-flex; align-items:center}
.fsrc-x{border:0; background:none; color:var(--paper-muted); font-size:13px; line-height:1; padding:0 3px; cursor:pointer}
.fsrc-x:hover{color:var(--bad, #b42318)}
.fsrc-add{color:var(--muted); border-style:dashed}
