:root{--bg:#f7f7f8;--panel:#fff;--line:#e5e5e8;--fg:#1f2023;--mut:#6b6d76;
      --accent:#10a37f;--user:#2f6feb;--danger:#c0392b;--code:#f2f2f4;
      --ok:#1e8e5a;--warn:#b5761a}
@media(prefers-color-scheme:dark){:root{--bg:#1b1c1f;--panel:#25262b;--line:#35363d;
      --fg:#ececf1;--mut:#9a9ca5;--code:#2d2e34;--ok:#43b581;--warn:#d99b3a}}
*{box-sizing:border-box}
body{margin:0;font:14px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
     background:var(--bg);color:var(--fg)}
#app{display:flex;height:100vh}
#sidebar{width:270px;flex:none;background:var(--panel);border-right:1px solid var(--line);
         padding:12px;display:flex;flex-direction:column;gap:10px}
.side-top{flex:none}
.side-bottom{flex:none;border-top:1px solid var(--line);padding-top:10px}
.convs{flex:1;overflow-y:auto;margin:0 -4px}
.conv{display:flex;align-items:center;gap:6px;padding:8px 10px;border-radius:8px;cursor:pointer}
.conv:hover{background:var(--code)}
.conv.active{background:var(--code);font-weight:600}
.conv .t{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}
.conv .x{opacity:0;color:var(--danger);padding:0 4px}
.conv:hover .x{opacity:1}
button.wide{width:100%;margin-top:0}
.brand{font-weight:700;font-size:18px;margin-bottom:10px}
.brand span{color:var(--accent);margin-left:5px}
.panel{border-top:1px solid var(--line);padding-top:12px;margin-top:12px}
.panel h3{margin:0 0 8px;font-size:12px;text-transform:uppercase;letter-spacing:.06em;color:var(--mut)}
select,input[type=text],input:not([type]),textarea{width:100%;padding:7px 9px;border:1px solid var(--line);
       border-radius:7px;background:var(--panel);color:var(--fg);font:inherit}
.row{margin-top:6px}
button{margin-top:6px;padding:7px 11px;border:1px solid var(--line);border-radius:7px;
       background:var(--panel);color:var(--fg);cursor:pointer;font:inherit}
button:hover{border-color:var(--mut)}
button.primary{background:var(--accent);border-color:var(--accent);color:#fff}
button.danger{color:var(--danger)}
button:disabled{opacity:.5;cursor:not-allowed}
.hint{color:var(--mut);font-size:12px;margin:6px 0 0}
/* Where the page says whose it is. Quiet enough to ignore while chatting, and there
   without opening anything for the visitor who has just watched a model answer in
   their own tab and wants to know what they are looking at. */
.srclink{display:flex;align-items:center;justify-content:center;gap:6px;margin-top:8px;
         color:var(--mut);font-size:12px;text-decoration:none}
.srclink svg{width:14px;height:14px;fill:currentColor;flex:none}
.srclink:hover{color:var(--fg);text-decoration:underline}
.status{margin-top:8px;font-size:12px;color:var(--mut);white-space:pre-wrap}
.bar{height:5px;background:var(--line);border-radius:3px;margin-top:7px;overflow:hidden}
/* A stage with no fraction to report. A full bar that has stopped moving reads as a load
   that finished and then hung, so it sweeps instead: working, length unknown. */
#bar.busy{background-image:linear-gradient(90deg,transparent 0%,rgba(255,255,255,.55) 50%,
  transparent 100%);background-size:40% 100%;background-repeat:no-repeat;
  animation:barsweep 1.1s linear infinite}
@keyframes barsweep{from{background-position:-40% 0}to{background-position:140% 0}}
.fill{height:100%;width:0;background:var(--accent);transition:width .2s}
.cache{margin-top:8px;font-size:12px}
.cache .item{display:flex;justify-content:space-between;gap:8px;padding:5px 0;
             border-bottom:1px solid var(--line)}
.cache .item button{margin:0;padding:2px 7px;font-size:11px}
.cache .k{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#main{flex:1;display:flex;flex-direction:column;min-width:0}
#messages{flex:1;overflow-y:auto;padding:22px 16px}
.msg{max-width:760px;margin:0 auto 18px;display:flex;gap:11px}
.msg .who{width:30px;height:30px;border-radius:50%;flex:none;display:grid;place-items:center;
          color:#fff;font-size:12px;font-weight:700}
.msg.user .who{background:var(--user)} .msg.bot .who{background:var(--accent)}
.msg .body{white-space:pre-wrap;word-wrap:break-word;padding-top:4px;min-width:0}
.msg .body img{max-width:270px;border-radius:8px;display:block;margin:6px 0}
#attachments{max-width:760px;margin:0 auto;width:100%;padding:0 16px;display:flex;
             gap:8px;flex-wrap:wrap}
.chip{background:var(--code);border:1px solid var(--line);border-radius:14px;padding:3px 10px;font-size:12px}
.chip b{cursor:pointer;margin-left:6px;color:var(--danger)}
#composer{max-width:760px;margin:0 auto;width:100%;padding:12px 16px 6px;display:flex;
          gap:8px;align-items:flex-end}
#composer .tools{display:flex;gap:4px}
#composer .tools button{margin:0;padding:6px 8px;font-size:12px}
#input{resize:none;max-height:180px}
#hintbar{max-width:760px;margin:0 auto 10px;width:100%;padding:0 16px}
#camDlg{border:1px solid var(--line);border-radius:12px;background:var(--panel);color:var(--fg)}
#cam{width:420px;max-width:80vw;border-radius:8px;display:block}

/* settings dialog */
#settingsDlg{border:1px solid var(--line);border-radius:14px;background:var(--panel);
             color:var(--fg);width:470px;max-width:92vw;padding:18px}
