/* Studio Console components. Reference markup for every class lives at /_styleguide.
   Semantic colour is never alone: sage/apricot/brick always ship with a word and an icon. */

/* Buttons */
.btn { --b: var(--edge); --bg: transparent; --fg: var(--ink); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--control); padding: 0 var(--s3); border: 1px solid var(--b); border-radius: var(--radius); background: var(--bg); color: var(--fg);
  font-weight: 500; font-size: var(--fs-small); line-height: 1.2; text-decoration: none; white-space: nowrap; user-select: none; -webkit-user-select: none;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease); }
.btn:hover { background: color-mix(in oklab, var(--ink) 7%, var(--bg)); }
.btn:active { background: color-mix(in oklab, var(--ink) 13%, var(--bg)); }
.btn .icon { margin-left: -2px; }
.btn[aria-pressed="true"] { background: var(--press); --b: var(--ink); z-index: 1; }
.btn-primary { --bg: var(--ink); --fg: var(--ground); --b: var(--ink); }
.btn-primary:hover { background: color-mix(in oklab, var(--ink) 86%, var(--ground)); }
.btn-primary:active { background: color-mix(in oklab, var(--ink) 76%, var(--ground)); }
.btn-free { --bg: var(--free-ground); --b: var(--free); } .btn-free .icon { color: var(--free); }
.btn-money { --bg: var(--money-ground); --b: var(--money); } .btn-money .icon { color: var(--money); }
.btn-stop { --bg: var(--stop-ground); --b: var(--stop); } .btn-stop .icon { color: var(--stop); }
.btn-ghost { --b: transparent; --fg: var(--muted); } .btn-ghost:hover { color: var(--ink); }
.btn-sm { min-height: 28px; padding: 0 var(--s2); font-size: var(--fs-micro); gap: 6px; }
.btn-lg { min-height: 44px; padding: 0 var(--s4); font-size: var(--fs-body); }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: var(--control); padding: 0; } .btn-icon .icon { margin: 0; }
@media (pointer: coarse) { .btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-small); } }
/* The ~$ amount slot: a ruled-off mono cell at the trailing edge of a money button. */
.btn-amt { align-self: stretch; display: inline-flex; align-items: center; margin: 0 calc(-1 * var(--s3)) 0 var(--s1); padding: 0 var(--s3); border-left: 1px solid var(--b);
  font: 500 var(--fs-small)/1 var(--mono); font-variant-numeric: tabular-nums; }
.btn-lg .btn-amt { margin-right: calc(-1 * var(--s4)); padding: 0 var(--s4); }
.btn:disabled, .btn[aria-disabled="true"] { --b: var(--rule); --bg: transparent; --fg: var(--muted); cursor: not-allowed; background: transparent; }
.btn:disabled .icon, .btn[aria-disabled="true"] .icon { color: inherit; }
.btn[aria-busy="true"] { cursor: progress; pointer-events: none; color: transparent; }
.btn[aria-busy="true"] > * { visibility: hidden; }
.btn[aria-busy="true"]::after { content: "Working"; color: var(--fg); position: absolute; inset: 0; display: grid; place-items: center; font: 500 var(--fs-micro)/1 var(--mono); letter-spacing: var(--track-label); text-transform: uppercase; animation: sc-pulse 1.2s steps(2, end) infinite; }
@keyframes sc-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .btn[aria-busy="true"]::after { animation: none; } }
.btn-group { display: inline-flex; } .btn-group .btn { border-radius: 0; margin-left: -1px; } .btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; } .btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn:focus-visible { z-index: 1; }

/* <sc-hold-button> */
sc-hold-button { display: inline-flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
sc-hold-button[block] { display: flex; } sc-hold-button[block] .btn { flex: 1; }
sc-hold-button .btn { overflow: hidden; touch-action: none; }
sc-hold-button .hold-fill { position: absolute; inset: 0; transform-origin: left; transform: scaleX(0); background: color-mix(in oklab, var(--b) 34%, transparent); pointer-events: none; }
sc-hold-button .btn > :not(.hold-fill) { position: relative; }
sc-hold-button[holding] .hold-fill { transform: scaleX(1); transition: transform var(--hold, 800ms) linear; }
sc-hold-button .hold-hint { font-size: var(--fs-small); color: var(--muted); }

/* Chips, labels, money */
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 1px 7px; border: 1px solid var(--rule); border-radius: var(--radius-chip); background: var(--raised);
  font-size: var(--fs-micro); font-weight: 500; line-height: 1.2; letter-spacing: .01em; white-space: nowrap; color: var(--ink); text-decoration: none; }
