/* Cut to Match - a storyboard sheet: warm grey drafting paper, pencil panels, a red "A" and cyan "B" onion skin. */
:root {
  --bg: #e9e5db; --paper: #fbf9f3; --paper2: #f3efe5; --ink: #23211d; --soft: #5a554c; --line: #cfc8b8; --grid: #d9d2c2;
  --a: #b83228; --b: #0e7487; --accent: #23211d; --accent-ink: #fbf9f3;
  --ok: #1f6b3a; --ok-bg: #dcefe1; --warn: #8a5a00; --warn-bg: #f7e7c2; --bad: #a32020; --bad-bg: #f6d9d6;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Courier New", monospace;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --card: var(--paper2); --bg-2: var(--paper2); --ink-2: var(--soft);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15171a; --paper: #1f2226; --paper2: #262a2f; --ink: #ece8df; --soft: #b5afa3; --line: #3a3f46; --grid: #353a41;
  --a: #ff8073; --b: #5fd3e6; --accent: #ece8df; --accent-ink: #15171a;
  --ok: #8fe0a8; --ok-bg: #1d3a27; --warn: #ffd27a; --warn-bg: #3d2f10; --bad: #ff9b92; --bad-bg: #44201d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); overflow-x: hidden;
  background-image: radial-gradient(var(--grid) 0.8px, transparent 0.8px); background-size: 18px 18px; }
a { color: var(--b); }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 13px; } .muted { color: var(--soft); } .mono { font-family: var(--mono); }
button, select, input, textarea { font: inherit; color: inherit; }

/* Header */
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--paper); border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.back { color: var(--soft); text-decoration: none; font-size: 13px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--mono); letter-spacing: .02em; }
.logo { width: 28px; height: 28px; }
.lg-a { fill: none; stroke: var(--a); stroke-width: 2.2; } .lg-b { fill: none; stroke: var(--b); stroke-width: 2.2; } .lg-dot { fill: var(--ink); }
.session { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { border: 1.5px solid var(--ink); background: var(--paper); border-radius: 4px; padding: 5px 11px; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-block; font-size: 14px; }
.pill:hover:not(:disabled) { background: var(--paper2); }
.pill.solid { background: var(--accent); color: var(--accent-ink); }
.pill.solid:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); opacity: .88; }
.pill.ghost { border-style: dashed; cursor: default; }
.pill.tiny { padding: 2px 8px; font-size: 12px; }
.pill.big { padding: 9px 18px; font-size: 16px; }
.pill:disabled { opacity: .45; cursor: not-allowed; }

/* Hero */
main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.hero { padding: 18px 4px 8px; }
.kicker { font-family: var(--mono); font-size: 12.5px; color: var(--soft); margin: 0 0 10px; max-width: 820px; }
.note-src { white-space: nowrap; }
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 5vw, 44px); line-height: 1.12; margin: 0 0 10px; max-width: 860px; overflow-wrap: anywhere; }
.lede { font-size: 16.5px; max-width: 760px; margin: 0 0 12px; }
.samples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 1.5px dashed var(--ink); background: transparent; border-radius: 3px; padding: 4px 10px; cursor: pointer; font-size: 13px; color: var(--ink); }
.chip.on { background: var(--ink); color: var(--paper); border-style: solid; }