#settingsDlg::backdrop{background:rgba(0,0,0,.45)}
.dlg-head{display:flex;align-items:center;justify-content:space-between}
.dlg-head h2{margin:0;font-size:17px}
.dlg-head button{margin:0;border:none;background:none;font-size:16px}
#composer .tools button{font-size:15px;padding:6px 8px}

/* tabs: one settings page per concern instead of one long scroll */
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);margin:10px 0 14px}
.tabs button{margin:0;padding:7px 13px;border:none;border-bottom:2px solid transparent;
             border-radius:0;background:none;color:var(--mut);font-weight:600}
.tabs button:hover{color:var(--fg)}
.tabs button.on{color:var(--fg);border-bottom-color:var(--accent)}
.tab-panel h3{margin:16px 0 8px;font-size:12px;text-transform:uppercase;
              letter-spacing:.06em;color:var(--mut)}
.tab-panel h3:first-child{margin-top:0}

/* labelled inputs: label above, full width, no side-by-side crowding */
.field{display:block;margin-top:10px}
.field>span{display:block;font-size:12px;color:var(--mut);margin-bottom:4px}
.field input{width:100%}
.field .inline{display:flex;gap:6px}
.field .inline input{flex:1}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:4px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:10px 12px;margin-top:4px}
@media (max-width:560px){.grid3{grid-template-columns:repeat(2,1fr)}
                         .grid2{grid-template-columns:1fr}}

/* One card per decision, so a panel reads as a few choices instead of a wall. Explanations
   sit at the end of a card in a quieter voice -- present for whoever wants them, skippable
   by everyone else. */
.grp{border:1px solid var(--line);border-radius:10px;padding:12px 14px;margin:0 0 12px}
.grp:last-child{margin-bottom:0}
.grp>h3,.grp>summary{margin:0 0 8px;font-size:12px;text-transform:uppercase;
                     letter-spacing:.06em;color:var(--mut);font-weight:700}
.grp>summary{cursor:pointer;user-select:none;list-style:none;display:flex;
             align-items:center;gap:8px;margin-bottom:0}
.grp[open]>summary{margin-bottom:10px}
.grp>summary::-webkit-details-marker{display:none}
.grp>summary::before{content:"▸";font-size:10px;color:var(--mut);transition:transform .15s}
.grp[open]>summary::before{transform:rotate(90deg)}
.grp>summary:hover{color:var(--fg)}
/* the small print that qualifies a heading or a field, inline and unshouted */
.grp em,.field em{font-style:normal;text-transform:none;letter-spacing:0;
                  font-weight:400;opacity:.7}
.note{color:var(--mut);font-size:12px;line-height:1.5;margin:8px 0 0}
.grp .field:first-of-type,.grp .grid2,.grp .grid3{margin-top:0}
.grp>input{width:100%}
.btns{display:flex;gap:8px;flex-wrap:wrap}
.btns button{margin-top:10px}
button.ghost{border:none;background:none;color:var(--accent);padding:7px 6px}
.check{display:flex;gap:8px;align-items:flex-start;margin-top:14px;cursor:pointer}
.check input{margin-top:3px;accent-color:var(--accent)}

/* thinking block: folded by default, expandable — the reasoning is there, not lost */
details.think{margin:2px 0 8px;color:var(--mut);font-size:13px}
details.think summary{cursor:pointer;font-style:normal;color:var(--mut);user-select:none;
                      list-style:none;display:flex;align-items:center;gap:6px}
