/* AgentMobile UI — tokens first. Dark by default, light follows the system unless forced. */
:root {
  --scale: 1;
  --bg: #0e0e10; --surface: #16161a; --raised: #1d1d22; --hover: #24242a; --line: #2a2a31; --line-strong: #3a3a43;
  --text: #ececef; --muted: #9a9aa3; --faint: #6b6b74;
  --accent: #8a8fff; --accent-ink: #0e0e10; --accent-soft: rgba(138, 143, 255, .14);
  --ok: #4cc38a; --warn: #e5a54b; --err: #f06a6a; --err-soft: rgba(240, 106, 106, .12);
  --code-bg: #121215; --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --r: 10px; --r-lg: 14px;
  --u-in: #3fbf6f; --u-cache: #e2b42d; --u-out: #ef5a5a;
  --cp-0: #8a8fff; --cp-1: #4fb3d9; --cp-2: #3fbf6f; --cp-3: #e2b42d; --cp-4: #ef7a5a; --cp-5: #d96fd0; --cp-6: #3ec9c0; --cp-7: #c08a5a; --cp-8: #9b7be0; --cp-9: #6b6b74;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fafaf9; --surface: #ffffff; --raised: #f2f2f0; --hover: #ebebe8; --line: #e4e4e0; --line-strong: #d0d0cb;
    --text: #1b1b1d; --muted: #6a6a70; --faint: #9a9aa0;
    --accent: #5b5fe0; --accent-ink: #ffffff; --accent-soft: rgba(91, 95, 224, .1);
    --code-bg: #f4f4f2; --shadow: 0 12px 40px rgba(0, 0, 0, .12); color-scheme: light;
    --u-in: #1f9d55; --u-cache: #c99a06; --u-out: #d83b3b;
    --cp-0: #5b5fe0; --cp-1: #1f84b0; --cp-2: #1f9d55; --cp-3: #c99a06; --cp-4: #d4572f; --cp-5: #b3379f; --cp-6: #12a39a; --cp-7: #9a6a3a; --cp-8: #6d4fc2; --cp-9: #9a9aa0;
  }
}
:root[data-theme="light"] {
  --bg: #fafaf9; --surface: #ffffff; --raised: #f2f2f0; --hover: #ebebe8; --line: #e4e4e0; --line-strong: #d0d0cb;
  --text: #1b1b1d; --muted: #6a6a70; --faint: #9a9aa0;
  --accent: #5b5fe0; --accent-ink: #ffffff; --accent-soft: rgba(91, 95, 224, .1);
  --code-bg: #f4f4f2; --shadow: 0 12px 40px rgba(0, 0, 0, .12); color-scheme: light;
  --u-in: #1f9d55; --u-cache: #c99a06; --u-out: #d83b3b;
  --cp-0: #5b5fe0; --cp-1: #1f84b0; --cp-2: #1f9d55; --cp-3: #c99a06; --cp-4: #d4572f; --cp-5: #b3379f; --cp-6: #12a39a; --cp-7: #9a6a3a; --cp-8: #6d4fc2; --cp-9: #9a9aa0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: calc(15px * var(--scale)); }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.55; }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .85rem; }
.ic { width: 1.25rem; height: 1.25rem; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 1rem; height: 1rem; }
.ic.lg { width: 1.5rem; height: 1.5rem; }

#app { height: 100%; position: relative; }
.view { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--bg); }
.view.active { display: flex; }