.chip .icon { width: 12px; height: 12px; stroke-width: 2; }
.chip-ok { background: var(--free-ground); border-color: var(--free); } .chip-ok .icon { color: var(--free); }
.chip-warn { background: var(--money-ground); border-color: var(--money); } .chip-warn .icon { color: var(--money); }
.chip-stop { background: var(--stop-ground); border-color: var(--stop); } .chip-stop .icon { color: var(--stop); }
.chip-muted { background: transparent; color: var(--muted); }
button.chip, a.chip, label.chip { cursor: pointer; min-height: 28px; padding-inline: 10px; }
button.chip:hover, a.chip:hover, label.chip:hover { border-color: var(--edge); }
.chip[aria-pressed="true"], label.chip:has(:checked) { background: var(--ink); color: var(--ground); border-color: var(--ink); }
label.chip input { position: absolute; opacity: 0; pointer-events: none; } label.chip:has(:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
@media (pointer: coarse) { button.chip, a.chip, label.chip { min-height: 36px; padding-inline: var(--s3); font-size: var(--fs-small); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.label { font-size: var(--fs-micro); font-weight: 500; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); line-height: 1.3; }
.money { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.money-spend { color: var(--money-ink); } .money-over { color: var(--stop-ink); }
.tally { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s6); }
.tally > div { display: flex; flex-direction: column; gap: 2px; }
.tally dt { font-size: var(--fs-micro); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); }
.tally dd { font: 500 1.375rem/1.15 var(--mono); font-variant-numeric: tabular-nums; }
kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; vertical-align: 1px; padding: 0 5px; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 3px; background: var(--raised); color: var(--muted); font-size: .6875rem; line-height: 1; }

/* Cards, spec slate, flag, banner, empty */
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--rule); }
.card-money { border-left: 2px solid var(--money); } .card-stop { border-left: 2px solid var(--stop); } .card-free { border-left: 2px solid var(--free); }
a.card { text-decoration: none; } a.card:hover { border-color: var(--edge); }
.spec { background: var(--slate); color: var(--slate-ink); border-radius: var(--radius); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.spec .label, .spec dt { color: var(--slate-muted); }
.spec dl, dl.spec { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px var(--s4); font: 400 var(--fs-small)/1.45 var(--mono); font-variant-numeric: tabular-nums; }
.spec dl + dl, .spec > * + dl { border-top: 1px solid var(--slate-rule); padding-top: var(--s3); }
.spec dt { font-size: var(--fs-micro); letter-spacing: var(--track-label); text-transform: uppercase; padding-top: 2px; white-space: nowrap; }
.spec dd { overflow-wrap: anywhere; min-width: 0; }
.flag { border-left: 2px solid var(--money); padding: 1px 0 1px var(--s3); font-size: var(--fs-small); color: var(--muted); }
.flag b, .flag strong { color: var(--ink); font-weight: 600; }
.spec .flag { color: var(--slate-muted); } .spec .flag b { color: var(--slate-ink); }
.flag-stop { border-left-color: var(--stop); }
.banner { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); font-size: var(--fs-small); }
.banner .icon { margin-top: 2px; } .banner b { font-weight: 600; }
.banner-critical { background: var(--stop-ground); border-color: var(--stop); } .banner-critical .icon { color: var(--stop); }
.banner-money { background: var(--money-ground); border-color: var(--money); } .banner-money .icon { color: var(--money); }
.banner-free { background: var(--free-ground); border-color: var(--free); } .banner-free .icon { color: var(--free); }
.banner-page { border-width: 0 0 1px; border-radius: 0; justify-content: center; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s6) var(--s5); border: 1px dashed var(--edge); border-radius: var(--radius); color: var(--muted); }
.empty h3 { color: var(--ink); } .empty .icon { width: 20px; height: 20px; color: var(--faint); margin-bottom: var(--s1); } .empty .btn { margin-top: var(--s2); }