details.think summary::-webkit-details-marker{display:none}
details.think summary::before{content:"▸";font-size:10px;transition:transform .15s}
details.think[open] summary::before{transform:rotate(90deg)}
/* The reasoning is rendered like the answer -- it is prose, with lists and code and
   formulae in it -- so this styles whatever the renderer produced, not a <pre>. */
details.think > .ans{font:inherit;font-style:italic;
                     border-left:2px solid var(--line);padding-left:9px;margin:6px 0 0}
details.think > .ans pre, details.think > .ans code{font-style:normal}
details.think.live summary{color:var(--accent)}

/* tool log: the same folded panel as thinking, for what the model ran. The answer text
   itself never carries the trace — a model that sees traces in its own history starts
   imitating them as content, forged results and all. */
details.toollog{margin:2px 0 8px;color:var(--mut);font-size:13px}
details.toollog summary{cursor:pointer;font-style:normal;color:var(--mut);user-select:none;
                        list-style:none;display:flex;align-items:center;gap:6px}
details.toollog summary::-webkit-details-marker{display:none}
details.toollog summary::before{content:"▸";font-size:10px;transition:transform .15s}
details.toollog[open] summary::before{transform:rotate(90deg)}
/* The trace is markdown -- a fenced block per call and per result -- so this styles what
   the renderer produced, the same way the thinking pane does. */
details.toollog > .ans{font-size:12px;
                       border-left:2px solid var(--line);padding-left:9px;margin:6px 0 0}

/* waiting for the first token: a pulsing · → ·· → ··· so a long prefill reads as working,
   not frozen; and the live/final decode speed under the reply text */
.msg .body .dots{color:var(--mut);letter-spacing:2px;animation:blink 1.2s ease-in-out infinite}
@keyframes blink{0%,100%{opacity:.35}50%{opacity:1}}
.tokrate{margin-top:6px;font-size:11px;color:var(--mut)}

#composer.locked{opacity:.55}
#composer.locked #input{cursor:not-allowed}

/* A cache entry that is not fully downloaded: usable for resuming, not for export. */
.item .k.partial { color: var(--warn, #b26b00); }

/* ---- rendered replies -------------------------------------------------------------
   `.body` keeps pre-wrap for plain text — a reply that could not be rendered, and every
   message the person typed. Once a reply IS rendered it is real block elements, which do
   their own wrapping, so `.md` turns pre-wrap back off. */
.md{white-space:normal}
.md > :first-child{margin-top:0}
.md > :last-child{margin-bottom:0}
.md p{margin:0 0 10px}
.md h1,.md h2,.md h3,.md h4,.md h5,.md h6{margin:18px 0 8px;line-height:1.3;font-weight:650}
.md h1{font-size:1.4em} .md h2{font-size:1.25em} .md h3{font-size:1.12em}
.md h4,.md h5,.md h6{font-size:1em}
.md ul,.md ol{margin:0 0 10px;padding-left:22px}
.md li{margin:3px 0}
.md li > p{margin:0 0 4px}
.md blockquote{margin:0 0 10px;padding:2px 0 2px 12px;border-left:3px solid var(--line);
               color:var(--mut)}
.md hr{border:0;border-top:1px solid var(--line);margin:16px 0}
.md a{color:var(--user);text-decoration:none}
.md a:hover{text-decoration:underline}
.md img{max-width:100%;border-radius:8px}
/* Inline code, then the block form undoes it — one selector would otherwise style both. */
.md code{background:var(--code);border-radius:4px;padding:1px 5px;
         font:0.9em/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.md pre{margin:0 0 12px;padding:12px 14px;border-radius:10px;background:var(--code);
        border:1px solid var(--line);overflow-x:auto}
.md pre code{background:none;border-radius:0;padding:0;font-size:0.88em;white-space:pre}
.md table{border-collapse:collapse;margin:0 0 12px;display:block;overflow-x:auto;
          max-width:100%}
.md th,.md td{border:1px solid var(--line);padding:6px 10px;text-align:left}
.md th{background:var(--code);font-weight:650}
/* A long formula scrolls inside its own line rather than widening the whole conversation. */
.md .katex-display{overflow-x:auto;overflow-y:hidden;padding:2px 0;margin:6px 0 12px}

/* ---- delete control on a message --------------------------------------------------- */
.msg{position:relative}
.msg .del{position:absolute;top:0;right:-4px;border:0;background:none;color:var(--mut);
          font-size:13px;line-height:1;padding:4px 6px;border-radius:6px;cursor:pointer;
          opacity:0;transition:opacity .12s}
.msg:hover .del,.msg .del:focus-visible{opacity:.65}
.msg .del:hover{opacity:1;color:var(--danger);background:var(--code)}

/* ---- narrow screens ----------------------------------------------------------------
   The sidebar is a column on a desktop and a drawer on a phone. Below 760px it slides off
   to the left until `#app.nav-open`, the scrim covers the conversation while it is open,
   and the composer keeps clear of the home indicator on a phone. */
#navBtn,#navScrim{display:none}
@media (max-width: 760px){
  #sidebar{position:fixed;z-index:30;top:0;left:0;bottom:0;width:82vw;max-width:300px;
           transform:translateX(-102%);transition:transform .18s ease-out;
           box-shadow:0 0 24px rgba(0,0,0,.18)}
  #app.nav-open #sidebar{transform:none}
  #navScrim{display:block;position:fixed;inset:0;z-index:20;background:rgba(0,0,0,.35);
            opacity:0;pointer-events:none;transition:opacity .18s}
  #app.nav-open #navScrim{opacity:1;pointer-events:auto}
  #navBtn{display:block;position:fixed;z-index:40;top:8px;left:8px;width:38px;height:38px;
          border:1px solid var(--line);border-radius:10px;background:var(--panel);
          color:var(--fg);font-size:17px;line-height:1;cursor:pointer}
  /* An opaque strip for the button to sit in, not a pill floating over the conversation.
     Padding alone only holds the two apart at the top of the scroll: the button is fixed, so
     the moment the list moves, whatever is passing behind it -- an avatar, the start of a
     line -- collides with it. Under a solid strip the content simply scrolls out of view,
     which is what a reader expects. */
  #app::before{content:'';position:fixed;z-index:35;top:0;left:0;right:0;height:54px;
               background:var(--bg);pointer-events:none}
  #messages{padding-top:60px}                    /* the strip, plus a gap under it */
  .msg{gap:8px}
  .msg .who{width:26px;height:26px;font-size:11px}
  .msg .del{opacity:.5}                          /* no hover on touch: always reachable */
  #composer{padding-bottom:max(10px, env(safe-area-inset-bottom))}
  .md pre{padding:10px}
}
@media (max-width: 420px){
  .msg .who{display:none}                        /* the bubbles are distinct enough */
  #messages{padding-left:10px;padding-right:10px}
}