/* ---------- top bars ---------- */
.top { display: flex; align-items: center; gap: .25rem; height: 3.5rem; padding: 0 .375rem; flex: none; border-bottom: 1px solid var(--line); background: var(--bg); }
.top .title { flex: 1; min-width: 0; padding: 0 .375rem; }
.top .title .t1 { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .title .t2 { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: .3rem; }
.iconbtn { width: 2.5rem; height: 2.5rem; display: inline-grid; place-items: center; border: 0; background: none; color: var(--text); border-radius: 999px; flex: none; }
.iconbtn:active { background: var(--hover); }
.iconbtn.dim { color: var(--muted); }
.model-chip { display: inline-flex; align-items: center; gap: .25rem; max-width: 100%; padding: 0 .1rem; border: 0; background: none; color: var(--muted); font-size: .78rem; }
.model-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* header usage: ring = context left, bar = input/cache/output of this chat */
.model-chip.usage span { display: inline-flex; align-items: center; gap: .35rem; }
.model-chip.usage b { font-weight: 500; font-variant-numeric: tabular-nums; }
.ring { flex: none; display: block; }
.ubar { display: inline-flex; width: 4.2rem; height: .45rem; border-radius: 99px; overflow: hidden; background: var(--line); flex: none; gap: 1px; }
.ubar i { display: block; min-width: 2px; height: 100%; }
.ubar.big { width: 100%; height: .7rem; margin: .5rem 0; }
.ucall .ubar { width: 100%; height: .4rem; margin: .3rem 0 .2rem; }
.u-in { background: var(--u-in); } .u-ca { background: var(--u-cache); } .u-ou { background: var(--u-out); }
.cp-0 { background: var(--cp-0); } .cp-1 { background: var(--cp-1); } .cp-2 { background: var(--cp-2); } .cp-3 { background: var(--cp-3); } .cp-4 { background: var(--cp-4); } .cp-5 { background: var(--cp-5); } .cp-6 { background: var(--cp-6); } .cp-7 { background: var(--cp-7); } .cp-8 { background: var(--cp-8); } .cp-9 { background: var(--cp-9); }
.ucpu { display: flex; flex-direction: column; gap: .15rem; margin-top: .25rem; font-size: .78rem; }
.ucpu .ubar { width: 100%; height: .3rem; margin: 0; }
.ucard { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: .75rem .85rem; margin-bottom: .75rem; font-size: .85rem; }
.ulg { display: flex; align-items: center; gap: .5rem; padding: .15rem 0; }
.ulg .grow, .ucall .inline .grow { min-width: 0; overflow-wrap: anywhere; }
.ulg i { width: .7rem; height: .7rem; border-radius: 3px; flex: none; }
.ulg b { font-weight: 500; font-variant-numeric: tabular-nums; }
.ucall { padding: .5rem 0; border-top: 1px solid var(--line); font-size: .8rem; }
.ucall:first-of-type { border-top: 0; }
.ucall .muted { font-size: .75rem; }
.ucall.bad b { color: var(--err); }
.ucall .why { font-size: .75rem; color: var(--warn); margin-top: .15rem; }
/* usage sheet cards: shared header (icon tile · title/sub · number), stat tiles, warnings */
.ic.xs { width: .8rem; height: .8rem; }
.uhead { display: flex; align-items: center; gap: .65rem; }
.uhead + .ucall { border-top: 0; margin-top: .3rem; }
.uc-ico { width: 2rem; height: 2rem; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.uh-t { font-weight: 600; }
.uh-s { font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; line-height: 1.3; }
.uh-v { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.uh-of { font-size: .78rem; font-weight: 400; color: var(--muted); }
.ring-wrap { position: relative; flex: none; display: grid; place-items: center; }
.ring-wrap b { position: absolute; font-size: .68rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.uwarn { display: flex; align-items: center; gap: .35rem; margin-top: .6rem; padding: .4rem .55rem; border-radius: 8px; font-size: .75rem; }
.uwarn.warn { color: var(--warn); background: rgba(229, 165, 75, .14); }
.uwarn.err { color: var(--err); background: var(--err-soft); }
.ustats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin: .7rem 0 .2rem; }
.ustats div { background: var(--raised); border-radius: 8px; padding: .45rem .5rem; display: flex; flex-direction: column; gap: .05rem; min-width: 0; }
.ustats b { font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ustats span { font-size: .68rem; color: var(--muted); line-height: 1.25; overflow-wrap: anywhere; }
.ustats .bad b { color: var(--err); }
/* sub-agent card: delegate batches → numbered tasks */
.sa-batch { margin-top: .7rem; }
.sa-bh { font-size: .72rem; color: var(--faint); margin-bottom: .1rem; }
.sa-task { display: flex; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.sa-bh + .sa-task { border-top: 0; }
.sa-num { width: 1.4rem; height: 1.4rem; border-radius: 99px; flex: none; display: grid; place-items: center; font-size: .72rem; font-weight: 600; background: var(--raised); color: var(--muted); border: 1px solid var(--line-strong); }
.sa-goal { font-size: .84rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.sa-cost { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sa-task .ubar { width: 100%; height: .35rem; margin: .4rem 0 .3rem; }
.sa-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .3rem; font-size: .72rem; color: var(--muted); }
.sa-meta .ic { margin-right: .15rem; vertical-align: -1px; }
.sa-dot { color: var(--faint); }
.sa-task.tap { cursor: pointer; }
.sa-task.tap:active { background: var(--hover); }
.sa-st { font-size: .68rem; padding: .05rem .4rem; border-radius: 99px; background: var(--raised); color: var(--muted); margin-right: .2rem; white-space: nowrap; }
.sa-st.warn { color: var(--warn); background: rgba(229, 165, 75, .14); }
.sa-st.err { color: var(--err); background: var(--err-soft); }
/* delegate step in the chat → button that opens the sub-agents' traces */
.sub-open { display: inline-flex; align-items: center; gap: .4rem; margin: .1rem 0 .5rem; padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--text); font-size: .8rem; }
.sub-open .ic:first-child { color: var(--accent); }
.sub-open .ic:last-child { color: var(--faint); }
/* live sub-agents under a running delegate step: purple pulsing dot = working now */
.sub-live { display: flex; flex-direction: column; gap: .1rem; margin: .1rem 0 .5rem; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.sl-row { display: flex; align-items: center; gap: .55rem; padding: .3rem 0; }
.sl-row + .sl-row { border-top: 1px solid var(--line); }
.sl-row .sa-num { width: 1.2rem; height: 1.2rem; font-size: .66rem; }
.sl-goal { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-act { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-dot { width: .55rem; height: .55rem; border-radius: 99px; flex: none; background: var(--faint); }
.sl-row.active .sl-dot { background: var(--accent); box-shadow: 0 0 0 .2rem var(--accent-soft); }
.sl-row.active .sl-act { color: var(--accent); }
.sl-row.retry .sl-act { color: var(--warn); }
.sl-row.ok .sl-dot { background: var(--ok); }
.sl-row.warn .sl-dot { background: var(--warn); }
.sl-row.err .sl-dot { background: var(--err); }
/* sub-agent trace sheet */
.st-task > summary { list-style: none; cursor: pointer; }
.st-task > summary::-webkit-details-marker { display: none; }
.st-task .st-chev { color: var(--faint); transition: transform .15s; }
.st-task[open] .st-chev { transform: rotate(180deg); }
.st-body { margin-top: .6rem; }
.st-ctx { margin-bottom: .5rem; font-size: .78rem; }
.st-ctx > summary { cursor: pointer; color: var(--accent); }
.st-ctx .muted { white-space: pre-wrap; margin-top: .3rem; max-height: 10rem; overflow-y: auto; }
.st-list { border-left: 1px solid var(--line); padding-left: .7rem; }
.st-text { font-size: .82rem; color: var(--muted); margin: .3rem 0; }
.st-text p { margin: .2em 0; }
.st-report { margin-top: .7rem; padding: .55rem .65rem; border-radius: 8px; background: var(--raised); font-size: .82rem; }
.st-rh { display: flex; align-items: center; gap: .3rem; font-size: .72rem; color: var(--muted); margin-bottom: .3rem; }
.st-report .md { max-height: 18rem; overflow-y: auto; }
.sa-more { margin-top: .5rem; }
.sa-more > summary { list-style: none; cursor: pointer; font-size: .78rem; color: var(--accent); display: inline-flex; align-items: center; gap: .25rem; padding: .2rem 0; }
.sa-more > summary::-webkit-details-marker { display: none; }
.sa-more[open] > summary .ic { transform: rotate(180deg); }

/* ---------- chat ---------- */
#messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 1rem 1rem 3.4rem; scroll-behavior: auto; }
.msg { margin: 0 0 1.25rem; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { max-width: 86%; background: var(--raised); border-radius: 1.1rem 1.1rem .35rem 1.1rem; padding: .6rem .9rem; white-space: pre-wrap; word-break: break-word; }
.msg.user .imgs { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; margin-bottom: .35rem; }
.msg.user .imgs img { width: 5.5rem; height: 5.5rem; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); }
.msg.queued .bubble { opacity: .55; border: 1px dashed var(--line-strong); background: transparent; }
.msg.assistant .md { word-break: break-word; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: .55em 0; }
.md h2, .md h3, .md h4 { margin: 1.1em 0 .4em; line-height: 1.3; font-weight: 600; }
.md h2 { font-size: 1.15rem; } .md h3 { font-size: 1.05rem; } .md h4 { font-size: 1rem; }
.md ul, .md ol { padding-left: 1.3em; margin: .5em 0; } .md li { margin: .2em 0; } .md li.sub { margin-left: 1.2em; }
.md blockquote { margin: .6em 0; padding: .1em .9em; border-left: 2px solid var(--line-strong); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md code { font-family: var(--mono); font-size: .85em; background: var(--raised); padding: .1em .35em; border-radius: 5px; }
.md .code { margin: .7em 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--code-bg); }
.md .code-h { display: flex; justify-content: space-between; align-items: center; padding: .3rem .4rem .3rem .75rem; font-size: .75rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.md .code-h button { border: 0; background: none; color: var(--muted); font-size: .75rem; padding: .2rem .4rem; border-radius: 6px; }
.md .code pre { margin: 0; padding: .7rem .75rem; overflow-x: auto; }
.md .code pre code { background: none; padding: 0; font-size: .8rem; line-height: 1.5; }
.md .tbl { overflow-x: auto; margin: .6em 0; border: 1px solid var(--line); border-radius: var(--r); -webkit-overflow-scrolling: touch; }
.md table { border-collapse: separate; border-spacing: 0; font-size: .88rem; min-width: 100%; width: max-content; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: .4rem .6rem; text-align: left; vertical-align: top; min-width: 4.5em; max-width: 16em; white-space: normal; word-break: normal; overflow-wrap: break-word; }
.md tr:last-child td { border-bottom: 0; }
.md th { color: var(--muted); font-weight: 500; white-space: nowrap; background: var(--raised); }
.md td.num, .md th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* pinned columns stay put while the rest scrolls; pin2 = short index column + label column */
.md .p1 { position: sticky; left: 0; z-index: 1; background: var(--bg); box-shadow: inset -1px 0 0 var(--line-strong); max-width: 40vw; }
.md th.p1 { background: var(--raised); }
.md .pin2 .p0 { position: sticky; left: 0; z-index: 1; background: var(--bg); width: 3.4em; min-width: 3.4em; max-width: 3.4em; text-align: center; padding-left: .3rem; padding-right: .3rem; }
.md .pin2 th.p0 { background: var(--raised); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md .pin2 .p1 { left: 3.4em; }
.md-img { display: block; max-width: 100%; max-height: 60vh; margin: .5rem 0; border-radius: var(--r); border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.code.svg .svg-img { margin: 0; border: 0; border-radius: 0; background: transparent; }
.cursor::after { content: ""; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--muted); }

.think { margin: 0 0 .6rem; }
.think > summary, .steps > summary { list-style: none; display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .85rem; cursor: pointer; user-select: none; padding: .15rem 0; }
.think > summary::-webkit-details-marker, .steps > summary::-webkit-details-marker { display: none; }
.think > summary .ic, .steps > summary .ic { transition: transform .15s; }
.think[open] > summary .chev, .steps[open] > summary .chev { transform: rotate(90deg); }
.think .txt { margin: .35rem 0 0; padding-left: .8rem; border-left: 2px solid var(--line); color: var(--muted); font-size: .85rem; white-space: pre-wrap; max-height: 16rem; overflow-y: auto; }
.steps { margin: .35rem 0 .6rem; }
.steps .list { margin: .3rem 0 0; border-left: 1px solid var(--line); padding-left: .75rem; }
.tool { margin: 0; }
.tool > summary { list-style: none; display: flex; align-items: center; gap: .5rem; padding: .3rem 0; font-size: .85rem; color: var(--muted); cursor: pointer; }
.tool > summary::-webkit-details-marker { display: none; }
.tool .dot { width: .45rem; height: .45rem; border-radius: 99px; background: var(--faint); flex: none; }
.tool.run .dot { background: var(--accent); }
.tool.ok .dot { background: var(--ok); } .tool.err .dot { background: var(--err); }
.tool .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.tool .ms { font-size: .75rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.tool pre { margin: .2rem 0 .5rem; padding: .55rem .65rem; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; font-family: var(--mono); font-size: .75rem; white-space: pre-wrap; word-break: break-word; max-height: 14rem; overflow-y: auto; color: var(--muted); }
/* D-086: no CSS animation runs forever any more. An endless animation makes the WebView draw a frame every vsync (60-120/s) for as long as
   it lives, and that alone was ~1 CPU core while a chat was open. One JS heartbeat (app.js syncBeat) toggles body.beat ~1.6x/s while
   something is really running and the page is visible; everything that "pulses" or "blinks" just follows it. */
body.beat .tool.run .dot, body.beat .status .pulse, body.beat .ditem .run-dot, body.beat .sl-row.active .sl-dot, body.beat .cursor::after { opacity: .3; }
.tool-imgs { margin: .2rem 0 .6rem; }
/* a file the agent gives the user: tap the name to open, ⬇ download to the phone, share to LINE/Drive… */
.tool-files { display: flex; flex-direction: column; gap: .4rem; margin: .2rem 0 .6rem; }
.file-chip { display: flex; align-items: center; gap: .2rem; max-width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: .15rem .25rem .15rem .2rem; margin: .3rem 0; }
.file-chip .fc-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; border: 0; background: none; color: var(--text); text-align: left; padding: .45rem .4rem; font-size: .88rem; }
.file-chip .fc-open .ic { color: var(--accent); flex: none; }
.file-chip .fc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .iconbtn { width: 2.4rem; height: 2.4rem; color: var(--muted); }

.actions { display: flex; gap: .1rem; margin-top: .35rem; }
.actions button { border: 0; background: none; color: var(--faint); width: 2.1rem; height: 2.1rem; display: inline-grid; place-items: center; border-radius: 8px; }
.actions button:active, .actions button.on { color: var(--text); background: var(--hover); }
.speed { margin-top: .35rem; font-size: .72rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.actions.turn { margin: -.6rem 0 1rem; }
.actions.turn.inline { margin: 0; }
.note { margin: 0 0 1rem; font-size: .8rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.note.err { color: var(--err); }
.note .ic { width: .95rem; height: .95rem; }
/* the system killed the app mid-run: message + "ทำต่อ" / "ไม่ต้อง" (wraps on narrow screens) */
.note.interrupted { flex-wrap: wrap; row-gap: .45rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text); font-size: .85rem; }
.note.interrupted .ic { color: var(--warn); flex: none; }
.note.interrupted .grow { flex: 1 1 11rem; }
/* result of /compact or /clear: text + "ย้อนคืน" */
.note.cut { flex-wrap: wrap; row-gap: .4rem; }
.note.cut .grow { flex: 1 1 11rem; }
.note.cut .btn { flex: none; }

.welcome { max-width: 34rem; margin: 18vh auto 0; padding: 0 .5rem; }
.welcome h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 .25rem; letter-spacing: -.01em; }
.welcome p { color: var(--muted); margin: 0 0 1.25rem; }
.prompts { display: grid; gap: .5rem; }
.prompts button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: .7rem .85rem; color: var(--text); font-size: .92rem; display: flex; align-items: center; gap: .6rem; }
.prompts button .ic { color: var(--muted); }
.banner { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: .7rem .85rem; margin-bottom: 1rem; font-size: .9rem; }
.banner .ic { color: var(--warn); }

/* status + composer */
.status { display: flex; align-items: center; gap: .5rem; padding: .3rem 1rem; font-size: .8rem; color: var(--muted); flex: none; }
.status .pulse { width: .45rem; height: .45rem; border-radius: 99px; background: var(--accent); }
.queue { display: flex; gap: .4rem; overflow-x: auto; padding: 0 .75rem .4rem; flex: none; }
.qchip { display: flex; align-items: center; gap: .3rem; flex: none; max-width: 80%; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .2rem .25rem .2rem .7rem; font-size: .8rem; }
.qchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qchip button { flex: none; white-space: nowrap; border: 0; background: none; color: var(--muted); height: 2.4rem; min-width: 2.4rem; padding: 0 .6rem; border-radius: 999px; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; gap: .2rem; }
.qchip button:active { background: var(--hover); }
.qchip button.now { color: var(--accent); font-weight: 600; }
.qchip.pending { border-color: var(--accent); }
.msg.user .inj-note { font-size: .72rem; color: var(--faint); margin: .2rem .25rem 0 0; }
/* a folded question / approval: compact bar above the composer, the chat stays readable */
.askbar { display: flex; align-items: center; gap: .5rem; margin: 0 .75rem .4rem; padding: .3rem .3rem .3rem .75rem; border-radius: var(--r); border: 1px solid var(--accent); background: var(--accent-soft); font-size: .85rem; flex: none; cursor: pointer; }
.askbar.warn { border-color: var(--warn); background: var(--surface); }
.askbar > .ic { color: var(--accent); }
.askbar.warn > .ic { color: var(--warn); }
.askbar .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.askbar .btn { height: 2.2rem; flex: none; }
.qchip .wait { font-style: normal; color: var(--accent); font-size: .75rem; display: inline-flex; align-items: center; gap: .3rem; padding: 0 .3rem; white-space: nowrap; }
.spin { width: .7rem; height: .7rem; border-radius: 99px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); }
body.beat .spin { transform: rotate(180deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.iconbtn.spinning .ic { animation: spin .8s steps(8) 10; }   /* bounded: ~8 s, never endless */
.editbar { display: flex; align-items: center; gap: .5rem; margin: 0 .75rem .4rem; padding: .3rem .3rem .3rem .75rem; border-radius: var(--r); background: var(--accent-soft); color: var(--text); font-size: .8rem; flex: none; }
.attachbar { display: flex; gap: .4rem; padding: 0 .75rem .4rem; flex: none; overflow-x: auto; }
.att { position: relative; flex: none; }
.att img { width: 3.6rem; height: 3.6rem; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--raised); }
.att button { position: absolute; top: -.35rem; right: -.35rem; width: 1.3rem; height: 1.3rem; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: grid; place-items: center; padding: 0; }
.composer { margin: 0 .6rem .6rem; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg); padding: .35rem .35rem .35rem .25rem; display: flex; align-items: flex-end; gap: .1rem; flex: none; }
.composer textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: none; resize: none; max-height: 10rem; padding: .5rem .35rem; line-height: 1.45; }
.composer textarea::placeholder { color: var(--faint); }
.sendbtn { width: 2.4rem; height: 2.4rem; border-radius: 999px; border: 0; display: grid; place-items: center; background: var(--text); color: var(--bg); flex: none; }
.sendbtn:disabled { background: var(--raised); color: var(--faint); }
.sendbtn.stop { background: var(--raised); color: var(--text); border: 1px solid var(--line-strong); }
.popmenu { position: absolute; left: .6rem; bottom: 4.4rem; z-index: 30; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: .3rem; min-width: 13rem; }
.popmenu button { display: flex; align-items: center; gap: .6rem; width: 100%; border: 0; background: none; text-align: left; padding: .6rem .7rem; border-radius: 8px; font-size: .92rem; }
.popmenu button:active { background: var(--hover); }
.popmenu .ic { color: var(--muted); }

/* ---------- drawer ---------- */
.mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); z-index: 40; }
.drawer { position: absolute; top: 0; bottom: 0; left: 0; width: min(84vw, 21rem); z-index: 41; background: var(--surface); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-top { padding: .75rem .75rem .5rem; display: flex; flex-direction: column; gap: .5rem; flex: none; }
.search { display: flex; align-items: center; gap: .5rem; background: var(--raised); border-radius: var(--r); padding: 0 .7rem; height: 2.5rem; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); }
.drawer-scroll { flex: 1; overflow-y: auto; padding: 0 .5rem .75rem; }
.dsec { margin-top: .75rem; }
.dsec-h { display: flex; align-items: center; justify-content: space-between; padding: 0 .5rem; height: 2rem; font-size: .75rem; color: var(--faint); font-weight: 500; letter-spacing: .02em; }
.dsec-h button { border: 0; background: none; color: var(--muted); display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; padding: .2rem .3rem; border-radius: 6px; }
.ditem { display: flex; align-items: center; gap: .6rem; width: 100%; border: 0; background: none; text-align: left; padding: .55rem .5rem; border-radius: 8px; color: var(--text); font-size: .92rem; }
.ditem .ic { color: var(--muted); }
.ditem .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ditem .meta { font-size: .72rem; color: var(--faint); flex: none; }
.ditem .run-dot { width: .5rem; height: .5rem; border-radius: 99px; background: var(--accent); flex: none; }
.ditem.on { background: var(--hover); }
.ditem:active { background: var(--hover); }
.ditem .more { color: var(--faint); margin: -.4rem -.3rem -.4rem 0; }
.drawer-foot { border-top: 1px solid var(--line); padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom)); flex: none; }
.newchat { display: flex; align-items: center; justify-content: center; gap: .45rem; height: 2.5rem; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); color: var(--text); font-weight: 500; }

/* ---------- settings ---------- */
.page { flex: 1; overflow-y: auto; padding: .5rem 0 2rem; }
.group { margin: 1rem 0 0; }
.group-h { padding: 0 1.1rem .35rem; font-size: .75rem; color: var(--faint); font-weight: 500; letter-spacing: .02em; }
.group-b { margin: 0 .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.group-f { padding: .4rem 1.1rem 0; font-size: .78rem; color: var(--faint); }
.row { display: flex; align-items: center; gap: .75rem; min-height: 3rem; padding: .55rem .9rem; border: 0; background: none; width: 100%; text-align: left; color: var(--text); }
.group-b > .row + .row, .group-b > * + .row, .group-b > .row + * { border-top: 1px solid var(--line); }
button.row:active, .row.tap:active { background: var(--hover); }
.row > .ic { color: var(--muted); }
.row .lbl { flex: 1; min-width: 0; }
.row .lbl .l1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .lbl .l2 { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .lbl .l2.wrap { white-space: normal; word-break: break-word; }
.row .val { color: var(--muted); font-size: .88rem; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--faint); }
.row.stack { flex-direction: column; align-items: stretch; gap: .45rem; }
.row.danger { color: var(--err); }
.field { display: flex; flex-direction: column; gap: .3rem; padding: .65rem .9rem; }
.field > label { font-size: .78rem; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; outline: 0; }
.input:focus { border-color: var(--line-strong); }
textarea.input { resize: vertical; min-height: 5rem; line-height: 1.5; }
textarea.input.mono { font-family: var(--mono); font-size: .8rem; }
.inline { display: flex; gap: .4rem; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 2.3rem; padding: 0 .9rem; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: .88rem; font-weight: 500; white-space: nowrap; }
.btn:active { background: var(--hover); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.danger { color: var(--err); }
.btn.sm { height: 1.9rem; padding: 0 .65rem; font-size: .8rem; }
.btn.icon-only { width: 2.3rem; padding: 0; }
.btn:disabled { opacity: .45; }
.btns { display: flex; gap: .5rem; justify-content: flex-end; padding: .65rem .9rem; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: .25rem; height: 1.35rem; padding: 0 .5rem; border-radius: 999px; font-size: .72rem; background: var(--raised); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.tag.ok { color: var(--ok); background: rgba(76, 195, 138, .12); }
.tag.err { color: var(--err); background: var(--err-soft); }
.tag.warn { color: var(--warn); background: rgba(229, 165, 75, .12); }
.tag.accent { color: var(--accent); background: var(--accent-soft); }
.switch { position: relative; width: 2.6rem; height: 1.5rem; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; z-index: 1; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: 1.2rem; height: 1.2rem; border-radius: 99px; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(1.1rem); }
.seg { display: inline-flex; background: var(--raised); border-radius: 8px; padding: .15rem; gap: .1rem; }
.seg button { border: 0; background: none; color: var(--muted); height: 1.9rem; padding: 0 .75rem; border-radius: 6px; font-size: .82rem; white-space: nowrap; flex: none; }
.seg.scroll { display: flex; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.empty { padding: 1.4rem 1rem; text-align: center; color: var(--faint); font-size: .88rem; }
.crumbs { display: flex; align-items: center; gap: .2rem; padding: .3rem .9rem .5rem; font-size: .82rem; color: var(--muted); overflow-x: auto; white-space: nowrap; }
.crumbs button { border: 0; background: none; color: var(--muted); padding: .2rem .3rem; border-radius: 6px; }
.crumbs button:last-child { color: var(--text); }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
.kv > div { background: var(--surface); padding: .7rem .8rem; }
.kv .k { font-size: .72rem; color: var(--faint); }
.kv .v { font-size: 1.05rem; font-weight: 600; margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar { height: .35rem; background: var(--raised); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 99px; }
.bar.warn > div { background: var(--warn); } .bar.err > div { background: var(--err); }
.heat { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: .8rem .9rem; }
.heat i { aspect-ratio: 1; border-radius: 2px; background: var(--raised); }
.heat i.h1 { background: color-mix(in srgb, var(--accent) 30%, var(--raised)); }
.heat i.h2 { background: color-mix(in srgb, var(--accent) 55%, var(--raised)); }
.heat i.h3 { background: color-mix(in srgb, var(--accent) 80%, var(--raised)); }
.heat i.h4 { background: var(--accent); }
.heat i.fut { opacity: .3; }
/* usage: today/yesterday + stacked daily token chart (cache / input / output) */
.u0 { background: var(--u-cache); } .u1 { background: var(--u-in); } .u2 { background: var(--u-out); }
.days2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.dc { background: var(--surface); padding: .7rem .8rem; min-width: 0; }
.dc .k { font-size: .72rem; color: var(--faint); }
.dc .v { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.dc .v small { font-size: .72rem; font-weight: 400; color: var(--muted); }
.dcs { font-size: .75rem; margin-top: .3rem; }
.split { display: flex; gap: 2px; height: .4rem; margin-top: .4rem; border-radius: 99px; overflow: hidden; background: var(--raised); }
.split i { min-width: 2px; }
.chart { padding: .7rem .8rem .4rem; }
.legend { display: flex; gap: .9rem; font-size: .75rem; color: var(--muted); margin-bottom: .5rem; }
.legend i, .dl i { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.ymax { font-size: .68rem; color: var(--faint); font-variant-numeric: tabular-nums; border-bottom: 1px dashed var(--line); line-height: 1.4; }
.cols { display: flex; align-items: stretch; gap: 4px; height: 9rem; border-bottom: 1px solid var(--line-strong); }
.cols.long { gap: 2px; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; position: relative; border: 0; padding: 0; background: none; border-radius: 4px 4px 0 0; }
.col.on { background: var(--accent-soft); }
.stk { display: flex; flex-direction: column-reverse; gap: 2px; min-height: 0; width: 70%; max-width: 2.2rem; margin: 0 auto; border-radius: 4px 4px 0 0; overflow: hidden; }
.cols.long .stk { width: 100%; border-radius: 2px 2px 0 0; gap: 1px; }
.stk i { min-height: 1px; }
.xl { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font-size: .66rem; color: var(--faint); white-space: nowrap; padding-top: .25rem; }
.col.on .xl { color: var(--text); }
#dayDetail { border-top: 1px solid var(--line); margin-top: 1.6rem; }
.dd { padding: .6rem .9rem .7rem; font-size: .85rem; }
.dl { display: flex; justify-content: space-between; gap: .75rem; padding: .15rem 0; color: var(--muted); }
.dl > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-text { padding: .9rem; border-top: 1px solid var(--line); }
.slider { width: 100%; accent-color: var(--accent); }
.ctx-line { display: flex; justify-content: space-between; gap: .75rem; font-size: .85rem; padding: .35rem 0; }
.ctx-line span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

/* ---------- modal / sheet ---------- */
.modal { position: absolute; inset: 0; z-index: 60; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 40rem; max-height: 92%; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 1.1rem 1.1rem 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow); padding-bottom: env(safe-area-inset-bottom); }
.sheet.tall { height: 92%; }
.sheet.cap { max-height: 70vh; }   /* question / approval: a long text scrolls inside the sheet (.sheet-b), never over the whole screen */
.sheet-h { display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem .5rem 1.1rem; min-height: 3.25rem; border-bottom: 1px solid var(--line); flex: none; }
.sheet-h .t { flex: 1; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-b { overflow-y: auto; overflow-x: hidden; padding: .9rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: .75rem; flex: 1; }
.sheet-b .group-b { margin: 0; }
.sheet-b pre.view { margin: 0; padding: .75rem; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .78rem; flex: 1; overflow: auto; }
.dialog-title { font-weight: 600; font-size: 1.02rem; display: flex; align-items: center; gap: .5rem; }
.dialog-title .ic { color: var(--warn); }
.dialog-detail { margin: 0; padding: .65rem .75rem; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; font-family: var(--mono); font-size: .78rem; white-space: pre-wrap; word-break: break-word; max-height: 40vh; overflow: auto; }
.ap-always { font-size: .78rem; color: var(--muted); margin: .6rem 0 .5rem; }
.opts { display: flex; flex-direction: column; gap: .4rem; }
.opts button { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: .65rem .8rem; color: var(--text); }
.opts button:active { border-color: var(--accent); }
.tabs-s { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin: -.2rem -1.1rem 0; padding: 0 1.1rem; overflow-x: auto; }
.tabs-s button { border: 0; background: none; color: var(--muted); padding: .55rem .2rem; margin-right: 1.1rem; font-size: .88rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs-s button.on { color: var(--text); border-bottom-color: var(--text); }
.picker-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.picker-list button { text-align: left; border: 0; background: none; padding: .6rem .75rem; display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: .9rem; }
.picker-list button + button { border-top: 1px solid var(--line); }
.picker-list button.on { color: var(--accent); }
.picker-list button .ic { margin-left: auto; }

.toast { position: absolute; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 80; background: var(--text); color: var(--bg); border-radius: 999px; padding: .5rem 1rem; font-size: .85rem; max-width: 90%; box-shadow: var(--shadow); text-align: center; }
.img-viewer { position: fixed; inset: 0; z-index: 9999; background: rgba(0, 0, 0, .94); overflow: hidden; touch-action: none; overscroll-behavior: contain; user-select: none; -webkit-user-select: none; }
/* D-086: the viewer does its own pinch / double-tap / pan (pointer events) - touch-action:none keeps the WebView's page zoom and the chat scroller out of it */
.img-viewer .iv-stage { position: absolute; inset: 0; display: grid; place-items: center; touch-action: none; }
.img-viewer .iv-stage img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; transform-origin: 50% 50%; will-change: transform; touch-action: none; -webkit-user-drag: none; pointer-events: none; }
.img-viewer .cap { position: absolute; left: 0; right: 0; bottom: 4.2rem; text-align: center; color: #aaa; font-size: .75rem; word-break: break-all; padding: 0 1rem; pointer-events: none; }
.img-viewer .iv-acts { position: absolute; left: 0; right: 0; bottom: 1rem; display: flex; gap: .6rem; justify-content: center; }
.img-viewer .iv-acts .btn { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .2); display: inline-flex; align-items: center; gap: .35rem; }
.img-viewer .iv-x { position: absolute; top: calc(.6rem + env(safe-area-inset-top)); right: .6rem; width: 2.6rem; height: 2.6rem; border-radius: 99px; border: 0; background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center; }

.btn.danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
.sheet-b > * { flex-shrink: 0; }
.sheet-b > pre.view, .sheet-b > textarea { flex-shrink: 1; }
.picker-list button.use { color: var(--accent); }
.row.tap { cursor: pointer; }
#confirmDlg { z-index: 70; }

/* ---- in-app browser (header + start page; the page is a native WebView under the header) */
.bv-top { position: relative; gap: .125rem; padding-right: .25rem; }
.bv-addr { flex: 1; min-width: 0; display: flex; align-items: center; gap: .45rem; height: 2.375rem; margin: 0 .2rem; padding: 0 .3rem 0 .8rem; border-radius: 999px; background: var(--raised); border: 1px solid transparent; transition: background .15s, border-color .15s; }
.bv-addr:focus-within { background: var(--surface); border-color: var(--line-strong); }
.bv-addr input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: none; background: none; color: var(--text); font: inherit; font-size: .9rem; text-overflow: ellipsis; }
.bv-addr input::placeholder { color: var(--faint); }
.bv-kind { color: var(--muted); }
.bv-addr button { width: 2rem; height: 2rem; display: inline-grid; place-items: center; flex: none; border: 0; border-radius: 999px; background: none; color: var(--muted); }
.bv-addr button:active { background: var(--hover); }
.bv-star.on { color: var(--accent); }
.bv-star.on .ic { fill: currentColor; }
.bv-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
.bv-progress i { display: block; width: 0; height: 100%; background: var(--accent); opacity: 0; transition: width .25s ease, opacity .35s ease .15s; }
.bv-progress.on i { opacity: 1; transition: width .25s ease, opacity 0s; }
.bv-url { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bv-nav { display: flex; gap: .5rem; padding: 0 0 .75rem; }
.bv-nav .btn { flex: 1; justify-content: center; }
#btnBrowser { position: relative; }
#btnBrowser.live::after { content: ''; position: absolute; top: .6rem; right: .6rem; width: .4rem; height: .4rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }

/* ---- per-chat input breakdown (usage sheet) */
:root { --cb-sys: #8a8fff; --cb-tool: #4fa3e0; --cb-msg: #8f96a3; --cb-res: #e0913c; --cb-etc: #5c6370; }
.cb-sys { background: var(--cb-sys); } .cb-tool { background: var(--cb-tool); } .cb-msg { background: var(--cb-msg); }
.cb-res { background: var(--cb-res); } .cb-etc { background: var(--cb-etc); }
.cb-prev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono, monospace); }

/* D-068: diff of a file the chat changed */
.diffv { font-size: .74rem; line-height: 1.45; overflow-x: auto; white-space: pre; border-radius: 10px; background: rgba(127,127,127,.08); background: color-mix(in srgb, var(--text) 4%, transparent); padding: .4rem 0; }
.diffv > div { padding: 0 .6rem; min-width: max-content; }
.diffv .da { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.diffv .dd { background: color-mix(in srgb, var(--err) 16%, transparent); }
.diffv .dh { color: var(--muted); }

/* D-086: "back to the bottom" while the reader is scrolled up (auto-follow is off then) */
.tb-wrap { position: relative; height: 0; flex: none; z-index: 5; }
.to-bottom { position: absolute; right: .9rem; bottom: .6rem; height: 2.4rem; padding: 0 .85rem 0 .65rem; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--raised); color: var(--text); display: inline-flex; align-items: center; gap: .3rem; font-size: .82rem; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.to-bottom:active { background: var(--hover); }
/* the hero can never sit next to real messages, whatever the script did or did not redraw (D-086) */
#messages:has(.msg, .note) > .welcome { display: none; }
