/* ==========================================================================
   TestPilot design system
   Neo-brutalist: paper + ink, 2px edges, hard offset shadows (on panels and
   buttons only), pastel fills that always MEAN something:
     mint = passed · coral = failed / major · butter = running / warning
     lavender = queued / focus · sky = info / links · lime = brand / primary
   Type: Bricolage Grotesque (display) · IBM Plex Sans (text) · IBM Plex Mono (data)
   ========================================================================== */

@font-face { font-family: "Bricolage"; src: url("/static/font-display.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/font-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/font-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/font-sans-600.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/static/font-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/static/font-mono-500.woff2") format("woff2"); font-weight: 500 700; font-display: swap; }

/* ---------- tokens ---------- */
:root {
  --font-display: "Bricolage", "Plex Sans", system-ui, sans-serif;
  --font-text: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* pastel palette (same hues in both themes; text on them is always --on-pastel) */
  --lime: #d4f28a; --lime-strong: #b9e05a;
  --mint: #b8ecc9; --coral: #ffb3a3; --butter: #ffe48f; --lavender: #d3c8ff; --sky: #b9e0ff; --peach: #ffd2b0;
  --on-pastel: #17161c;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --r-sm: 4px; --r: 6px; --r-lg: 10px;
  --edge-w: 2px;
  --shadow-x: 4px;
  --t-fast: 120ms; --t: 220ms; --ease: cubic-bezier(.2, .8, .2, 1); --ease-back: cubic-bezier(.3, 1.4, .5, 1);
  --side-w: 248px;
}
[data-theme="light"] {
  --paper: #f6f2ea; --paper-2: #ede7db; --surface: #fffdf8; --surface-2: #f8f4ec;
  --ink: #17161c; --ink-2: #4c4955; --ink-3: #75717d;
  --edge: #17161c; --line: #dcd5c7; --shadow: #17161c;
  --focus: #7c5cff; --link: #2b59c3; --bad-text: #a3261b; --ok-text: #136a3a; --warn-text: #7a5300;
  color-scheme: light;
}
[data-theme="dark"] {
  --paper: #121115; --paper-2: #18171c; --surface: #1d1c22; --surface-2: #24232a;
  --ink: #f2efe8; --ink-2: #c3bfca; --ink-3: #9893a1;
  --edge: #e8e3d8; --line: #34323b; --shadow: #000;
  --focus: #b8a6ff; --link: #93c2ff; --bad-text: #ff9f8c; --ok-text: #8fe0ad; --warn-text: #ffd66b;
  --lime: #cdec7f; --mint: #a8e2bb; --coral: #ffa391; --butter: #f7da7c; --lavender: #c6b9ff; --sky: #a9d6fb; --peach: #ffc69c;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--font-text); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body.booting .shell { visibility: hidden; }
::selection { background: var(--lime); color: var(--on-pastel); }
h1, h2, h3 { font-family: var(--font-display); color: var(--ink); line-height: 1.1; letter-spacing: -0.02em; }
h1 { font-size: clamp(28px, 3.2vw, 40px); font-weight: 800; margin: 0; }
h2 { font-size: 21px; font-weight: 750; margin: 0 0 var(--s3); }
h3 { font-size: 16px; font-weight: 700; margin: 0 0 var(--s2); letter-spacing: -0.01em; }
p { margin: 0 0 var(--s3); }
a { color: var(--link); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2.5px; }
code, pre, .mono, .url, kbd { font-family: var(--font-mono); font-size: 13px; }
.url, .mono { word-break: break-all; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 1px 5px; }
pre { margin: 0; white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--lime); color: var(--on-pastel); padding: 8px 12px; border: var(--edge-w) solid var(--edge); font-weight: 600; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-3); font-size: 13px; }
.eyebrow { font: 500 11px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); margin: 0 0 var(--s2); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
svg.i.sm { width: 15px; height: 15px; vertical-align: -2px; } svg.i.lg { width: 22px; height: 22px; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
body.is-auth .shell { grid-template-columns: minmax(0, 1fr); }
body.is-auth .side, body.is-auth .top { display: none; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--paper-2); border-right: var(--edge-w) solid var(--edge); display: flex; flex-direction: column; padding: var(--s4) var(--s3); gap: var(--s4); }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 800 20px/1 var(--font-display); letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; background: var(--lime); color: var(--on-pastel); border: var(--edge-w) solid var(--edge); border-radius: var(--r); box-shadow: 2px 2px 0 var(--shadow); font: 800 14px/1 var(--font-display); letter-spacing: -0.04em; }
.side .brand { padding: 2px 6px 6px; }
.org-switch { display: grid; gap: 4px; padding: 0 4px; }
.org-switch label { font: 500 11px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }
.org-switch select { width: 100%; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-list a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: var(--edge-w) solid transparent; border-radius: var(--r); color: var(--ink-2); text-decoration: none; font-weight: 500; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast); }
.nav-list a:hover { background: var(--surface); color: var(--ink); }
.nav-list a[aria-current="page"] { background: var(--lime); color: var(--on-pastel); border-color: var(--edge); box-shadow: 2px 2px 0 var(--shadow); font-weight: 600; }
.nav-sep { height: 0; border-top: 1px solid var(--line); margin: var(--s2) 6px; }
.side-foot { margin-top: auto; display: grid; gap: var(--s2); padding: var(--s3) 4px 0; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--ink-2); }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.col { min-width: 0; display: flex; flex-direction: column; }
.top { display: none; position: sticky; top: 0; z-index: 30; align-items: center; gap: var(--s3); padding: 10px var(--s4); background: var(--paper); border-bottom: var(--edge-w) solid var(--edge); }
.top-spacer { flex: 1; }
#nav { display: flex; align-items: center; gap: var(--s2); }
main { width: 100%; max-width: 1180px; margin: 0 auto; padding: var(--s6) var(--s6) var(--s8); outline: none; }
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 14, .45); z-index: 40; }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s6); }
.page-head .titles { min-width: 0; }
.page-head .sub { margin: var(--s2) 0 0; color: var(--ink-2); max-width: 64ch; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: var(--s3); font-weight: 500; color: var(--ink-2); text-decoration: none; }
.back:hover { color: var(--ink); }