/* Panels */
.panel { background: var(--paper); border: 1.5px solid var(--line); border-radius: 6px; padding: 14px 16px; margin: 14px 0; box-shadow: 0 1px 0 var(--line); min-width: 0; }
.ph { font-family: var(--mono); font-size: 15px; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.step-no { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1.5px solid var(--ink); border-radius: 50%; font-size: 12px; }
h3 { font-size: 15px; margin: 14px 0 6px; } h3.sub { font-family: var(--mono); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 0 16px; align-items: start; }
.lbl { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
input[type=text], select, textarea { width: 100%; background: var(--paper2); border: 1.5px solid var(--line); border-radius: 4px; padding: 6px 8px; }
textarea { resize: vertical; }
.note { color: var(--warn); background: var(--warn-bg); padding: 6px 9px; border-radius: 4px; }

/* Shot rows */
.rows { list-style: none; padding: 0; margin: 8px 0; }
.shot-row { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 6px 8px; padding: 9px 0; border-top: 1px dashed var(--line); align-items: center; }
.row-no { font-family: var(--mono); font-weight: 700; text-align: center; border: 1.5px solid var(--ink); border-radius: 3px; }
.row-opts { grid-column: 2; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.row-opts select { font-size: 13px; padding: 4px 5px; }
.row-opts .mv-in { border-color: var(--b); } .row-opts .mv-out { border-color: var(--a); }
.row-acts { grid-column: 2; display: flex; gap: 5px; flex-wrap: wrap; }
.none { color: var(--soft); font-style: italic; list-style: none; }
.drop { border: 1.5px dashed var(--line); border-radius: 4px; padding: 8px; margin-top: 10px; }
.drop.over { border-color: var(--b); }
.filelbl { text-decoration: underline; cursor: pointer; }

/* The storyboard sheet */
.sheet { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; }
.pnl { margin: 0; width: 120px; background: var(--paper2); border: 1.5px solid var(--line); border-radius: 4px; padding: 5px; }
.pnl.pnl-on { border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.pnl-head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--soft); }
.pnl-no { font-weight: 700; color: var(--ink); }
.pnl-svg { display: block; width: 100%; height: auto; max-height: 190px; }
.pnl-cap { font-size: 11.5px; line-height: 1.3; margin-top: 3px; overflow-wrap: anywhere; }
.pnl-cap b { display: block; }
.pnl-mv { color: var(--soft); font-family: var(--mono); font-size: 10.5px; }
.fr-paper { fill: var(--paper); stroke: var(--ink); stroke-width: 1.4; }
.fr-grid { stroke: var(--grid); stroke-width: .8; stroke-dasharray: 2 2; }
.sub { stroke: var(--ink); stroke-width: 1.3; }
.mv { stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.mv-out { stroke: var(--a); } .mv-in { stroke: var(--b); stroke-dasharray: 3 2; }
.mv-in.mv-head { stroke-dasharray: none; }
.mv-dot.mv-out { fill: var(--a); } .mv-dot.mv-in { fill: var(--b); stroke-dasharray: none; }
.mv-halo { stroke-dasharray: 2 3; }
.seam { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 104px; border: 1.5px solid var(--line); background: var(--paper); border-radius: 14px;
  padding: 5px 9px; cursor: pointer; text-align: left; font-size: 11px; line-height: 1.25; color: var(--ink); }
.seam.seam-on { border-color: var(--ink); border-width: 2px; }
.seam-cut { font-family: var(--mono); color: var(--soft); }
.seam-v { font-weight: 700; padding: 0 5px; border-radius: 3px; }
.seam-name { font-weight: 600; } .seam-h { color: var(--soft); }
.v-locked .seam-v, .k-lock { background: var(--ok-bg); color: var(--ok); }
.v-loose .seam-v, .k-loose { background: var(--warn-bg); color: var(--warn); }
.v-broken .seam-v, .k-broken { background: var(--bad-bg); color: var(--bad); }
.legend { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--soft); }
.legend li { display: flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 18px; height: 10px; border-radius: 2px; border: 1px solid var(--line); }
.k-in { border: 0; border-top: 2.5px dashed var(--b); height: 0; } .k-out { border: 0; border-top: 2.5px solid var(--a); height: 0; }
.k-lock { border-color: var(--ok); } .k-loose { border-color: var(--warn); } .k-broken { border-color: var(--bad); }

/* Onion skin */
.skin-grid { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 16px; align-items: start; }
.onion-host { background: var(--paper2); border: 1.5px solid var(--line); border-radius: 4px; padding: 8px; }
.onion-svg { display: block; width: 100%; height: auto; max-height: 420px; }
.reg { stroke: var(--soft); stroke-width: 1; fill: none; }
.sub-a { stroke: var(--a); stroke-width: 2; fill: none; opacity: .75; }
.sub-b { stroke: var(--b); stroke-width: 2; fill: none; }
.skin-a .mv { opacity: .8; }
.vel-svg { display: block; width: 100%; max-width: 460px; height: auto; }
.vel-axis { stroke: var(--line); stroke-width: 1.2; } .vel-cut { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 4 3; }
.vel-a { stroke: var(--a); stroke-width: 2.5; fill: none; } .vel-b { stroke: var(--b); stroke-width: 2.5; fill: none; }
.vel-lbl { fill: var(--soft); font: 10px var(--mono); }
.spec { background: var(--paper2); border-left: 3px solid var(--ink); padding: 6px 10px; }
.facts { list-style: none; padding: 0; margin: 0; }
.facts li { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; border-top: 1px dashed var(--line); font-size: 13.5px; }
.facts li.clear { color: var(--ok); }
.tag { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 3px; white-space: nowrap; border: 1px solid currentColor; }
.t-break, .cvt-broken { color: var(--bad); background: var(--bad-bg); }
.t-gap, .cvt-loose { color: var(--warn); background: var(--warn-bg); }
.cvt-locked { color: var(--ok); background: var(--ok-bg); }
.seamtag { color: var(--ink); background: var(--paper2); }
.badge { display: inline-block; font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 3px; border: 1.5px solid currentColor; }
.v-ready { color: var(--ok); background: var(--ok-bg); } .v-tighten { color: var(--warn); background: var(--warn-bg); } .v-rethink { color: var(--bad); background: var(--bad-bg); }
.v-none { color: var(--soft); }

/* Run, progress, result */
.runrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.gate { background: var(--paper2); border: 1px dashed var(--line); padding: 8px 10px; border-radius: 4px; }
.steps { list-style: none; padding: 0; margin: 6px 0; font-family: var(--mono); font-size: 13px; }
.step { color: var(--soft); } .step.done { color: var(--ok); } .step.active { color: var(--ink); font-weight: 700; }
.raw { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--paper2); padding: 10px; max-height: 360px; overflow: auto; font-size: 12px; }
.res-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.res-head h2 { font-family: var(--serif); margin: 0; font-size: 24px; overflow-wrap: anywhere; min-width: 0; }
.summary { font-size: 16px; }
.cutcards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.cutcard { border: 1.5px solid var(--line); border-left: 5px solid var(--line); border-radius: 4px; padding: 9px 12px; background: var(--paper2); }
.cv-locked { border-left-color: var(--ok); } .cv-loose { border-left-color: var(--warn); } .cv-broken { border-left-color: var(--bad); }
.cc-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cc-pair { font-weight: 700; margin-right: 4px; overflow-wrap: anywhere; }
.cutcard p { margin: 5px 0; font-size: 14px; }
.cc-a b { color: var(--a); } .cc-b b { color: var(--b); }
.fix { background: var(--paper); padding: 4px 8px; border-radius: 3px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.plain { padding-left: 18px; } .keep { margin: 0; }
.recon { padding-left: 18px; font-size: 13.5px; } .recon .warn { color: var(--bad); } .recon .note { background: none; padding: 0; color: var(--warn); }
.exports, .cardrow { display: flex; flex-wrap: wrap; gap: 6px; }
.hist { list-style: none; padding: 0; } .hrow { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px dashed var(--line); }
.hinfo { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.foot { max-width: 1180px; margin: 0 auto; padding: 8px 16px 40px; font-size: 13px; color: var(--soft); }
.toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 9; max-width: min(360px, calc(100vw - 24px)); }
.toast { background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 4px; font-size: 13.5px; transition: opacity .5s; }
.toast.err { background: var(--bad); color: #fff; } .toast.gone { opacity: 0; }
.toast a { color: inherit; font-weight: 700; }
.printsheet { display: none; }

@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 620px) {
  .row-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skin-grid, .cols { grid-template-columns: minmax(0, 1fr); }
  .onion-host { max-width: 240px; }
  .pnl { width: calc(50% - 60px); min-width: 92px; } .seam { width: 92px; }
  .back { display: none; }
}
@media print {
  body { background: #fff; color: #000; }
  body.printing-board > *:not(main), body.printing-board main > *:not(.printsheet) { display: none !important; }
  body.printing-board .printsheet { display: block; }
  .ps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .ps-cell { border: 1px solid #000; padding: 6px; font-size: 11px; display: flex; flex-direction: column; gap: 2px; break-inside: avoid; }
  .ps-cell svg { width: 100%; max-height: 200px; }
  .ps-cut { font-style: italic; }
  .ps-h { font-size: 14px; margin: 12px 0 4px; }
  .ps-recipes { margin: 0; padding-left: 20px; font-size: 11px; }
  .ps-rec { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; break-inside: avoid; }
  .ps-rec i { font-style: normal; font-weight: 600; }
}
@media (max-width: 620px) {
  .sheet { justify-content: center; }
  .pnl { width: 150px; min-width: 0; }
  .seam { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; border-radius: 8px; justify-content: center; }
}