/* The send button while a reply is being written: same place, different job. */
#send.stopping{background:var(--danger);border-color:var(--danger)}

/* ---- message tools (edit / delete) --------------------------------------------------- */
.msg .mtools{position:absolute;top:0;right:-6px;display:flex;gap:2px;opacity:0;
             transition:opacity .12s}
.msg:hover .mtools,.msg .mtools:focus-within{opacity:.7}
.msg .mtools:hover{opacity:1}
.msg .mtools button{border:0;background:none;color:var(--mut);font-size:13px;line-height:1;
                    padding:4px 6px;border-radius:6px;cursor:pointer}
.msg .mtools button:hover{background:var(--code)}
.msg .mtools .del:hover{color:var(--danger)}
/* Nothing in a conversation offers to be changed while the page cannot act on the
   change -- the runtime is still starting, no model is loaded, or a reply is being
   written. The composer already goes flat in exactly these states; the messages used
   to stay editable, which let a question be rewritten with no way to answer it. */
#messages.locked .mtools{display:none}

/* ---- editing a message --------------------------------------------------------------- */
.editbox{width:100%;min-height:64px;padding:10px 12px;border:1px solid var(--line);
         border-radius:10px;background:var(--panel);color:var(--fg);font:inherit;resize:vertical}
.editbar{display:flex;gap:8px;margin-top:8px}

/* ---- a runnable code block ------------------------------------------------------------
   The button sits over the block's top-right corner rather than in the flow, so the code
   keeps its full width and the control is where the eye already is. */
.codewrap{position:relative}
.codewrap .runbtn{position:absolute;top:8px;right:8px;border:1px solid var(--line);
                  background:var(--panel);color:var(--fg);border-radius:8px;
                  padding:3px 9px;font-size:12px;line-height:1.4;cursor:pointer;
                  opacity:.55;transition:opacity .12s}
.codewrap:hover .runbtn{opacity:1}
.codewrap .runbtn:disabled{opacity:.3;cursor:default}
/* Without hover the overlay is wrong twice over: it cannot be revealed, and it sits on top
   of the code -- a long first line runs underneath it, and scrolling the block horizontally
   just feeds more text under it, so reserving padding would not help. On such a device the
   button leaves the overlay and takes a line of its own under the code. Keyed on the
   capability rather than on a width: a narrow window with a mouse still reveals on hover. */