/* ---------- layout ---------- */
.stack { display: grid; gap: var(--s5); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.spread { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }

/* ---------- panels (the one "card" style: used for real sections, not decoration) ---------- */
.panel, .card { background: var(--surface); border: var(--edge-w) solid var(--edge); border-radius: var(--r-lg); box-shadow: var(--shadow-x) var(--shadow-x) 0 var(--shadow); padding: var(--s5); min-width: 0; }
.card { margin: 0 0 var(--s4); box-shadow: 3px 3px 0 var(--shadow); padding: var(--s4); }
.panel > h2:first-child, .panel > .panel-head:first-child { margin-top: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.panel-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.panel-head h2 .count { font: 500 13px/1 var(--font-mono); color: var(--ink-3); }
.panel.flat { box-shadow: none; }
.panel.tinted { background: var(--surface-2); }
section + section { margin-top: 0; }

/* ---------- buttons ---------- */
button, .btn { --bg: var(--surface); font: 600 14px/1 var(--font-text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  color: var(--on-pastel); background: var(--bg); border: var(--edge-w) solid var(--edge); border-radius: var(--r); box-shadow: 3px 3px 0 var(--shadow);
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast); }
button { color: var(--ink); }
button[type="submit"], .btn-primary { --bg: var(--lime); color: var(--on-pastel); }
button:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); }
button:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--shadow); }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
button.danger:not(.link) { --bg: var(--coral); color: var(--on-pastel); }
button.secondary, button.tab, button.remove, button.add-step, button.discard-plan, button.dismiss, button.undo, button.edit, button.preview-plan { --bg: var(--surface); color: var(--ink); }
button.use { --bg: var(--lime); color: var(--on-pastel); }
button.link { background: none; border: 0; box-shadow: none; min-height: 0; padding: 4px 6px; color: var(--link); font-weight: 600; border-radius: var(--r-sm); }
button.link:hover:not(:disabled) { transform: none; box-shadow: none; text-decoration: underline; }
button.link.danger { color: var(--bad-text); }
.icon-btn { min-height: 38px; width: 38px; padding: 0; box-shadow: 2px 2px 0 var(--shadow); }
.icon-btn svg.i { width: 18px; height: 18px; }
button.sm { min-height: 32px; padding: 0 12px; font-size: 13px; box-shadow: 2px 2px 0 var(--shadow); }
button .spin, .spin { animation: spin 900ms linear infinite; }
button.is-busy { pointer-events: none; }