/* Tabs */
.tabs { display: flex; gap: var(--s4); border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > a, .tabs > button { position: relative; display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--control); padding: 0 2px; color: var(--muted); font-weight: 500; font-size: var(--fs-small); text-decoration: none; white-space: nowrap; }
.tabs > :hover { color: var(--ink); }
.tabs > [aria-current="page"], .tabs > [aria-selected="true"] { color: var(--ink); }
.tabs > [aria-current="page"]::after, .tabs > [aria-selected="true"]::after { content: ""; position: absolute; inset: auto 0 -1px; height: 2px; background: var(--ink); }
.tabs > :focus-visible { outline-offset: -3px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.table { width: 100%; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.table th { height: var(--row); padding: 0 var(--s3); text-align: left; font-size: var(--fs-micro); font-weight: 500; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); background: var(--panel); border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table td { height: var(--row); padding: 0 var(--s3); border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--hover); }
.table .r, .table .money { text-align: right; }
.table td.money, .table td.mono { font-family: var(--mono); }
.table td.wrap-cell { white-space: normal; padding-block: var(--s2); }
.table tfoot td { border-top: 1px solid var(--edge); border-bottom: 0; font-weight: 600; }
.table th[aria-sort] { cursor: pointer; } .table th[aria-sort="ascending"]::after { content: " ↑"; } .table th[aria-sort="descending"]::after { content: " ↓"; }

/* Budget meter: spent / to buy / ceiling */
.bar { display: flex; flex-direction: column; gap: var(--s2); }
.bar-track { position: relative; display: flex; height: 10px; background: var(--raised); border: 1px solid var(--rule); border-radius: 2px; }
.bar-track > span { height: 100%; width: var(--v, 0%); min-width: 0; }
.bar-spent { background: var(--muted); }
.bar-buy { background: var(--money); border-left: 1px solid var(--ground); }
.bar-ceiling { position: absolute; top: -4px; bottom: -4px; left: var(--at, 100%); width: 2px !important; height: auto !important; background: var(--ink); }
.bar[data-over] .bar-buy { background: var(--stop); }
.bar[data-over] .bar-track { border-color: var(--stop); }
.bar-legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--fs-small); color: var(--muted); }
.bar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bar-legend b { font: 500 var(--fs-small)/1 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-legend i { width: 8px; height: 8px; border-radius: 1px; background: var(--muted); }
.bar-legend .k-buy i { background: var(--money); } .bar-legend .k-ceiling i { width: 2px; height: 12px; background: var(--ink); } .bar[data-over] .bar-legend .k-buy i { background: var(--stop); }

/* Pipeline strip: brief → prompts → stills → gate → video → audio → QA → delivered */
.pipeline { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.pipeline li { position: relative; display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3); min-width: 0; border-left: 1px solid var(--rule); color: var(--muted); }
.pipeline li:first-child { border-left: 0; }
.pipeline .stage { display: flex; align-items: center; gap: 6px; font-size: var(--fs-small); font-weight: 500; white-space: nowrap; }
.pipeline .stage .icon { width: 14px; height: 14px; }
.pipeline .detail { font: 400 var(--fs-micro)/1.3 var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline [data-state="done"] { color: var(--ink); } .pipeline [data-state="done"] .icon { color: var(--free); }
.pipeline [data-state="active"] { color: var(--ink); background: var(--raised); box-shadow: inset 0 -2px 0 var(--ink); }
.pipeline [data-state="waiting"] { color: var(--ink); background: var(--money-ground); box-shadow: inset 0 -2px 0 var(--money); } .pipeline [data-state="waiting"] .icon { color: var(--money); }
.pipeline [data-state="stuck"] { color: var(--ink); background: var(--stop-ground); outline: 2px solid var(--stop); outline-offset: -2px; }
.pipeline [data-state="stuck"] .icon { color: var(--stop); } .pipeline [data-state="stuck"] .stage { text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.pipeline [data-state="todo"] .icon { color: var(--faint); }
.pipeline [data-state="na"] .stage span { text-decoration: line-through; } .pipeline [data-state="na"] .icon { color: var(--faint); }
.pipeline-sm li { padding: 6px var(--s2); } .pipeline-sm .detail { display: none; }
@media (max-width: 760px) {
  .pipeline { display: flex; }
  .pipeline li { flex: 0 0 auto; padding-inline: 6px; justify-content: center; }
  .pipeline .stage span:not(.visually-hidden) { overflow: hidden; text-overflow: ellipsis; }
  .pipeline li:is([data-state="active"], [data-state="waiting"], [data-state="stuck"]) { flex: 1 1 0; padding-inline: 10px; }
  .pipeline li:not([data-state="active"], [data-state="waiting"], [data-state="stuck"]) :is(.stage span, .detail) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* Media tiles — no skeletons: the lqip is the placeholder. Grids never contain <video>. */
.tiles { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fill, minmax(min(46%, 200px), 1fr)); }
.tile { position: relative; display: block; aspect-ratio: var(--ar, 1); overflow: hidden; border-radius: var(--radius); background: var(--slate) var(--lqip, none) center / cover no-repeat; color: var(--slate-ink); text-decoration: none; isolation: isolate; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile::after { content: ""; position: absolute; inset: 0; border: 1px solid color-mix(in oklab, var(--slate-ink) 14%, transparent); border-radius: inherit; pointer-events: none; }
.tile:hover::after { border-color: color-mix(in oklab, var(--slate-ink) 55%, transparent); }
.tile:focus-visible { outline-offset: 2px; }
.tile[aria-selected="true"]::after, .tile.is-current::after { border: 2px solid var(--focus); }
.tile-tag { position: absolute; display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 5px; border-radius: var(--radius-chip); background: color-mix(in oklab, var(--slate) 82%, transparent); color: var(--slate-ink);
  font: 500 .6875rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.tile-tag .icon { width: 12px; height: 12px; stroke-width: 2; }
.tile-kind { left: 6px; bottom: 6px; } .tile-stack { right: 6px; bottom: 6px; } .tile-notes { right: 6px; top: 6px; }
.tile-verdict { left: 6px; top: 6px; background: var(--slate); border: 1px solid var(--slate-rule); font-family: var(--sans); letter-spacing: .02em; }
.tile[data-verdict="approved"] .tile-verdict { border-color: var(--free); } .tile[data-verdict="approved"] .tile-verdict .icon { color: var(--free); }
.tile[data-verdict="rejected"] .tile-verdict { border-color: var(--stop); } .tile[data-verdict="rejected"] .tile-verdict .icon { color: var(--stop); }
.tile:is([data-verdict="rejected"], [data-verdict="not_selected"]) img { opacity: .38; filter: grayscale(1); }
.tile-name { position: absolute; inset: auto 0 0; padding: 6px 8px 30px; font-size: var(--fs-micro); opacity: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: color-mix(in oklab, var(--slate) 70%, transparent); transition: opacity var(--fast); }
.tile:is(:hover, :focus-visible) .tile-name { opacity: 1; }
.tile-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: var(--s3); text-align: center; font-size: var(--fs-small); color: var(--slate-muted); }
.tile-state b { color: var(--slate-ink); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.tile-state .detail { font: 400 var(--fs-micro)/1.35 var(--mono); max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tile-blank { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: var(--s3) var(--s3) 28px; text-align: center; color: var(--slate-muted); background: color-mix(in oklab, var(--slate) 62%, transparent); }
.tile-blank .icon { width: 24px; height: 24px; stroke-width: 1.5; color: var(--slate-ink); }
.tile-blank-name { max-width: 100%; font-size: var(--fs-small); font-weight: 500; color: var(--slate-ink); overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-blank .detail { font: 400 var(--fs-micro)/1.35 var(--mono); font-variant-numeric: tabular-nums; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile:is([data-verdict="rejected"], [data-verdict="not_selected"]) .tile-blank { opacity: .5; }
.tile[data-state] { background-image: none; }
.tile[data-state="submitted"]::after { border-style: dashed; border-color: var(--slate-muted); }
.tile[data-state="submitted"] .tile-state .icon { animation: sc-spin 2.4s linear infinite; }
.tile[data-state="failed"] { background-color: var(--stop-ground); color: var(--ink); } .tile[data-state="failed"]::after { border-color: var(--stop); }
.tile[data-state="failed"] .tile-state { color: var(--muted); } .tile[data-state="failed"] .tile-state b { color: var(--ink); } .tile[data-state="failed"] .tile-state .icon { color: var(--stop); }
@keyframes sc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tile[data-state="submitted"] .tile-state .icon { animation: none; } }

/* Form controls */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label-text, legend { font-size: var(--fs-small); font-weight: 500; padding: 0; }
.hint { font-size: var(--fs-small); color: var(--muted); }
.error { font-size: var(--fs-small); color: var(--stop-ink); display: flex; gap: 6px; align-items: flex-start; } .error .icon { color: var(--stop); margin-top: 2px; } .error:empty { display: none; }
.input, .select, .textarea { width: 100%; min-height: var(--control); padding: 0 var(--s3); background: var(--raised); border: 1px solid var(--edge); border-radius: var(--radius); font-size: var(--fs-body); }   /* tokens make this 16px on touch, which stops iOS zooming on focus */
.textarea { padding-block: var(--s2); min-height: 88px; line-height: 1.5; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline-offset: 1px; border-color: var(--ink); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--stop); }
.input:disabled, .select:disabled, .textarea:disabled { color: var(--muted); border-color: var(--rule); background: transparent; cursor: not-allowed; }
.select { appearance: none; padding-right: var(--s6); background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(-45deg, transparent 50%, var(--muted) 50%); background-size: 5px 5px; background-position: right 15px center, right 10px center; background-repeat: no-repeat; }
.check { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--control); cursor: pointer; font-size: var(--fs-body); }
.check input { appearance: none; width: 16px; height: 16px; margin: 0; flex: none; border: 1px solid var(--edge); border-radius: 2px; background: var(--raised); display: grid; place-items: center; cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { content: ""; width: 8px; height: 4px; border: solid var(--ground); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"]:checked::after { width: 6px; height: 6px; border: 0; border-radius: 50%; background: var(--ground); transform: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: var(--control); cursor: pointer; }
.switch input { appearance: none; position: relative; flex: none; width: 34px; height: 20px; margin: 0; border: 1px solid var(--edge); border-radius: 10px; background: var(--raised); cursor: pointer; transition: background var(--fast); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform var(--fast) var(--ease); }
.switch input:checked { background: var(--ink); border-color: var(--ink); } .switch input:checked::after { transform: translateX(14px); background: var(--ground); }
.switch-state { font: 500 var(--fs-micro)/1 var(--mono); text-transform: uppercase; letter-spacing: var(--track-label); color: var(--muted); margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: var(--radius); padding: 2px; gap: 2px; background: var(--raised); max-width: 100%; }
.seg label { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: calc(var(--control) - 6px); padding: 0 var(--s3); border-radius: 2px; font-size: var(--fs-small); font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(:checked) { background: var(--ink); color: var(--ground); }
.seg label:has(:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: var(--s2); }
.setting { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); padding: var(--s4) 0; border-bottom: 1px solid var(--rule); align-items: center; }
.setting:last-child { border-bottom: 0; }
.setting h3 { font-size: var(--fs-body); } .setting p { color: var(--muted); font-size: var(--fs-small); margin-top: 2px; }
@media (min-width: 640px) { .setting { grid-template-columns: minmax(0, 1fr) auto; gap: var(--s6); } }

/* Dialog, bottom sheet, menu */
dialog { color: var(--ink); }
.dialog, .sheet { padding: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); width: min(calc(100vw - 2 * var(--s4)), var(--w, 480px)); max-height: min(86dvh, 720px); overflow: hidden; }
.dialog[open], .sheet[open] { display: flex; flex-direction: column; }
.dialog::backdrop, .sheet::backdrop { background: var(--scrim); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s4); border-bottom: 1px solid var(--rule); }
.dialog-head h2 { font: 600 var(--fs-lead)/1.3 var(--sans); letter-spacing: 0; }
.dialog-body { padding: var(--s4); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--s4); }
.dialog-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--rule); }
/* .sheet: a centred dialog on desktop, a bottom sheet on phones. */
@media (max-width: 640px) {
  .sheet { margin: auto 0 0; width: 100vw; max-width: none; max-height: 88dvh; border-width: 1px 0 0; border-radius: 8px 8px 0 0; padding-bottom: var(--safe-b); }
  .sheet::before { content: ""; flex: none; align-self: center; width: 36px; height: 4px; margin-top: var(--s2); border-radius: 2px; background: var(--rule); }
  .sheet[open] { animation: sc-sheet var(--slow) var(--ease); }
  .sheet .dialog-foot .btn { flex: 1; }
}
@keyframes sc-sheet { from { transform: translateY(24px); opacity: 0; } }
.menu { position: fixed; inset: auto; margin: 0; min-width: 200px; max-width: min(320px, calc(100vw - 2 * var(--s2))); padding: var(--s1); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--raised); color: var(--ink); }
.menu > :is(a, button) { display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: var(--row); padding: 0 var(--s2); border-radius: 2px; font-size: var(--fs-small); text-align: left; text-decoration: none; }
.menu > :is(a, button):hover, .menu > :is(a, button):focus-visible { background: var(--press); outline: none; }
.menu > :is(a, button) .icon { color: var(--muted); } .menu .menu-stop .icon { color: var(--stop); } .menu .menu-money .icon { color: var(--money); }
.menu > :is(a, button) .money, .menu > :is(a, button) kbd { margin-left: auto; }
.menu hr { margin: var(--s1) calc(-1 * var(--s1)); } .menu .label { padding: var(--s2) var(--s2) var(--s1); }
.navlist { display: flex; flex-direction: column; }
.navlist a, .navlist button { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: 0 var(--s1); border-bottom: 1px solid var(--rule); text-decoration: none; font-size: var(--fs-body); width: 100%; text-align: left; }
.navlist > :last-child { border-bottom: 0; } .navlist .icon { color: var(--muted); }

/* Command palette + keymap */
.palette { --w: 600px; margin-top: 12dvh; }
.palette-input { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4); border-bottom: 1px solid var(--rule); color: var(--muted); }
.palette-input input { flex: 1; min-width: 0; height: 48px; border: 0; background: none; outline: none; font-size: 1rem; color: var(--ink); }
.palette-list { overflow-y: auto; padding: var(--s1); min-height: 80px; max-height: 50dvh; }
.palette-list .label { padding: var(--s3) var(--s3) var(--s1); }
.palette-item { display: flex; align-items: center; gap: var(--s3); min-height: var(--control); padding: 0 var(--s3); border-radius: 2px; text-decoration: none; font-size: var(--fs-small); }
.palette-item .icon { color: var(--muted); } .palette-item .mono { margin-left: auto; color: var(--muted); font-size: var(--fs-micro); }
.palette-item[aria-selected="true"] { background: var(--press); }
.palette-none { padding: var(--s4) var(--s3); color: var(--muted); font-size: var(--fs-small); }
.keymap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2) var(--s5); font-size: var(--fs-small); align-items: center; }
.keymap dd { display: flex; gap: var(--s1); justify-content: flex-end; } .keymap .label { grid-column: 1 / -1; padding-top: var(--s2); }

