.brandcard {
  margin: 16px 18px 6px; padding: 12px 16px; border-radius: var(--r-m); background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center; box-shadow: 0 1px 0 rgb(0 0 0 / .03);
}
.brandcard img { display: block; width: 100%; max-width: 210px; height: auto; }
.brand-full { display: var(--show-full); }
.brandmark { display: var(--show-mark); align-items: center; gap: 12px; margin: 16px 18px 6px; }
.brandmark .tile { width: 44px; height: 44px; border-radius: 12px; background: #fff; display: grid; place-items: center; flex: none; padding: 5px; }
.brandmark .tile img { width: 100%; height: 100%; display: block; }
.brandmark .word { font: italic 700 28px/1 var(--f-display); letter-spacing: .01em; }
.brandmark .by { margin-left: auto; font: 600 10px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: right; max-width: 7ch; line-height: 1.3; }
.about { display: none; }
:root[data-theme="dark"] .about { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .about { display: block; } }
.about summary { cursor: pointer; font: 700 11px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); min-height: 32px; display: flex; align-items: center; }
.about .brandcard { margin: 6px 0 4px; }

.sec { padding: 16px 0 18px; border-bottom: 1px dashed var(--line); display: grid; gap: 12px; }
.sec:last-child { border-bottom: 0; }
.sec-h { font: 700 11px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.sec-h .n { color: var(--focus); }
.muted { color: var(--muted); }
.wide { width: 100%; }
.row { display: flex; gap: 8px; }
.row .input { flex: 1; min-width: 0; }
.err { color: var(--bad); font-size: 13px; }

.proj-name { font: italic 600 24px/1.15 var(--f-display); overflow-wrap: anywhere; }
.bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--sunken); border: 1px solid var(--line); }
.bar i { display: block; height: 100%; transition: width .4s var(--ease); }
.bar .s-done { background: var(--ok); } .bar .s-failed { background: var(--bad); } .bar .s-pending { background: var(--pend); opacity: .5; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.tiles div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.tiles dt { font: 600 10px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tiles dd { margin: 2px 0 0; font: 700 22px/1.1 var(--f-display); font-variant-numeric: tabular-nums; }
.meta { font: 12px var(--f-mono); color: var(--muted); }

/* skills */
.skills { display: grid; gap: 8px; }
.skill { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.skill > summary {
  list-style: none; cursor: pointer; padding: 10px 12px; min-height: var(--tap); display: grid; gap: 2px; border-radius: 12px;
}
.skill > summary::-webkit-details-marker { display: none; }
.skill > summary b { font: 600 15px var(--f-display); display: flex; justify-content: space-between; align-items: center; }
.skill > summary b::after { content: "+"; font: 400 18px var(--f-ui); color: var(--muted); }
.skill[open] > summary b::after { content: "–"; }
.skill > summary span { color: var(--muted); font-size: 12.5px; }
.skill form { padding: 4px 12px 12px; display: grid; gap: 10px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.kchip { font: 600 10px var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); border: 1px solid var(--line); border-radius: 99px; padding: 2px 7px 2px 6px; display: inline-flex; align-items: center; gap: 5px; }
.kchip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--kc, var(--muted)); }
.k-text { --kc: var(--k-text); } .k-script { --kc: var(--k-script); } .k-image { --kc: var(--k-image); } .k-video { --kc: var(--k-video); } .k-audio { --kc: var(--k-audio); }

.panel-foot { border-top: 1px solid var(--line); padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 10px; background: var(--panel); }
.who { display: flex; gap: 10px; align-items: center; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: var(--on-grad); font: 700 14px var(--f-ui); text-transform: uppercase; flex: none; }
.who-n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-a { font: 11px var(--f-mono); color: var(--muted); }
.conn { display: inline-flex; align-items: center; gap: 8px; font: 600 12px var(--f-mono); color: var(--muted); margin: 0; }
.conn i { width: 9px; height: 9px; border-radius: 50%; background: var(--pend); flex: none; }
.conn[data-conn="live"] i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.conn[data-conn="down"] i { background: var(--bad); animation: pulse 1.2s ease-in-out infinite; }
.conn[data-conn="connecting"] i { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* inspector */
.ins { display: grid; gap: 14px; padding-top: 14px; }
.ins-empty { padding: 40px 6px; text-align: center; color: var(--muted); display: grid; gap: 8px; }
.ins-empty h2 { font: italic 600 22px var(--f-display); color: var(--ink); }
.ins-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ins-head .id { margin-left: auto; font: 11px var(--f-mono); color: var(--faint); }
.status { font: 600 11px var(--f-mono); letter-spacing: .05em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--pend); }
.status.done::before { background: var(--ok); border-color: var(--ok); } .status.failed { color: var(--bad); border-color: var(--bad); } .status.failed::before { background: var(--bad); border-color: var(--bad); }
.status.running { color: var(--run); border-color: var(--run); } .status.running::before { border-color: var(--run); border-top-color: transparent; animation: spin .8s linear infinite; }
.hint { font-size: 12.5px; color: var(--muted); }
.acts { display: flex; gap: 8px; flex-wrap: wrap; } .acts .btn { flex: 1; }
@media (max-width: 820px) { /* the sheet scrolls: keep Run / Delete pinned at its bottom edge, just above the tab bar */
  .ins > .acts { position: sticky; bottom: calc(-1 * var(--pb)); /* sticky ignores the scroller's bottom padding */ z-index: 1; margin: 0 -18px; padding: 10px 18px; background: var(--panel); border-top: 1px solid var(--line); }
}
.out { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px; display: grid; gap: 8px; min-width: 0; }
.out pre { margin: 0; font: 12.5px/1.5 var(--f-mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }
.out img, .out video { width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; background: var(--sunken); display: block; }
.out audio { width: 100%; }
.out a { color: var(--focus); font-weight: 600; overflow-wrap: anywhere; }
/* A preview that could not load says which path failed and why: a blank box is not an answer. */
.prevfail { display: grid; gap: 3px; padding: 10px 12px; border-radius: var(--r-s); border: 1px dashed var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); color: var(--bad); font-size: 12.5px; }
.prevfail b { font: 600 12.5px var(--f-ui); }
.prevfail code { font: 11.5px/1.4 var(--f-mono); color: var(--ink); overflow-wrap: anywhere; }
.prevmeta { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.prevmeta .kchip { flex: none; }
.prevmeta a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The mock stand-in is always labelled: a [mock ...] output must never read as a real result. */
.mocktag { font: 700 10px var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--on-grad); background: var(--grad); border-radius: 99px; padding: 2px 8px; flex: none; }
.errbox { color: var(--bad); border: 1px solid var(--bad); background: color-mix(in srgb, var(--bad) 9%, var(--surface)); border-radius: var(--r-m); padding: 10px 12px; display: grid; gap: 10px; }
.errtext { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.5 var(--f-mono); user-select: text; }
.errtext.clamped { max-height: 4.6em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.errbox .btn { color: var(--ink); min-height: 34px; padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.links { display: grid; gap: 6px; }
.link { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 2px 4px 2px 10px; min-height: 40px; }
.link-main { flex: 1; min-width: 0; justify-content: flex-start; text-align: left; border: 0; background: none; padding-left: 4px; }
.link-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link .dir { flex: none; font: 600 10px var(--f-mono); color: var(--muted); letter-spacing: .06em; }
.link .role { flex: none; font: 600 10.5px var(--f-mono); color: var(--muted); background: var(--sunken); border-radius: 999px; padding: 3px 8px; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Generation settings form: one row per generic key, with its name, value and remove button. An
   invalid control is outlined in the error colour; the summary names each field and its problem. */
.settings { display: grid; gap: 10px; }
.settings .setrows { display: grid; gap: 6px; }
.settings .setrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 6px; align-items: center; }
.settings [aria-invalid="true"] { border-color: var(--bad); }
.settings .errs { margin: 0; padding-left: 18px; color: var(--bad); font-size: 12.5px; line-height: 1.4; }

/* Provider picker and checks editor: the same grid and error look as the settings form. The verdict
   reads in the ok or bad colour; a check that has not run reads as muted text. */
.provider { display: grid; gap: 10px; }
.provider .errs { margin: 0; padding-left: 18px; color: var(--bad); font-size: 12.5px; line-height: 1.4; }
.provider [aria-invalid="true"] { border-color: var(--bad); }
.provider textarea.input { resize: vertical; font-family: inherit; }
.chk-verdict .hint { margin: 0; }
.chk-verdict.ok > .hint { color: var(--ok); }
.chk-verdict.bad > .hint { color: var(--bad); }

/* Variant picker: a horizontal strip of small cells, one per result. The chosen cell is filled with
   the brand accent and its border is thicker, so "which one is in use" survives greyscale. */
.lblrow { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.varcount { font: 700 11px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.varrow { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin: -2px; scrollbar-width: thin; }
.varrow.busy { opacity: .6; pointer-events: none; }
.varcell {
  flex: none; width: 64px; min-height: 64px; display: grid; place-content: center; justify-items: center; gap: 3px;
  padding: 4px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer;
  color: var(--ink); overflow: hidden;
}
.varcell:hover { border-color: var(--muted); }
.varcell:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.varcell.on { border-width: 2.5px; border-color: var(--focus); background: color-mix(in srgb, var(--a) 12%, var(--surface)); }
.varcell img { width: 100%; height: 40px; object-fit: cover; border-radius: 6px; display: block; background: var(--sunken); }
.varglyph { font: 700 18px/1 var(--f-ui); color: var(--muted); height: 40px; display: grid; place-items: center; }
.varbad { font: 700 16px/1 var(--f-ui); color: var(--bad); height: 40px; display: grid; place-items: center; }
.varname { font: 600 10px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.varcell.on .varname { color: var(--ink); }
.varnote { font-size: 12.5px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 8px; }
.picker { position: relative; }
.picker .listbox { top: auto; bottom: calc(100% + 6px); }

/* output history: previous takes, newest first, each restorable */
.hist-list { display: grid; gap: 8px; margin-top: 2px; max-height: 380px; overflow: auto; }
.hist-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px 8px 8px 10px; }
.hist-body { display: grid; gap: 6px; min-width: 0; }
.hist-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hist-take { font: 600 12px var(--f-mono); letter-spacing: .04em; }
.hist-when { font: 11px var(--f-mono); color: var(--muted); }
.hist-prompt { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.hist-thumb img { display: block; width: 100%; max-width: 180px; max-height: 110px; object-fit: cover; border-radius: 8px; background: var(--sunken); }
.hist-file { font: 12px/1.45 var(--f-mono); overflow-wrap: anywhere; color: var(--ink); }
.hist-restore { min-height: 32px; padding: 4px 10px; font-size: 12.5px; white-space: nowrap; align-self: start; }
.hint.err { color: var(--bad); }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; text-align: left; margin: 14px 0 0; padding-top: 14px; border-top: 1px dashed var(--line); align-items: center; }
.keys dt, .keys dd { margin: 0; } .keys dd { font-size: 13px; }
kbd { font: 600 11px var(--f-mono); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--surface); color: var(--ink); white-space: nowrap; }

/* checkpoints. "Stopped for a person" is --hold (amber): not --run (busy), not --bad (broken),
   not --pend (not started) and not the brand accent (selected). */
.status.hold { color: var(--hold); border-color: var(--hold); }
.status.hold::before { border-color: var(--hold); background: var(--hold); }
.status.gate { color: var(--hold); border-color: color-mix(in srgb, var(--hold) 55%, var(--line)); }
.status.gate::before { border-color: var(--hold); background: transparent; }
.btn.hold { color: var(--hold); border-color: var(--hold); }
.btn.hold:hover { border-color: var(--hold); background: color-mix(in srgb, var(--hold) 10%, var(--surface)); }
.btn.hold:not([disabled]) { font-weight: 700; }
.ckpt { display: grid; gap: 6px; }
.ckpt-main { display: flex; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; font-size: 14px; }
.ckpt-main b { font-weight: 600; }
.ckpt .acts { margin-top: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; width: 38px; height: 22px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--sunken); cursor: pointer; position: relative;
  transition: background .15s, border-color .15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); transition: transform .15s var(--ease), border-color .15s;
}
.switch:checked { background: color-mix(in srgb, var(--hold) 22%, var(--surface)); border-color: var(--hold); }
.switch:checked::after { transform: translateX(16px); background: var(--hold); border-color: var(--hold); }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* comments (inspector) */
.cmsec { border-top: 1px dashed var(--line); padding-top: 12px; }
.cmhead-row { display: flex; align-items: center; gap: 8px; }
.cmcount { font: 700 11px var(--f-mono); color: var(--on-grad); background: var(--a); border-radius: 99px; padding: 1px 8px; min-width: 22px; text-align: center; }
.cmcount:empty { display: none; }
.cmlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cmitem { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 4px; cursor: default; }
.cmitem.none { background: none; border: 0; padding: 0; cursor: default; }
.cmitem.resolved { opacity: .62; }
.cmitem.hl { border-color: var(--a); box-shadow: 0 0 0 1px var(--a); }
.cmrow { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.cno { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font: 700 10px var(--f-mono); color: var(--on-grad); background: var(--a); }
.cmitem.resolved .cno { background: var(--pend); color: var(--panel); }
.cmeta { flex: 1; min-width: 0; font: 11px var(--f-mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctext { font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; margin: 0; }
.cmform { display: grid; gap: 8px; margin-top: 4px; }
.cmform textarea { min-height: 74px; }
.btn.tiny { min-height: 30px; padding: 2px 10px; font-size: 12.5px; flex: none; }
.cmregion { display: flex; align-items: center; gap: 6px; background: color-mix(in srgb, var(--a) 12%, var(--surface)); border: 1px solid var(--a); border-radius: 8px; padding: 2px 2px 2px 10px; }
.cmregion-t { flex: 1; font: 600 11px var(--f-mono); color: var(--ink); }
.cmregion .icon-btn { width: 30px; height: 30px; }

/* region selection on an image preview. The wrapper shrink-wraps the image, and the image keeps
   its own aspect (both dimensions auto), so the image BOX is the painted picture: no letterboxing,
   and the overlay can simply be `inset: 0` — a fraction of it is a fraction of the picture. */
.imgwrap { position: relative; display: block; width: fit-content; max-width: 100%; min-width: 0; margin: 0 auto; }
.imgwrap > img { display: block; width: auto; height: auto; max-width: 100%; max-height: 300px; border-radius: 8px; background: var(--sunken); user-select: none; -webkit-user-select: none; }
.rgn-layer { position: absolute; inset: 0; cursor: crosshair; touch-action: none; border-radius: 8px; }
.rgn { position: absolute; border: 1.5px solid var(--a); border-radius: 2px; box-shadow: 0 0 0 1px rgb(0 0 0 / .35); pointer-events: none; }
.rgn.resolved { border-color: var(--pend); border-style: dashed; opacity: .75; }
.rgn.hl { border-width: 2.5px; box-shadow: 0 0 0 2px rgb(0 0 0 / .45), 0 0 0 4px color-mix(in srgb, var(--a) 45%, transparent); }
.rgn.drawing { border-style: dashed; background: color-mix(in srgb, var(--a) 14%, transparent); }
.rgn-no {
  position: absolute; left: -8px; top: -8px; width: 18px; height: 18px; border-radius: 50%; font: 700 10px/18px var(--f-mono);
  font-style: normal; text-align: center; color: var(--on-grad); background: var(--a); border: 1px solid var(--panel);
}
.rgn.resolved .rgn-no { background: var(--pend); color: var(--panel); }