/* ---------- forms ---------- */
form { display: grid; gap: var(--s4); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.fields .wide { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label:has(> input[type="checkbox"]), label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); cursor: pointer; }
input, select, textarea { font: 400 15px/1.4 var(--font-text); color: var(--ink); background: var(--surface); border: var(--edge-w) solid var(--edge); border-radius: var(--r); padding: 9px 12px; min-height: 42px; width: 100%;
  transition: box-shadow var(--t-fast), border-color var(--t-fast); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:hover, select:hover, textarea:hover { box-shadow: 2px 2px 0 var(--shadow); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
input[type="checkbox"] { appearance: none; width: 20px; height: 20px; min-height: 0; padding: 0; flex: none; border-radius: var(--r-sm); display: inline-grid; place-items: center; cursor: pointer; }
input[type="checkbox"]::after { content: ""; width: 10px; height: 6px; border: 2.5px solid var(--on-pastel); border-top: 0; border-right: 0; transform: rotate(-45deg) scale(0); transition: transform var(--t-fast) var(--ease-back); margin-top: -2px; }
input[type="checkbox"]:checked { background: var(--lime); }
input[type="checkbox"]:checked::after { transform: rotate(-45deg) scale(1); }
input[type="checkbox"]:disabled { opacity: .55; cursor: not-allowed; }
input[type="file"] { padding: 7px; }
input[type="file"]::file-selector-button { font: 600 13px var(--font-text); border: var(--edge-w) solid var(--edge); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); padding: 6px 10px; margin-right: 10px; cursor: pointer; }
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.form-msg:empty { display: none; }
details.more { border: var(--edge-w) dashed var(--line); border-radius: var(--r); padding: 0 var(--s4); }
details.more[open] { padding-bottom: var(--s4); }
details.more > summary { cursor: pointer; padding: var(--s3) 0; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary svg { transition: transform var(--t) var(--ease); }
details.more[open] > summary svg { transform: rotate(90deg); }
details > summary { cursor: pointer; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--s5) * -1); padding: 0 var(--s5); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 500 11px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 0 var(--s3) var(--s3); border-bottom: var(--edge-w) solid var(--edge); white-space: nowrap; }
td { padding: var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr, table > tr { transition: background var(--t-fast); }
tbody tr:hover, table > tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.url { max-width: 380px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.current td { background: color-mix(in srgb, var(--lime) 28%, transparent); font-weight: 600; }

/* ---------- chips (status / severity / role): small, square-cornered, always meaningful ---------- */
.status, .sev, .tag, .chip { display: inline-flex; align-items: center; gap: 5px; font: 600 12px/1 var(--font-mono); letter-spacing: .02em; padding: 4px 7px; border: 1.5px solid var(--edge); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--on-pastel); white-space: nowrap; text-transform: lowercase; }
.tag, .chip { color: var(--ink); }
.status svg.i, .sev svg.i { width: 13px; height: 13px; vertical-align: 0; stroke-width: 2.5; }
.s-passed, .chip.ok { background: var(--mint); }
.s-failed, .s-error, .sev-critical, .sev-major, .chip.bad { background: var(--coral); }
.s-running, .chip.warn { background: var(--butter); }
.s-queued { background: var(--lavender); }
.s-cancelled { background: var(--surface-2); color: var(--ink-2); }
.sev-minor { background: var(--butter); } .sev-info { background: var(--sky); }
.tag.ok { background: var(--mint); color: var(--on-pastel); } .tag.warn { background: var(--butter); color: var(--on-pastel); }

/* ---------- messages, empty, error, success ---------- */
.msg { display: flex; align-items: flex-start; gap: 10px; padding: var(--s3) var(--s4); border: var(--edge-w) solid var(--edge); border-radius: var(--r); background: var(--sky); color: var(--on-pastel); font-weight: 500; margin: 0; }
.msg.error { background: var(--coral); } .msg.ok { background: var(--mint); }
.msg svg.i { margin-top: 1px; }
.err { color: var(--bad-text); font-weight: 600; }
.empty { display: grid; justify-items: start; gap: var(--s2); padding: var(--s5); border: var(--edge-w) dashed var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.empty .empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border: var(--edge-w) solid var(--edge); border-radius: var(--r); background: var(--lavender); color: var(--on-pastel); margin-bottom: var(--s1); }
.empty h3 { margin: 0; font-size: 17px; } .empty p { margin: 0; color: var(--ink-2); max-width: 52ch; }
.secret { display: block; background: var(--butter); color: var(--on-pastel); border: var(--edge-w) solid var(--edge); padding: var(--s3) var(--s4); border-radius: var(--r); user-select: all; font-size: 14px; }

/* ---------- stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border: var(--edge-w) solid var(--edge); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-x) var(--shadow-x) 0 var(--shadow); overflow: hidden; }
.stat { padding: var(--s4) var(--s5); border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat .k { font: 500 11px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 8px; display: block; }
.stat .v { font: 800 28px/1 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .v.bad { color: var(--bad-text); } .stat .v.ok { color: var(--ok-text); }

/* ---------- meters & bars (usage, trend) ---------- */
.meter { height: 14px; border: var(--edge-w) solid var(--edge); border-radius: var(--r-sm); background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; width: var(--w, 0%); background: var(--lime); border-right: var(--edge-w) solid var(--edge); transform-origin: left; animation: grow 700ms var(--ease) both; }
.bar { width: 100%; min-width: 80px; }
.bar > span { display: block; height: 12px; width: var(--w, 0%); background: var(--sky); border: 1.5px solid var(--edge); border-radius: 2px; transform-origin: left; animation: grow 600ms var(--ease) both; }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s4); }
.tabs .tab { min-height: 34px; padding: 0 12px; font-size: 13px; box-shadow: 2px 2px 0 var(--shadow); }
.tabs .tab.active { --bg: var(--ink); color: var(--paper); }
[data-theme="dark"] .tabs .tab.active { --bg: var(--lime); color: var(--on-pastel); }