/* Toasts */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: calc(var(--s4) + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: var(--s2); width: min(calc(100vw - 2 * var(--s4)), 440px); pointer-events: none; }
body:has(.tabbar):not(.bleed) .toasts { bottom: calc(var(--tabbar) + var(--s3) + var(--safe-b)); }
@media (min-width: 900px) { body:has(.tabbar):not(.bleed) .toasts { bottom: var(--s5); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s3); max-width: 100%; min-height: 40px; padding: 6px 6px 6px var(--s3); background: var(--ink); color: var(--ground); border-radius: var(--radius); font-size: var(--fs-small); animation: sc-toast var(--slow) var(--ease); }
.toast-msg { padding-block: 4px; }
.toast .icon { flex: none; }
.toast button { flex: none; min-height: 28px; padding: 0 var(--s2); border-radius: 2px; font-weight: 600; color: inherit; border: 1px solid color-mix(in oklab, var(--ground) 40%, transparent); }
.toast button:hover { background: color-mix(in oklab, var(--ground) 14%, transparent); }
.toast button:focus-visible { outline-color: var(--ground); outline-offset: 1px; }
.toast .toast-x { border: 0; width: 28px; padding: 0; display: grid; place-items: center; }
.toast[data-tone="stop"] { background: var(--stop-ground); color: var(--ink); border: 1px solid var(--stop); } .toast[data-tone="stop"] .icon:first-child { color: var(--stop); }
.toast[data-tone="stop"] button { border-color: var(--edge); }
@media (pointer: coarse) { .toast button { min-height: 36px; padding-inline: var(--s3); } .toast .toast-x { width: 36px; } }
@keyframes sc-toast { from { transform: translateY(8px); opacity: 0; } }

/* iOS install coach */
.coach { position: fixed; z-index: 80; left: var(--s3); right: var(--s3); bottom: calc(var(--tabbar) + var(--s3) + var(--safe-b)); display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s3) var(--s3) var(--s4); background: var(--raised); border: 1px solid var(--edge); border-radius: var(--radius); font-size: var(--fs-small); }
.coach p { color: var(--muted); } .coach b { color: var(--ink); font-weight: 600; } .coach .icon { display: inline; vertical-align: -3px; }

/* Settings list */
.card-list { padding-block: 0; gap: 0; }
.steps { margin-top: var(--s2); display: flex; flex-direction: column; gap: var(--s1); font-size: var(--fs-small); color: var(--muted); }
.steps b { color: var(--ink); font-weight: 500; } .steps .icon { display: inline; vertical-align: -3px; }
