:root {
  --bg: #f6f1e9;
  --card: #fffdf9;
  --ink: #2a2118;
  --muted: #7a6c5c;
  --line: #e2d8c9;
  --accent: #b5452f;
  --accent-ink: #fff;
  --wood-a: #c8955e;
  --wood-b: #a8733f;
  --carve: #3b2615;
  --tpl: #1f1f22;
  --tpl-ink: #f2f2f2;
  --route: #e03a2c;
  --spacer: #3a3d44;
  --done: #d8c2a0;
  --later: #9aa0aa;
  --info: #e8eef6;
  --warn: #fbf0d9;
  --bad: #f8e0dc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f; --card: #211b16; --ink: #efe6da; --muted: #a8998a; --line: #3a3027;
    --tpl: #0c0c0e; --spacer: #444851; --done: #6b5a45; --later: #5e636c;
    --info: #1e2733; --warn: #33291a; --bad: #3a211d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: 1100px; margin: 0 auto; padding-inline: 16px; }
.top { background: #2b2019; color: #f4ead9; padding-block: 22px 18px; padding-top: calc(22px + env(safe-area-inset-top, 0px)); margin-bottom: 18px; }
h1, h2, h3 { font-family: Overpass, system-ui, sans-serif; font-weight: 800; letter-spacing: .01em; margin: 0; }
h1 { font-size: 30px; text-transform: uppercase; letter-spacing: .06em; }
h2 { font-size: 19px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
h4 { margin: 14px 0 6px; font-size: 14px; }
.sub { margin: 4px 0 0; color: #d5c6b0; max-width: 60ch; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; gap: 10px; }
.gap { gap: 6px; }
input, select, button { font: inherit; color: inherit; }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input[type=number] { width: 5.5em; }
button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: .35; cursor: default; }
.line-row { display: flex; gap: 6px; align-items: center; margin: 10px 0; }
.line-row .num { width: 1.4em; color: var(--muted); font-weight: 700; text-align: right; }
.line-row .text { flex: 1; min-width: 0; font-family: Overpass, system-ui, sans-serif; font-weight: 800; font-size: 20px; letter-spacing: .08em; text-transform: uppercase; }
.line-row .ghost { padding: 6px 9px; }
.opts { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
.opts label { display: flex; gap: 6px; align-items: center; }
.pill { background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px; font-weight: 600; }
.preview { margin: 12px 0 4px; }
svg.board { width: 100%; height: auto; max-height: 60vh; display: block; }
.wood { fill: var(--wood-a); stroke: var(--wood-b); stroke-width: .06; }
.centerline { stroke: #fff; stroke-opacity: .35; stroke-width: .03; stroke-dasharray: .2 .15; }
.glyph { font-family: Overpass, "Arial Rounded MT Bold", Arial, sans-serif; font-weight: 800; }
.glyph.carved { fill: var(--carve); }
.glyph.missing { fill: none; stroke: var(--route); stroke-width: .04; stroke-dasharray: .1 .08; }
.kern { cursor: pointer; }
.kern .hit { fill: transparent; }
.kern .arc { fill: none; stroke-width: .07; stroke-linecap: round; }
.kern.on .arc { stroke: #fff; }
.kern.off .arc { stroke: #fff; stroke-opacity: .45; stroke-dasharray: .06 .06; }
.kern:hover .arc, .kern:focus .arc { stroke: var(--route); stroke-opacity: 1; }
.kern:focus { outline: none; }
.setup-cut { stroke: var(--route); stroke-width: .05; stroke-dasharray: .12 .08; }
.dim { stroke: var(--muted); stroke-width: .025; }
.dimtext { fill: var(--muted); font-size: .28px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 6px 0; }
.note { border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 14px; }
.note.info { background: var(--info); }
.note.warn { background: var(--warn); }
.note.bad { background: var(--bad); }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; margin-top: 10px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
tr.used td { font-weight: 600; }
.mono { font-family: Overpass, system-ui, sans-serif; font-weight: 800; letter-spacing: .06em; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; letter-spacing: 0; font-family: system-ui, sans-serif; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0; font-size: 13.5px; color: var(--muted); }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; }
.sw.route { background: var(--route); }
.sw.spacer { background: var(--spacer); }
.sw.done { background: var(--done); }
.sw.later { border: 1.5px dashed var(--later); }
.line-plan { border-top: 1px solid var(--line); margin-top: 14px; }
.pass { margin: 10px 0 14px; }
.pass-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.pass-no { background: var(--ink); color: var(--card); border-radius: 4px; padding: 1px 8px; font-weight: 700; font-size: 13px; }
svg.strip { width: 100%; height: auto; max-height: 150px; display: block; }
.tpl { fill: var(--tpl); }
.spacer { fill: var(--spacer); }
.notch { fill: var(--card); }
.tlabel { fill: var(--tpl-ink); font-size: .2px; font-weight: 700; font-family: system-ui, sans-serif; }
.slabel { fill: var(--tpl-ink); font-weight: 700; font-family: system-ui, sans-serif; letter-spacing: .02em; }
.cut-route { fill: var(--route); }
.ghost-done { fill: none; stroke: var(--done); stroke-width: .03; }
.cut-done { fill: var(--done); }
.ghost-later { fill: none; stroke: var(--later); stroke-width: .03; stroke-dasharray: .1 .07; }
.cut-later { fill: none; stroke: var(--later); stroke-width: .03; }
.swaps { margin: 6px 0 0; font-size: 14px; }
details summary { cursor: pointer; list-style: none; }
details summary h2 { display: inline; }
details summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }
.inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin: 8px 0 12px; }
.inv label { display: flex; align-items: center; gap: 6px; justify-content: space-between; background: var(--bg); border-radius: 6px; padding: 3px 3px 3px 9px; font-weight: 700; font-size: 13px; }
.inv input { width: 3.4em; padding: 3px 5px; }
.notes ul { margin: 8px 0 0; padding-left: 20px; }
.notes li { margin: 6px 0; }
#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 8px 16px; border-radius: 8px; font-weight: 600; }
#toast[hidden] { display: none; }
@media (max-width: 640px) {
  .line-row { flex-wrap: wrap; }
  .line-row .text { flex-basis: calc(100% - 2em); }
  h1 { font-size: 24px; }
}
@media print {
  .top { background: none; color: #000; padding: 0; }
  .sub, #editor, #kit, .notes, .kern, #toast { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
  .pass { break-inside: avoid; }
  .line-plan { break-before: auto; }
}
.scroll td { white-space: nowrap; }
/* traced template slots */
.part { stroke: none; }
.part.carved { fill: var(--carve); }
.part.cut-route { fill: var(--route); }
.part.cut-done { fill: var(--done); }
.part.cut-later { fill: none; stroke: var(--later); stroke-width: 1.2px; vector-effect: non-scaling-stroke; stroke-dasharray: 3 2; }
.part.ctx-done { fill: var(--done); fill-opacity: .55; }
.part.ctx-later { fill: none; stroke: #b9bcc4; stroke-width: 1.2px; vector-effect: non-scaling-stroke; stroke-dasharray: 3 2; }
.tt-box { margin-bottom: 8px; }
.tt-box details { margin-top: 6px; }
.tt-box summary { color: var(--accent); font-weight: 600; font-size: 14px; }
.tt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 10px 0; }
.tt { margin: 0; background: var(--bg); border-radius: 8px; padding: 10px; }
.tt svg { width: 100%; height: auto; display: block; max-height: 150px; }
.tt figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.woodchip { fill: var(--wood-a); }
.op { fill: var(--muted); font-weight: 700; font-family: system-ui, sans-serif; }