/* ---------- visual review ---------- */
#visual .card h3 { font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: 0; word-break: break-all; }
.shots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin: var(--s3) 0; }
.shots figure { margin: 0; display: grid; gap: 6px; }
.shots figcaption, figure figcaption { font: 500 11px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
img.shot { width: 100%; max-width: none; border: var(--edge-w) solid var(--edge); border-radius: var(--r-sm); background: var(--surface-2); display: block; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--s3); }
.thumb { width: 100%; border: var(--edge-w) solid var(--edge); border-radius: var(--r-sm); display: block; background: var(--surface-2); }
figure { margin: 0; display: grid; gap: 6px; }
.decision { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin: var(--s3) 0 0; }

/* ---------- AI: instructions, pencil, plan ---------- */
.instructions { display: grid; gap: 8px; }
.with-pencil { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2); align-items: start; }
.pencil { --bg: var(--lavender); color: var(--on-pastel); min-height: 42px; }
.pencil-panel:empty, .plan-area:empty { display: none; }
.suggest { display: grid; gap: var(--s3); padding: var(--s4); border: var(--edge-w) solid var(--edge); border-radius: var(--r); background: color-mix(in srgb, var(--lavender) 35%, var(--surface)); }
.suggest .row { gap: var(--s2); }
.suggestion { white-space: pre-wrap; font: 14px/1.6 var(--font-mono); background: var(--surface); color: var(--ink); padding: var(--s3) var(--s4); border: 1.5px solid var(--edge); border-radius: var(--r-sm); max-height: 360px; overflow: auto; }
.plan { display: grid; gap: var(--s3); }
.plan ol { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.plan li { counter-increment: step; display: grid; grid-template-columns: 30px 110px minmax(0, 1fr) auto; gap: var(--s2); align-items: center; padding: var(--s2); border: 1.5px solid var(--edge); border-radius: var(--r); background: var(--surface); }
.plan li::before { content: counter(step); display: grid; place-items: center; width: 26px; height: 26px; font: 700 12px var(--font-mono); background: var(--surface-2); border: 1.5px solid var(--edge); border-radius: var(--r-sm); }
.plan li .inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s2); }
.plan li input, .plan li select { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.plan li.blocked { background: color-mix(in srgb, var(--coral) 22%, var(--surface)); }
.plan .why { grid-column: 2 / -1; font-size: 13px; color: var(--bad-text); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.plan li button.remove { width: 36px; min-height: 36px; padding: 0; box-shadow: 2px 2px 0 var(--shadow); }

/* ---------- journey (instruction steps) ---------- */
#journey ol { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
#journey li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); align-items: start; padding: var(--s3); border: 1.5px solid var(--line); border-radius: var(--r); background: var(--surface); }
#journey li .what { min-width: 0; }
#journey li .what .muted { margin-top: 4px; }
#journey li strong.status { margin-top: 1px; }
#journey li.j-failed, #journey li.j-error { border-color: var(--edge); background: color-mix(in srgb, var(--coral) 18%, var(--surface)); }
#journey img.thumb { width: 168px; max-width: none; margin: 0; }
#journey-summary { font-weight: 600; }

/* ---------- accessibility ---------- */
#a11y h3 { display: flex; align-items: center; gap: 8px; margin: var(--s4) 0 var(--s2); font-family: var(--font-mono); font-size: 13px; letter-spacing: 0; text-transform: none; }
#a11y h3:first-of-type { margin-top: 0; }
#a11y .fix { display: inline-flex; gap: 4px; align-items: center; font-weight: 600; font-size: 13px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-brand { background: var(--lime); color: var(--on-pastel); border-right: var(--edge-w) solid var(--edge); padding: var(--s7); display: flex; flex-direction: column; justify-content: space-between; gap: var(--s6); }
.auth-brand .brand { color: var(--on-pastel); }
.auth-brand h2 { font-size: clamp(34px, 4.6vw, 60px); line-height: .98; font-weight: 800; letter-spacing: -0.035em; color: var(--on-pastel); max-width: 13ch; margin: 0; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); max-width: 44ch; }
.auth-points li { display: grid; grid-template-columns: 34px 1fr; gap: var(--s3); align-items: start; font-weight: 500; }
.auth-points .ico { display: grid; place-items: center; width: 34px; height: 34px; background: var(--surface); color: var(--ink); border: var(--edge-w) solid var(--on-pastel); border-radius: var(--r); }
[data-theme="dark"] .auth-points .ico { background: #fffdf8; color: var(--on-pastel); }
.auth-form { display: grid; place-items: center; padding: var(--s6) var(--s5); }
.auth-card { width: 100%; max-width: 420px; display: grid; gap: var(--s5); }
.auth-card h1 { font-size: 36px; }
.auth-card .alt { color: var(--ink-2); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.auth-card form button[type="submit"] { width: 100%; min-height: 46px; font-size: 15px; }
.auth-top { position: absolute; top: var(--s4); right: var(--s4); }

/* ---------- org list ---------- */
.org-list { list-style: none; margin: 0; padding: 0; display: grid; }
.org-list li { border-bottom: 1px solid var(--line); }
.org-list li:last-child { border-bottom: 0; }
.org-list a { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s2); color: var(--ink); text-decoration: none; font-weight: 600; border-radius: var(--r); transition: background var(--t-fast); }
.org-list a:hover { background: var(--surface-2); }
.org-list a .grow { flex: 1; min-width: 0; }
.org-list .ini { display: grid; place-items: center; width: 34px; height: 34px; border: var(--edge-w) solid var(--edge); border-radius: var(--r); background: var(--peach); color: var(--on-pastel); font: 800 14px var(--font-display); }
.org-list a > svg.i:last-child { color: var(--ink-3); transition: transform var(--t) var(--ease); }
.org-list a:hover > svg.i:last-child { transform: translateX(3px); color: var(--ink); }

/* ---------- modal ---------- */
dialog.modal { border: var(--edge-w) solid var(--edge); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); padding: var(--s5); width: min(460px, calc(100vw - 32px)); box-shadow: 6px 6px 0 var(--shadow); }
dialog.modal::backdrop { background: rgba(10, 10, 14, .5); }
dialog.modal[open] { animation: pop var(--t) var(--ease-back); }
dialog.modal h2 { margin-bottom: var(--s2); }
dialog.modal p { color: var(--ink-2); }
dialog.modal .row { justify-content: flex-end; margin-top: var(--s4); }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 60; right: var(--s4); bottom: var(--s4); display: grid; gap: var(--s2); width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: var(--s3) var(--s4); background: var(--surface); color: var(--ink); border: var(--edge-w) solid var(--edge); border-radius: var(--r); box-shadow: 3px 3px 0 var(--shadow); font-weight: 500; animation: toast-in var(--t) var(--ease-back) both; }
.toast .ti { display: grid; place-items: center; width: 24px; height: 24px; border: 1.5px solid var(--edge); border-radius: var(--r-sm); background: var(--mint); color: var(--on-pastel); flex: none; }
.toast.error .ti { background: var(--coral); }
.toast.leaving { animation: toast-out 180ms var(--ease) both; }

