/* Pitwall Mem pages, on top of pitwall-theme.css (tokens, top bar, cards, KPI tiles, bars, tags, tables, buttons).
   Only what the memory viewer adds or adjusts lives here; pitwall-theme.css is never edited, so a theme update stays a file copy. */

/* --- base ------------------------------------------------------------------------------------------------------ */
html { scroll-padding-top: 72px; }
p { margin: 0; }
a:not(:hover) { text-decoration: none; }
pre { font: 12.5px/1.45 var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.tab[hidden] { display: none; }
.secret { white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
pre code { background: none; border: 0; padding: 0; }
mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
button { cursor: pointer; }
textarea { font: inherit; color: inherit; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.muted { color: var(--muted); }
.mono { font-size: 12.5px; }

/* form controls: the look of the theme's .input */
input[type="text"], input[type="search"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--ring); outline-offset: -1px; border-color: var(--ring); }
select { max-width: 100%; text-overflow: ellipsis; padding-right: 28px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select:disabled { opacity: .55; cursor: default; }
textarea { height: auto; min-height: 110px; padding: 8px 10px; resize: vertical; line-height: 1.55; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.field-label { font-weight: 600; font-size: 13px; }
.form-error { color: var(--err); font-size: 13px; min-height: 1.3em; }
.form-error:empty { min-height: 0; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { color: var(--err); }
.btn.danger[data-confirm="1"] { background: var(--err); border-color: var(--err); color: var(--surface); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex: none; }
.seg button { white-space: nowrap; }

/* --- top bar: links for tabs, the product name after the brand, the queue in the status pill --------------------- */
.brand .product { color: var(--muted); font-weight: 500; font-size: 16px; margin-left: -4px; }
.tab { text-decoration: none; }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
a.status { text-decoration: none; }
a.status:hover { color: var(--text); }
.status .dot { flex: none; }
.status.busy .dot { background: var(--info); }
.status.warn .dot { background: var(--warn); }
@media (prefers-reduced-motion: no-preference) { .status.busy .dot { animation: breathe 1.8s ease-in-out infinite; } }
/* Eight tabs: they take their own row before the theme's phone layout does. */
@media (max-width: 1120px) and (min-width: 761px) {
  .top-in { height: auto; flex-wrap: wrap; gap: 0 12px; padding-top: 10px; }
  .tabs { order: 3; width: 100%; height: 44px; overflow-x: auto; margin: 6px -12px 0; }
}
.tabs { scrollbar-width: none; }

/* loading bar: shown only when a page takes a moment */
.loadbar { position: fixed; z-index: 60; top: 0; left: 0; height: 2px; width: 0; background: var(--accent); opacity: 0; }
body.busy .loadbar { opacity: 1; width: 80%; transition: width 2.5s cubic-bezier(.1, .7, .2, 1); }

/* --- login ----------------------------------------------------------------------------------------------------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); padding: 28px 28px 22px; display: grid; gap: 10px; box-shadow: var(--pop); }
.login-card .brand { margin-bottom: 8px; }
.login-card h1 { margin: 0; }
.login-card .btn { margin-top: 6px; height: 36px; }
.hint { font-size: 13px; color: var(--muted); }
.login-prefs { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--border); }

/* --- page structure -------------------------------------------------------------------------------------------- */
#view { container: main / inline-size; outline: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; }
#llm, #results, .stack, .tips { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; min-width: 0; }
#view > .kpis, #llm > .kpis { margin: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; margin-bottom: -10px; font-size: 13px; }
.crumbs a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.crumbs a:hover { color: var(--text); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }
.page-head .lede { margin: 4px 0 0; }
.actions, .btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.card > .body { padding: 0 20px 18px; min-width: 0; }
.card-head h2 a { color: inherit; }
.card-head > a { font-size: 13px; font-weight: 500; }
.head-aside { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.cols.wide-left { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
@container main (max-width: 820px) { .cols, .cols.wide-left { grid-template-columns: minmax(0, 1fr); } }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar > input[type="search"] { flex: 1 1 240px; width: auto; }
.toolbar > select, .toolbar > input[type="date"] { flex: 0 1 240px; width: auto; }
.toolbar label.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.toolbar label.inline input { width: auto; }
@media (max-width: 560px) { .toolbar > select, .toolbar > input[type="date"], .toolbar label.inline { flex: 1 1 140px; } .toolbar label.inline input { flex: 1; } }
.grow { flex: 1; }
.gap-top { margin-top: 0; }
#results[aria-busy="true"] { opacity: .55; transition: opacity .15s .1s; }

/* --- KPI tiles: as many as fit, links when they lead somewhere ---------------------------------------------------- */
#view .kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi .k::first-letter { text-transform: uppercase; }
.kpi .v .sd { font: 600 18px/1.55 var(--font); }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.kpi[data-tone="doing"] .v { color: var(--info); }

/* --- queue card: state, figures, why it waits, other machines ------------------------------------------------------ */
.qcard .card-head .sd { font-size: 14px; }
.qwhy { margin: 0 20px 16px; padding: 10px 12px; border-radius: 8px; font-size: 13px; background: var(--surface-2); color: var(--text); }
.qwhy[data-tone="warn"] { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.qwhy[data-tone="err"] { background: color-mix(in srgb, var(--err) 12%, var(--surface)); }
.qwhy b { font-weight: 600; }
.qcard .stats dd.warn { color: var(--warn); }
.qcard .stats dd.err { color: var(--err); }
.qcard .stats dd small { font: 500 12.5px var(--font); color: var(--muted); margin-left: 3px; }

/* --- activity heat map ----------------------------------------------------------------------------------------- */
.heat-wrap { overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.heat { display: grid; grid-template-columns: 28px repeat(var(--weeks), minmax(10px, 1fr)); grid-template-rows: 16px; grid-auto-rows: auto; gap: 3px;
  max-width: calc(28px + var(--weeks) * 21px); min-width: calc(28px + var(--weeks) * 13px); font-size: 11px; color: var(--muted); }
.heat .mo { grid-row: 1; white-space: nowrap; line-height: 14px; }
.heat .wd { grid-column: 1; align-self: center; line-height: 1; }
.heat i, .heat-legend i { aspect-ratio: 1; border-radius: 3px; background: var(--track); }
.heat i[data-l="1"], .heat-legend i[data-l="1"] { background: color-mix(in srgb, var(--accent) 30%, var(--track)); }
.heat i[data-l="2"], .heat-legend i[data-l="2"] { background: color-mix(in srgb, var(--accent) 55%, var(--track)); }
.heat i[data-l="3"], .heat-legend i[data-l="3"] { background: color-mix(in srgb, var(--accent) 78%, var(--track)); }
.heat i[data-l="4"], .heat-legend i[data-l="4"] { background: var(--accent); }
.heat i.today { outline: 1.5px solid var(--text); outline-offset: -1.5px; }
.heat-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.heat-legend i { width: 11px; height: 11px; }
.heat-legend span { margin: 0 4px; }

/* --- record lists: one row per record, edge to edge in a card like the dashboard's lists ----------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 16px; padding: 12px 20px; border-top: 1px solid var(--border); content-visibility: auto; contain-intrinsic-size: auto 64px; }
.body > .list { margin-inline: -20px; }
.body > .list:last-child { margin-bottom: -18px; }
.body > .list:first-child > li:first-child { border-top: 0; padding-top: 2px; }
.list .lead { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--muted); }
.list .title { font-weight: 500; color: var(--text); text-decoration: none; overflow-wrap: anywhere; cursor: pointer; }
.list .title:hover { text-decoration: underline; text-decoration-color: var(--muted); }
.list .aside { color: var(--muted); font-size: 12.5px; text-align: right; white-space: nowrap; align-self: start; }
.list .snippet { grid-column: 1 / -1; color: var(--muted); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.list .meta { grid-column: 1 / -1; }
.list.compact > li { padding-block: 10px; }
.list .title.mono { font-family: var(--mono); font-size: 12.5px; font-weight: 400; line-height: 1.5; }
@container main (max-width: 560px) { .list > li { grid-template-columns: minmax(0, 1fr); } .list .aside { text-align: left; } }
.meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.meta-item { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); min-width: 0; max-width: 100%; }
.meta-item .i { width: 14px; height: 14px; vertical-align: 0; }
a.meta-item:hover { color: var(--accent-text); }
.ref { font: 600 12px var(--mono); color: var(--accent-text); text-decoration: none; white-space: nowrap; }
.ref:hover { text-decoration: underline; }
/* Record kinds: a tinted tag per kind, the word always shown. */
.tag[data-type="discovery"], .tag[data-type="summary"] { background: color-mix(in srgb, var(--info) 13%, var(--surface)); color: var(--info); }
.tag[data-type="decision"], .tag[data-type="outdated"] { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); color: var(--warn); }
.tag[data-type="bugfix"], .tag[data-type="contradiction"] { background: color-mix(in srgb, var(--err) 13%, var(--surface)); color: var(--err); }
.tag[data-type="feature"], .tag[data-type="done"] { background: color-mix(in srgb, var(--ok) 13%, var(--surface)); color: var(--ok); }
.tag[data-type="refactor"], .tag[data-type="note"] { background: color-mix(in srgb, var(--s6) 15%, var(--surface)); color: var(--s6); }
a.tag { text-decoration: none; }
a.tag.line:hover { color: var(--text); border-color: var(--muted); }
/* Task and note status: the theme's status dot, one tone per status. */
.sd[data-s="doing"] { color: var(--info); } .sd[data-s="doing"]::before { background: var(--info); }
.sd[data-s="blocked"] { color: var(--err); } .sd[data-s="blocked"]::before { background: var(--err); }
.sd[data-s="done"], .sd[data-s="active"] { color: var(--ok); } .sd[data-s="done"]::before, .sd[data-s="active"]::before { background: var(--ok); }
.sd[data-s="todo"] { color: var(--muted); } .sd[data-s="todo"]::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.sd[data-s="archived"], .sd[data-s="cancelled"] { color: var(--muted); text-decoration: line-through; }
@media (prefers-reduced-motion: no-preference) { .sd[data-s="doing"]::before { animation: breathe 1.8s ease-in-out infinite; } }
.sd { font-size: 12.5px; }

/* simple name / value rows (projects, files, machines) */
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.kv li:first-child { border-top: 0; padding-top: 0; }
.kv .k { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv .k.path { direction: rtl; text-align: left; font-family: var(--mono); font-size: 12.5px; }
.kv .v { color: var(--muted); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.share { display: grid; gap: 5px; flex: 1; min-width: 0; }
.share .bfill { background: var(--accent); }

/* --- tables: the theme's .tbl, sortable headers ---------------------------------------------------------------- */
.tbl th button { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.tbl th button:hover { color: var(--text); }
.tbl th button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
.tbl th .i { width: 14px; height: 14px; opacity: 0; }
.tbl th[aria-sort] .i { opacity: 1; color: var(--accent-text); }
.tbl th.n { text-align: right; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .pname { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.minibar { display: inline-flex; align-items: center; gap: 8px; }
.minibar .btrack { width: 56px; }
.minibar .bfill { background: var(--ok); }
@media (max-width: 760px) { .tbl td.wide { font-size: 15px; } .tbl tbody tr:hover td { background: none; } .card > .tbl tbody tr:first-child { border-top: 0; } }

/* --- pager ----------------------------------------------------------------------------------------------------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.pager-sum { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pager-nav { display: flex; align-items: center; gap: 4px; }
.pg-nums { display: flex; gap: 4px; }
.pg { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; font-variant-numeric: tabular-nums; }
.pg:hover { color: var(--text); background: var(--surface-2); }
.pg[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pg.gap { border: 0; background: none; min-width: 20px; padding: 0; }
.pg[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.pg-compact { display: none; padding: 0 10px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
@container main (max-width: 560px) { .pg-nums { display: none; } .pg-compact { display: inline; } .pager { justify-content: center; } .pager-sum { width: 100%; text-align: center; } }

/* --- timeline spine -------------------------------------------------------------------------------------------- */
.day { position: relative; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 0 26px; }
.day + .day { margin-top: 6px; }
.day-label { position: sticky; top: 72px; align-self: start; padding-top: 12px; text-align: right; }
.day-label b { display: block; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day-label span { font-size: 12.5px; color: var(--muted); }
.day-items { position: relative; list-style: none; margin: 0; padding: 4px 0 8px; border-left: 2px solid var(--border); }
/* No content-visibility here: its paint containment would clip the dot that sits on the spine. */
.entry { position: relative; padding: 10px 0 10px 22px; }
.entry::before { content: ""; position: absolute; left: -7px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); }
.entry[data-kind="sum"]::before { background: var(--accent); border-color: var(--accent); }
.entry[data-kind="event"]::before { border-color: var(--err); border-radius: 2px; }
.entry[data-kind="prompt"]::before { background: var(--text); border-color: var(--text); border-radius: 2px; }
.entry .head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12.5px; color: var(--muted); }
.entry .when { font-family: var(--mono); font-size: 12px; color: var(--text); }
.entry .title { display: block; margin-top: 2px; font-weight: 500; color: var(--text); text-decoration: none; overflow-wrap: anywhere; cursor: pointer; }
.entry .title:hover { text-decoration: underline; text-decoration-color: var(--muted); }
.entry .sub { margin-top: 2px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry .meta { margin-top: 4px; }
.entry.prompt-text .title { cursor: default; white-space: pre-wrap; font-weight: 400; }
.entry.prompt-text .title:hover { text-decoration: none; }
.entry.prompt-text:has(details[open]) .clipped { display: none; }
.entry.prompt-text summary { cursor: pointer; font-size: 13px; margin-top: 4px; }
@container main (max-width: 620px) {
  .day { grid-template-columns: minmax(0, 1fr); }
  .day-label { position: static; text-align: left; padding: 14px 0 4px; display: flex; gap: 8px; align-items: baseline; }
  .day-items { margin-left: 4px; }
}

/* --- task board ------------------------------------------------------------------------------------------------ */
.composer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px; }
.composer .row { display: flex; flex-wrap: wrap; gap: 10px; }
.composer .row > input[type="text"] { flex: 3 1 260px; }
.composer .row > select, .composer .row > input[type="date"] { flex: 1 1 140px; width: auto; }
.composer .row > .btn { flex: 0 0 auto; }
details.new > summary { list-style: none; display: inline-flex; }
details.new > summary::-webkit-details-marker { display: none; }
details.new[open] > summary { margin-bottom: 12px; }
.lanes { display: grid; gap: 28px; }
.lane, .kanban { min-width: 0; }
.lane-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 10px; }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(200px, 1fr)); gap: 12px; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-width: 0; }
.col h3 { display: flex; align-items: center; justify-content: space-between; margin: 2px 4px 10px; font-size: 13px; font-weight: 600; }
.col h3 .num { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.col ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; min-height: 44px; align-content: start; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.tcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: var(--shadow); border-left: 3px solid var(--muted); }
.tcard[data-p="1"] { border-left-color: var(--err); }
.tcard[data-p="3"] { border-left-color: var(--border); }
.tcard .title { display: block; font-weight: 500; color: var(--text); cursor: pointer; overflow-wrap: anywhere; text-decoration: none; }
.tcard .meta { margin-top: 6px; font-size: 12px; gap: 3px 10px; }
.tcard[data-drag] { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; }
.tcard.dragging { opacity: .55; cursor: grabbing; box-shadow: var(--pop); }
.col .more-done { font-size: 12.5px; color: var(--muted); padding: 2px 4px; }
@media (max-width: 1000px) { .kanban { grid-template-columns: repeat(4, minmax(240px, 82vw)); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; } .col { scroll-snap-align: start; } }

/* --- brief, prose ---------------------------------------------------------------------------------------------- */
.prose { line-height: 1.65; max-width: 76ch; overflow-wrap: anywhere; }
.prose p + p, .prose ul, .prose ol, .prose pre, .prose h4 { margin-top: .7em; }
.prose ul, .prose ol { padding-left: 1.3em; margin-bottom: 0; }
.prose li + li { margin-top: .25em; }
.prose h4 { font-size: 13.5px; margin-bottom: 0; }
.brief { border-left: 3px solid var(--accent); padding-left: 16px; }
.foot-note { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

/* --- empty states, skeletons ----------------------------------------------------------------------------------- */
.empty { padding: 28px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.card .empty { border: 0; padding: 4px 0 2px; text-align: left; }
.error-box { padding: 14px 16px; border-radius: 10px; background: color-mix(in srgb, var(--err) 12%, var(--surface)); color: var(--err); }
.skel { display: grid; gap: 14px; }
.skel i { display: block; height: 14px; border-radius: 4px; background: var(--track); }
.skel i:nth-child(3n) { width: 70%; } .skel i:nth-child(3n+1) { width: 92%; } .skel i:nth-child(3n+2) { width: 55%; }
@media (prefers-reduced-motion: no-preference) {
  .skel i { background: linear-gradient(90deg, var(--track) 0%, var(--surface-2) 50%, var(--track) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
}
@keyframes shimmer { to { background-position: -200% 0; } }
.tips p { color: var(--muted); }

/* --- search page ----------------------------------------------------------------------------------------------- */
.searchbar { display: flex; gap: 10px; }
.searchbar .field { position: relative; flex: 1; display: flex; align-items: center; }
.searchbar .field .i { position: absolute; left: 13px; color: var(--muted); pointer-events: none; width: 18px; height: 18px; }
.searchbar input { height: 44px; padding-left: 40px; font-size: 15px; border-radius: 10px; }
.searchbar .btn { height: 44px; padding: 0 20px; }
@media (max-width: 560px) { .searchbar .btn { display: none; } }
.result-sum { color: var(--muted); font-size: 13px; margin-bottom: -10px; }

/* --- drawer (record detail): a side sheet, not the theme's centred dialog --------------------------------------- */
dialog.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(640px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; padding: 0; border: 0; border-radius: 0;
  border-left: 1px solid var(--border); display: flex; flex-direction: column; }
dialog.drawer:not([open]) { display: none; }
.drawer-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 10px 22px; border-bottom: 1px solid var(--border); padding-top: max(10px, env(safe-area-inset-top)); }
.drawer-ref { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 40px; overscroll-behavior: contain; }
.drawer-body h2 { margin: 0 0 6px; font-size: 19px; line-height: 1.35; overflow-wrap: anywhere; }
.drawer-body .subtitle { color: var(--muted); margin-bottom: 14px; }
.drawer-body h3 { margin: 22px 0 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.drawer-body .files { list-style: none; padding: 0; margin: 0; font-family: var(--mono); font-size: 12.5px; display: grid; gap: 3px; overflow-wrap: anywhere; }
.drawer-body .bullets { margin: 0; padding-left: 1.2em; line-height: 1.6; }
.drawer-body .composer { padding: 0; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 13px; margin: 22px 0 0; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.drawer-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.history { list-style: none; margin: 0; padding: 0; font-size: 13px; display: grid; gap: 6px; }
.history time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
@media (max-width: 640px) { dialog.drawer { border-left: 0; } .drawer-body { padding: 16px 16px 32px; } }
@media (prefers-reduced-motion: no-preference) {
  dialog.drawer[open] { animation: drawer-in .2s cubic-bezier(.2, .8, .2, 1); }
  dialog.drawer[open]::backdrop { animation: fade-in .2s ease-out; }
}
@keyframes drawer-in { from { transform: translateX(28px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

/* --- toast: the theme's, faded in and out ------------------------------------------------------------------------ */
.toast { z-index: 70; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.toast[data-show] { opacity: 1; transform: translate(-50%, 0); }

/* --- local LLM page -------------------------------------------------------------------------------------------- */
.updated { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.res { display: grid; gap: 8px; }
.res + .res { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.res-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.res-head b { font-weight: 600; overflow-wrap: anywhere; }
.res-head span { color: var(--muted); font: 12.5px var(--mono); }
.minis { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--muted); }
.minis b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.body > .btns { margin-top: 14px; }
.sub-h { margin: 18px 0 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
@container main (max-width: 820px) { .charts { grid-template-columns: minmax(0, 1fr); } }

/* column charts: HTML, so text stays crisp at every width; one baseline, 2px gaps, 4px rounded data ends */
.colchart { margin: 0; min-width: 0; }
.colchart .legend { padding: 0; }
.sw-1 { background: var(--s1); }
.sw-crit { background: var(--err); }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; margin-bottom: 10px; }
.chart-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.chart-plot { position: relative; height: 160px; margin-left: 44px; border-bottom: 1px solid var(--border); }
.chart-grid span { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); }
.chart-grid i { position: absolute; right: 100%; top: 0; transform: translateY(-50%); padding-right: 8px; font: 11px var(--mono); font-style: normal; color: var(--muted); white-space: nowrap; }
.chart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; }
.chart-cols > div { display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; height: 100%; border-radius: 4px; outline: none; }
.chart-cols > div:hover, .chart-cols > div:focus-visible { background: var(--surface-2); }
.chart-cols i { width: min(24px, 72%); flex: none; }
.chart-cols i:last-child { border-radius: 4px 4px 0 0; }
.chart-x { position: relative; height: 18px; margin: 6px 0 0 44px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-x span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.chart-tip { position: fixed; z-index: 80; pointer-events: none; max-width: 260px; padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 12.5px; line-height: 1.45; box-shadow: var(--pop); white-space: pre-line; }
@container main (max-width: 560px) { .chart-plot, .chart-x { margin-left: 36px; } }
details.as-table { margin-top: 12px; font-size: 13px; }
details.as-table summary { cursor: pointer; color: var(--muted); }
details.as-table summary:hover { color: var(--text); }
.data { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; margin-top: 8px; }
.data th { text-align: left; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 8px 10px; border-block: 1px solid var(--border); white-space: nowrap; }
.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data tr:last-child td { border-bottom: 0; }
.data td.n, .data th.n { text-align: right; }
.scroll-x { overflow-x: auto; }

@media (max-width: 760px) {
  .card > .body { padding-inline: 16px; }
  .qwhy { margin-inline: 16px; }
  .list > li { padding-inline: 16px; }
  .body > .list { margin-inline: -16px; }
  .brand .word, .brand .product { font-size: 15px; }
}
@media (max-width: 420px) { .tools .seg button { padding: 0 6px; } }
.card > .list:first-child > li:first-child { border-top: 0; }