@media (hover: none) {
  .codewrap .runbtn{position:static;display:block;margin:6px 0 0 auto;opacity:1}
  .runout > .x{opacity:1}
}
.md pre code[contenteditable]{outline:none;cursor:text}
.codewrap.editing pre{box-shadow:0 0 0 2px var(--accent) inset}

/* ---- what the code printed ------------------------------------------------------------ */
.runout{margin:-6px 0 12px;padding:10px 14px;border:1px solid var(--line);border-top:0;
        border-radius:0 0 10px 10px;background:var(--panel);font-size:0.9em;color:var(--mut)}
.runout pre{margin:0;padding:0;border:0;background:none;white-space:pre-wrap;
            font:0.95em/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:var(--fg)}
.runout pre.val{color:var(--accent)}
.runout img{display:block;max-width:100%;margin:8px 0 0;border-radius:6px}
.runout.bad{border-color:var(--danger)}
.runout.bad pre{color:var(--danger)}
/* the output belongs to whoever ran the code, so it can be taken back; the panel is the
   positioning context so the control sits in its corner rather than the page's */
.runout{position:relative}
.runout > .x{position:absolute;top:4px;right:6px;border:0;background:none;color:var(--mut);
  font-size:13px;line-height:1;padding:3px 5px;border-radius:5px;cursor:pointer;opacity:0}
.runout:hover > .x,.runout > .x:focus-visible{opacity:1}
.runout > .x:hover{background:var(--code);color:var(--fg)}

/* ---- block-level editing --------------------------------------------------------------
   Each block of a finished message is its own container, so an edit touches one paragraph
   or one code block and leaves the rest — including any output already on screen — alone. */
.md.blocks > .blk{border-radius:8px;margin:0 -6px;padding:0 6px}
.md.blocks > .blk:hover{background:var(--code)}
/* while the reply is still arriving its blocks are not editable, so they must not
   light up as if they were */