/* ---------- skeletons ---------- */
.sk { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent); animation: shimmer 1.2s infinite; }
.sk-title { height: 38px; width: 42%; margin-bottom: var(--s6); }
.sk-line { height: 14px; margin: 10px 0; } .sk-line.w60 { width: 60%; } .sk-line.w80 { width: 80%; } .sk-line.w40 { width: 40%; }
.sk-panel { height: 220px; border: var(--edge-w) solid var(--line); border-radius: var(--r-lg); margin-bottom: var(--s5); }

/* ---------- motion ---------- */
.enter > * { animation: rise 360ms var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) rotate(-1deg); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
.theme-btn svg.i { transition: transform 400ms var(--ease-back); }
.theme-btn:hover svg.i { transform: rotate(-25deg); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .enter > * { animation-delay: 0ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  main { padding: var(--s5) var(--s5) var(--s7); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .top { display: flex; }
  .side { position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-105%); transition: transform var(--t) var(--ease); box-shadow: 6px 0 0 var(--shadow); }
  body.nav-open .side { transform: none; }
  .side .side-brand { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { border-right: 0; border-bottom: var(--edge-w) solid var(--edge); padding: var(--s5); }
  .auth-brand h2 { font-size: 34px; }
  .auth-points { display: none; }
}
@media (min-width: 901px) { .menu-btn, .top-brand { display: none; } }
@media (max-width: 640px) {
  main { padding: var(--s4) var(--s4) var(--s7); }
  .page-head { margin-bottom: var(--s5); }
  .panel { padding: var(--s4); box-shadow: 3px 3px 0 var(--shadow); }
  .table-wrap { margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4); }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .shots { grid-template-columns: minmax(0, 1fr); }
  .plan li { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .plan li select { grid-column: 2 / 3; }
  .plan li .inputs { grid-column: 1 / -1; }
  #journey li { grid-template-columns: auto minmax(0, 1fr); }
  #journey li > a { grid-column: 1 / -1; }
  #journey img.thumb { width: 100%; }
  .stat { padding: var(--s3) var(--s4); } .stat .v { font-size: 24px; }
  .page-head .actions { width: 100%; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#current-plan { margin: 0; text-transform: capitalize; }

/* ---------- fixes after visual review ---------- */
body.is-auth main { max-width: none; padding: 0; }
@media (min-width: 901px) {   /* sidebar colour + edge painted on the shell, so they reach the bottom of long pages */
  .shell { background: linear-gradient(var(--edge), var(--edge)) calc(var(--side-w) - var(--edge-w)) 0 / var(--edge-w) 100% no-repeat,
                       linear-gradient(var(--paper-2), var(--paper-2)) 0 0 / var(--side-w) 100% no-repeat, var(--paper); }
  body.is-auth .shell { background: var(--paper); }
}
.shots, .grid { align-items: start; }
img.shot, .grid img.thumb { max-height: 440px; object-fit: cover; object-position: top; }
.grid img.thumb { max-height: 300px; }
.shots a, .grid a { display: block; }
details.files > summary { font-weight: 600; color: var(--ink-2); padding: var(--s2) 0; }
[data-theme="dark"] { --shadow: #4d4a59; }
th { white-space: normal; }
@media (max-width: 640px) {
  table.stack-sm, table.stack-sm tbody { display: block; }
  table.stack-sm tr { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  table.stack-sm tr:last-child { border-bottom: 0; }
  table.stack-sm td { border: 0; padding: 0; }
  table.stack-sm td.url { grid-column: 2; padding-top: 6px; color: var(--ink-3); font-size: 12px; }
}
/* closed drawer: off-screen AND out of the keyboard order / accessibility tree */
@media (max-width: 900px) {
  .side { visibility: hidden; transition: transform var(--t) var(--ease), visibility 0s linear var(--t); }
  body.nav-open .side { visibility: visible; transition: transform var(--t) var(--ease), visibility 0s; }
}
.head-actions{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
a.btn{text-decoration:none;display:inline-flex;align-items:center;gap:8px}
/* Phase 10: tests + step editor */
.icon-btn{--bg:var(--surface);padding:0 8px;min-width:36px;min-height:36px}
.steps-edit{margin:0;padding-left:22px;display:grid;gap:8px}
.step-row{gap:6px;align-items:center;flex-wrap:wrap}.step-row select{width:auto;min-width:96px}.step-row input{flex:1;min-width:160px}
.test-editor{border:2px dashed var(--ink);border-radius:12px;padding:14px;margin-top:12px}
textarea.mono{width:100%}
.recorder{border:2px solid var(--ink);border-radius:12px;padding:14px;margin-top:12px}
.rec-view{overflow:auto;border:2px solid var(--ink);border-radius:8px;background:var(--paper-2)}
.rec-frame{display:block;width:100%;height:auto;cursor:crosshair;min-height:120px}
.rec-steps{margin:0;padding-left:22px;font-family:var(--font-mono);font-size:13px}
details.mute{margin-top:6px}details.mute .row{gap:6px;flex-wrap:wrap;margin-top:6px}details.mute input{flex:1;min-width:140px}
dialog.replay{width:min(1100px,94vw)}.explain .suggestion{margin-top:6px;white-space:pre-wrap}
/* SCOPE-11: feedback dialog */
dialog.modal textarea { width: 100%; box-sizing: border-box; font: inherit; }
dialog.modal .star { font-size: 1.1rem; line-height: 1; min-width: 2.25rem; }
dialog.modal .star[aria-pressed="true"] { background: var(--accent, #f5b400); color: var(--ink); }
/* SCOPE-12: Account + Admin */
.msg.warn { background: var(--butter); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s4); margin: 0 0 var(--s4); }
dl.facts dt { color: var(--ink-2); } dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.plain-list li { border-bottom: 1px solid var(--line); padding-bottom: var(--s3); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: var(--s1) 0 0; }
.tag.bad { background: var(--coral); color: var(--on-pastel); }