.md.blocks.live > .blk:hover{background:none}
.md.blocks > .blk:hover > :first-child{margin-top:0}
.blockedit{width:100%;padding:9px 11px;border:1px solid var(--accent);border-radius:8px;
           background:var(--panel);color:var(--fg);resize:vertical;
           font:0.95em/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.md.blocks > .blk:has(.blockedit){background:none}

/* ---- a table edited as a table --------------------------------------------------------
   Cells take the text directly; the ⌗ control opens the source, which is where structure
   (a column, a row, the alignment) is changed. */
.tblblk{position:relative}
.tblblk .srcbtn{position:absolute;top:2px;right:2px;border:1px solid var(--line);
                background:var(--panel);color:var(--mut);border-radius:6px;
                padding:1px 7px;font-size:12px;line-height:1.5;cursor:pointer;opacity:0}
.tblblk:hover .srcbtn{opacity:.75}
.tblblk .srcbtn:hover{opacity:1;color:var(--fg)}
.md th[contenteditable],.md td[contenteditable]{outline:none}
.md th[contenteditable]:focus,.md td[contenteditable]:focus{
  box-shadow:0 0 0 2px var(--accent) inset;border-radius:3px}

/* ---- an image at full size ------------------------------------------------------------
   A plot rendered into the conversation column is too small to read the axes of. */
img.zoomable{cursor:zoom-in}
.lightbox{position:fixed;inset:0;z-index:80;background:rgba(0,0,0,.72);
          display:flex;flex-direction:column;align-items:center;justify-content:center;
          gap:12px;padding:24px}
.lbimg{max-width:96vw;max-height:82vh;background:#fff;border-radius:8px;
       box-shadow:0 8px 40px rgba(0,0,0,.4)}
.lbbar{display:flex;gap:8px}
.lbbtn{display:inline-block;border:1px solid rgba(255,255,255,.35);background:rgba(0,0,0,.35);
       color:#fff;border-radius:8px;padding:6px 14px;font:inherit;font-size:13px;
       text-decoration:none;cursor:pointer}
.lbbtn:hover{background:rgba(255,255,255,.16)}

/* ---- a cell edited according to what it holds ----------------------------------------
   Words are typed over where they are. A formula or an image is not its own source, so
   those open a small editor for that one cell, showing the result as it is typed. */
.md td.cell-math,.md td.cell-image,.md td.cell-code,.md td.cell-link,
.md th.cell-math,.md th.cell-image,.md th.cell-code,.md th.cell-link{cursor:pointer}
.md td.cell-math:hover,.md td.cell-image:hover,.md td.cell-code:hover,.md td.cell-link:hover,
.md th.cell-math:hover,.md th.cell-image:hover,.md th.cell-code:hover,.md th.cell-link:hover{
  box-shadow:0 0 0 2px var(--line) inset;border-radius:3px}
.cellpop{display:flex;flex-direction:column;gap:6px;min-width:220px}
.cellhint{font-size:11px;color:var(--mut)}
.celledit{width:100%;padding:6px 8px;border:1px solid var(--accent);border-radius:6px;
          background:var(--panel);color:var(--fg);
          font:0.95em/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.cellprev{min-height:1.6em;padding:4px 2px;border-top:1px dashed var(--line)}
.cellpop .editbar{margin-top:2px}
.cellpop .editbar button{padding:3px 10px;font-size:12px}

/* No GPU: said once, in the way, because the alternative is finding out after a long wait. */
dialog.cpuwarn{max-width:480px;padding:22px 24px;border:1px solid var(--line);border-radius:14px;
               background:var(--panel);color:var(--fg);font:inherit}
dialog.cpuwarn::backdrop{background:rgba(0,0,0,.4)}
dialog.cpuwarn h2{margin:0 0 10px;font-size:17px}
dialog.cpuwarn p{margin:0 0 10px;line-height:1.55}
dialog.cpuwarn p.why{color:var(--mut);font-size:13px}
dialog.cpuwarn details{margin:0 0 12px}
dialog.cpuwarn summary{cursor:pointer;color:var(--mut);font-size:13px}
dialog.cpuwarn pre{margin:8px 0 0;padding:10px;background:var(--code);border-radius:8px;
                   font:11.5px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;
                   white-space:pre-wrap;word-break:break-all;max-height:220px;overflow:auto}

/* A reply that was far slower than this machine should manage: said in the conversation,
   where the wait happened, rather than in a dialog that interrupts the next thing. */
.slownote{position:relative;max-width:760px;margin:0 auto 18px;padding:12px 34px 12px 14px;
          border:1px solid var(--line);border-left:3px solid var(--danger);border-radius:10px;
          background:var(--panel);font-size:13px;line-height:1.55}
.slownote details{margin-top:8px}
.slownote summary{cursor:pointer;color:var(--mut)}
.slownote pre{margin:8px 0 0;padding:9px;background:var(--code);border-radius:7px;
              font:11.5px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;
              white-space:pre-wrap;word-break:break-all;max-height:200px;overflow:auto}
.slownote .x{position:absolute;top:6px;right:8px;border:0;background:none;color:var(--mut);
             cursor:pointer;font-size:13px;padding:3px 5px;border-radius:6px}
.slownote .x:hover{background:var(--code);color:var(--fg)}

/* The outcome of "Apply & load", where the person pressing it is looking. It used to go to
   the hint bar under the composer -- which the settings dialog is sitting on top of, so the
   report existed and could not be seen. */
.pyresult{margin:10px 0 0;padding:9px 11px;border-radius:8px;font-size:12.5px;line-height:1.55;
          background:var(--code);color:var(--fg);border:1px solid var(--line)}
.pyresult.bad{border-color:var(--danger)}
.pyresult .miss{color:var(--danger)}
.pyresult code{font-size:12px}

/* What a library said on the way, not what the code produced. Present, and visibly not the
   answer -- merged into stdout it has been reported as the result. */
.runout pre.stderr{color:var(--mut);font-style:italic}

/* A page the sandboxed JS tool produced. It is someone else's document in someone else's
   origin, so it gets a frame rather than being spliced into ours. */
/* Sized from the height the page reported for itself, so it reads as an embedded page
   rather than a fixed porthole; the bounds live in app.js next to the report. */
iframe.jsview{width:100%;border:1px solid var(--line);border-radius:6px;
              margin:8px 0 0;background:#fff;display:block}

/* What a sandboxed call printed. Its own block, distinct from the page it drew: that one is
   a foreign document behind a frame, these are lines we captured and can style and select.
   Warnings read the way stderr already does here; errors are the only thing that shouts. */
.jslog{font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;
       word-wrap:break-word;border-left:2px solid var(--line);padding:6px 0 6px 9px;
       margin:8px 0 0}
/* The panel around this is muted, so ordinary output has to say so explicitly or it reads
   as a warning -- which is exactly how it looked before this line existed. */
.jsline{padding:1px 0;color:var(--fg)}
.jsline.warn{color:var(--mut);font-style:italic}
.jsline.err{color:var(--danger)}

/* Figures, from either tool. */
.jsfigs{margin:8px 0 0;display:flex;flex-wrap:wrap;gap:8px}
.jsfigs img{max-width:100%;border:1px solid var(--line);border-radius:6px;background:#fff}

/* The pages a reply built: one browser per reply, a tab per page. */
.webtabs{margin:8px 0 0;border:1px solid var(--line);border-radius:8px;overflow:hidden}
.webtabbar{display:flex;align-items:center;gap:2px;flex-wrap:wrap;padding:4px 6px;
           background:var(--code);border-bottom:1px solid var(--line)}
.webtab{display:inline-flex;align-items:center;gap:4px;padding:2px 6px;border-radius:5px;
        font-size:12px;color:var(--mut);cursor:pointer;max-width:180px}
.webtab.on{background:var(--panel);color:var(--fg)}
.webtab > span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.webtabx{border:0;background:none;color:var(--mut);cursor:pointer;font-size:14px;
         line-height:1;padding:0 2px}
.webtabx:hover{color:var(--danger)}
.webtabhide{margin-left:auto;border:0;background:none;color:var(--mut);cursor:pointer;
            font-size:12px;padding:2px 4px}
.webtabhide:hover{color:var(--fg)}
.webstage{background:#fff}
.webstage iframe.jsview{border:0;border-radius:0;margin:0}

/* Phones. The tab bar is the part that breaks first: a row of tabs plus a hide button does
   not fit 360px, and a 12px × is not a touch target. It scrolls sideways instead of
   wrapping into a wall, the controls grow to something a thumb can hit, and the page below
   gets more of the screen because there is less of it to spare. */
@media (max-width: 640px){
  .webtabbar{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;
             scrollbar-width:none;padding:5px 6px}
  .webtabbar::-webkit-scrollbar{display:none}
  .webtab{flex:0 0 auto;max-width:44vw;padding:5px 8px;font-size:13px}
  .webtabx{font-size:17px;padding:0 6px;min-width:28px;min-height:28px}
  .webtabhide{position:sticky;right:0;flex:0 0 auto;font-size:13px;padding:5px 8px;
              min-height:28px;background:var(--code)}
  .jsview{min-height:120px}
}

/* A reply that built pages says so, and opens them on request rather than on sight. */
.webopen{margin:8px 0 0;display:inline-flex;align-items:center;gap:6px;padding:5px 10px;
         border:1px solid var(--line);border-radius:7px;background:var(--panel);
         color:var(--mut);font-size:12px;cursor:pointer}
.webopen:hover{color:var(--fg);border-color:var(--mut)}
.webopenicon{font-size:14px;line-height:1}
@media (max-width: 640px){ .webopen{padding:8px 12px;font-size:13px;min-height:36px} }

/* The resource strip. Fixed above the composer, so the question it answers -- "why is this
   slow right now?" -- is answered where it is asked, and collapses to one line when it is
   not. */
#resbar{border-top:1px solid var(--line);background:var(--panel);
        font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}
#resToggle{display:flex;align-items:center;gap:6px;width:100%;border:0;background:none;
           color:var(--mut);cursor:pointer;padding:6px 12px;font:inherit;text-align:left}
#resToggle:hover{color:var(--fg)}
#resCaret{font-size:10px;width:10px}
#resBody{display:flex;flex-wrap:wrap;gap:2px 18px;padding:0 12px 8px}
.rescell{display:flex;align-items:baseline;gap:6px;min-width:0}
.reslab{color:var(--mut)}
.resval{color:var(--fg);font-variant-numeric:tabular-nums}
/* Why a level says what it says, in the smallest type on the page: without it "tight" is
   an assertion, and the reading behind it is the part that can be checked. */
.resnote{color:var(--mut);opacity:.65}
.res-normal{color:var(--ok)}
.res-tight{color:var(--warn)}
.res-severe{color:var(--danger)}
.res-unknown{color:var(--mut)}
@media (max-width: 640px){
  /* Two columns rather than a row that wraps into an unreadable ribbon, and the reasons
     drop out: on a phone the level is the whole message. */
  #resBody{display:grid;grid-template-columns:1fr 1fr;gap:4px 12px}
  .resnote{display:none}
  #resToggle{padding:8px 12px}
}

/* ---- decision models: a state, some typed questions, and their answers --------------
   Laid out as a form rather than a transcript because there is no conversation: the same
   questions are asked of a new state, over and over, and the previous answer is not
   context for the next one. */
#decision{flex:1;overflow:auto;padding:18px 22px;display:flex;flex-direction:column;gap:10px}
#decision .dlabel{font-size:12px;font-weight:600;color:var(--mut);text-transform:uppercase;letter-spacing:.04em}
#decision textarea{width:100%;box-sizing:border-box;padding:10px 12px;border:1px solid var(--line);
  border-radius:10px;background:var(--bg);color:inherit;font:inherit;resize:vertical}
#decision .drow{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
#decision .drow .hint{margin-left:auto}
#decision .dimage{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:9px 11px;
  border:1px dashed var(--line);border-radius:10px}
#decision .dimage[hidden]{display:none}
#decision .dimage input{max-width:min(100%,320px)}
.dcal{border:1px solid var(--line);border-radius:10px;padding:9px 11px;font-size:13px;line-height:1.45}
.dcal.warn{border-color:#d99b3f;background:color-mix(in srgb,#d99b3f 10%,var(--bg));color:#9a5b00}
.dcal.ok{border-color:#3a9b70;background:color-mix(in srgb,#3a9b70 10%,var(--bg));color:#25704f}
.dq{border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin:0 0 8px;
  display:flex;flex-direction:column;gap:8px}
.dq .dqhead{display:flex;gap:8px;align-items:center}
.dq select,.dq input{padding:6px 8px;border:1px solid var(--line);border-radius:8px;
  background:var(--bg);color:inherit;font:inherit}
.dq .dqins{flex:1}
.dq .dqdrop{margin-left:auto;background:none;border:0;color:var(--mut);cursor:pointer;font-size:16px}
.dq .opt{display:flex;gap:6px;align-items:center}
.dq .opt input:first-child{width:150px}
.dq .opt input:last-of-type{flex:1}
.dq .needs{font-size:12px;color:var(--mut)}
.dans{border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin:8px 0 0}
.dans h4{margin:0 0 2px;font-size:13px}
.dans .verdict{font-size:20px;font-weight:600;margin:2px 0 6px}
.dans .dbar{display:flex;align-items:center;gap:8px;margin:3px 0;font-size:13px}
.dans .dbar .dname{width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dans .dbar .dtrack{flex:1;height:8px;background:var(--code);border-radius:5px;overflow:hidden}
/* A span is inline until told otherwise, and width does not apply to an inline box --
   the fill measured zero pixels wide at every percentage. */
.dans .dbar .dfill{display:block;height:100%;background:var(--accent,#2f9e75)}
.dans .dbar .dpct{width:56px;text-align:right;color:var(--mut);font-variant-numeric:tabular-nums}
.dans .meta{margin-top:6px;font-size:12px;color:var(--mut)}

/* `hidden` is an attribute, not a layout rule: an element already given a `display` keeps
   it and stays on screen. The panels that swap with each other say so explicitly. */
#composer[hidden],#messages[hidden],#attachments[hidden],#decision[hidden],#hintbar[hidden]{display:none}
/* The type picker takes what it needs and no more, so the question itself gets the room. */
.dq select{flex:0 0 auto;width:120px}
.dq .dqins{flex:1 1 auto;min-width:0}
/* A flex column shrinks EVERY child to fit the height it has, which is not what any of
   these want: the state box collapsed to one line despite `rows`, and the probability bars
   stacked on top of each other. The panel scrolls, so nothing here should be shrinking. */
#decision > *{flex:0 0 auto}
#decision textarea{min-height:8.5em}

/* Plain-language scaffolding for the decision panel: the numbered steps, the one-line
   explanations under them, and an answer stated as a sentence before it is stated as bars. */
#decision .dhelp{margin:-4px 0 2px;font-size:13px;color:var(--mut);line-height:1.5;max-width:64ch}
#decision .linky{margin-left:auto;background:none;border:0;color:var(--accent,#2f9e75);
  cursor:pointer;font:inherit;font-size:13px;text-decoration:underline}
.dq .needs{font-size:12px;color:var(--mut);line-height:1.5}
.dq .optlabel{font-size:12px;color:var(--mut);margin:2px 0 0}
.dans .asked{font-size:13px;color:var(--mut);margin:0 0 4px}
.dans .verdict{font-size:22px;font-weight:600;margin:0 0 2px;line-height:1.25}
.dans .says{font-size:13px;margin:0 0 8px;color:var(--fg)}
.dans .others{font-size:12px;color:var(--mut);margin:8px 0 2px}
.dans .sure{margin-top:8px;font-size:13px;color:var(--mut)}
.dans .sure b{color:var(--fg);font-weight:600}
.dans .escalate{margin-top:6px;font-size:13px;color:#b4690e}

/* The files inside a multi-file model, folded away until asked for. */
#cacheList details.files{margin:-4px 0 8px 10px}
#cacheList details.files summary{cursor:pointer;color:var(--mut);font-size:12px;padding:2px 0}
#cacheList .file{display:flex;align-items:center;gap:8px;padding:3px 0 3px 12px;font-size:12px}
#cacheList .file .fk{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
#cacheList .file .fs{color:var(--mut);white-space:nowrap}
#cacheList .file .partial{color:#b4690e}
