:root {
  --paper: #f3eee4;
  --card: #fffdf8;
  --ink: #1d1b17;
  --muted: #6d665a;
  --line: #ddd3c2;
  --line-strong: #c4b8a3;
  --accent: #ff4f1a;
  --accent-ink: #ffffff;
  --outside: #ff4f1a;
  --inside: #1f63e0;
  --on: #128a43;
  --ok: #128a43;
  --warn: #b97800;
  --bad: #cc2f12;
  --wood: #ead3a8;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(29,27,23,.06), 0 8px 24px -12px rgba(29,27,23,.18);
  --sans: 'Archivo', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3, h4 { font-stretch: 78%; line-height: 1.05; margin: 0; letter-spacing: -.01em; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px clamp(16px, 4vw, 48px); border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.logo { display: inline-flex; align-items: center; font: 900 26px/1 var(--sans); font-stretch: 70%; text-decoration: none; letter-spacing: -.02em; }
.logo .kerf { width: 4px; height: 30px; background: var(--accent); transform: skewX(-24deg); margin: 0 5px; border-radius: 1px; }
.logo.small { font-size: 18px; } .logo.small .kerf { height: 20px; width: 3px; }
.top nav { display: flex; gap: clamp(12px, 2.5vw, 28px); font-weight: 500; font-size: 15px; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a:hover { color: var(--ink); }
.top nav .nav-ask { color: var(--ink); border-bottom: 2px solid var(--accent); }
@media (max-width: 720px) { .top nav a:not(.nav-ask) { display: none; } }

/* ---------- buttons & fields ---------- */
.btn { font: 600 15px/1 var(--sans); border-radius: 8px; padding: 12px 18px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; transition: transform .08s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #e8410f; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.small { padding: 7px 11px; font-size: 13px; }
.btn.block { width: 100%; padding: 15px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .mini { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini { display: inline-flex; align-items: center; gap: 8px; }
input, select, textarea { font: 400 15px/1.3 var(--sans); color: var(--ink); background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 12px; width: 100%; }
.mini select { width: auto; padding: 5px 8px; font-size: 13px; text-transform: none; letter-spacing: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .drop:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--card); }
.seg button { font: 600 12px/1 var(--sans); border: 0; background: none; padding: 7px 10px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--paper); }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(24px, 5vw, 72px); align-items: center; padding: clamp(32px, 7vw, 96px) clamp(16px, 4vw, 48px); max-width: 1320px; margin: 0 auto; }
.eyebrow { font: 600 13px/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--accent); margin: 0 0 18px; }
.hero h1 { font-size: clamp(44px, 7.4vw, 104px); font-weight: 900; font-stretch: 66%; letter-spacing: -.025em; line-height: .92; }
.hero h1 em { font-style: normal; color: var(--accent); }
.lede { font-size: clamp(17px, 1.6vw, 20px); color: var(--muted); max-width: 34em; margin: 22px 0; }
.facts { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 26px; font-size: 14px; color: var(--muted); }
.facts b { color: var(--ink); }
.drop { display: grid; place-items: center; gap: 8px; text-align: center; min-height: 360px; padding: 32px; border: 2px dashed var(--line-strong); border-radius: 18px; background: var(--card); cursor: pointer; transition: border-color .15s, background .15s, transform .15s; box-shadow: var(--shadow); }
.drop:hover, .drop.over { border-color: var(--accent); background: #fff8f2; }
.drop.over { transform: scale(1.01); }
.drop strong { font-size: 22px; font-stretch: 80%; }
.drop span { color: var(--muted); }
.drop-art { width: 180px; margin-bottom: 8px; }
.drop-art .sheet { fill: var(--wood); stroke: #c9a876; }
.drop-art .cut { fill: none; stroke: var(--outside); stroke-width: 2; stroke-dasharray: 4 3; animation: march 1.2s linear infinite; }
.drop-art .cut.in { stroke: var(--inside); }
@keyframes march { to { stroke-dashoffset: -14; } }
@media (prefers-reduced-motion: reduce) { .drop-art .cut { animation: none; } }
.sample { margin-top: 10px; font-size: 14px; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } .drop { min-height: 240px; } }

/* ---------- workspace ---------- */
#workspace { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; padding: 24px clamp(16px, 3vw, 40px) 48px; max-width: 1480px; margin: 0 auto; align-items: start; }
@media (max-width: 1060px) { #workspace { grid-template-columns: 1fr; } }
.stage { min-width: 0; }
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
.file-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-meta b { font-size: 18px; font-stretch: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { color: var(--muted); font-size: 13px; }
.stage-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tabs { display: flex; align-items: end; gap: 4px; border-bottom: 1px solid var(--line-strong); }
.tabs [role=tab] { font: 600 14px/1 var(--sans); border: 1px solid transparent; border-bottom: 0; background: none; padding: 11px 14px; cursor: pointer; color: var(--muted); border-radius: 8px 8px 0 0; margin-bottom: -1px; }
.tabs [role=tab].on { background: var(--card); color: var(--ink); border-color: var(--line-strong); }
.tabs .count { font: 500 11px/1 var(--mono); background: var(--paper); border: 1px solid var(--line); border-radius: 99px; padding: 2px 6px; margin-left: 4px; }
.tab-tools { margin-left: auto; padding-bottom: 6px; }
.viewport { position: relative; height: clamp(340px, 56vh, 620px); background: radial-gradient(ellipse at 50% 40%, #fffdf8 0%, #efe8db 100%); border: 1px solid var(--line-strong); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; touch-action: none; }
.viewport canvas { display: block; }
.dim-layer { position: absolute; inset: 0; pointer-events: none; }
.dim-label { font: 600 12px/1 var(--mono); background: var(--ink); color: var(--paper); padding: 4px 7px; border-radius: 5px; white-space: nowrap; }
.dim-label.t { background: var(--accent); }
.stage-note { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

/* 2D paths */
.viewport.paths { display: grid; grid-template-rows: 1fr auto; background: #fbf8f1; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 24px 24px; }
#pathSvg { width: 100%; height: 100%; padding: 24px; }
#pathSvg .ascut { fill: var(--wood); fill-opacity: .85; fill-rule: evenodd; }
#pathSvg .p { fill: none; stroke-width: 2.2; vector-effect: non-scaling-stroke; cursor: pointer; stroke-linejoin: round; }
#pathSvg .p.outside { stroke: var(--outside); }
#pathSvg .p.inside { stroke: var(--inside); }
#pathSvg .p.on { stroke: var(--on); stroke-dasharray: 6 4; }
#pathSvg .p.hit { stroke: transparent; stroke-width: 12; }
#pathSvg .p.sel { stroke-width: 4.5; filter: drop-shadow(0 0 3px rgba(0,0,0,.35)); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 14px; font-size: 12px; color: var(--muted); background: rgba(255,253,248,.92); border-top: 1px solid var(--line); }
.sw { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.sw.outside { background: var(--outside); } .sw.inside { background: var(--inside); }
.sw.on { background: repeating-linear-gradient(90deg, var(--on) 0 5px, transparent 5px 8px); }
.path-panel { margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.path-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.path-bulk select { width: auto; padding: 4px 6px; font-size: 13px; }
.path-bulk .link { margin-left: auto; font-size: 13px; }
.path-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
.path-list li { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px; padding: 7px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.path-list li:last-child { border-bottom: 0; }
.path-list li.sel { background: #fff3ea; }
.path-list .meta { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.path-list .more { color: var(--muted); padding: 10px 14px; display: block; }

/* checks */
.checks { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.checks h3 { font-size: 18px; margin-bottom: 8px; }
.checks ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; align-items: start; }
.checks li::before { font: 700 12px/20px var(--mono); text-align: center; border-radius: 50%; width: 20px; height: 20px; }
.checks li.pass::before { content: '✓'; background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.checks li.info::before { content: 'i'; background: var(--paper); color: var(--muted); }
.checks li.warn::before { content: '!'; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.checks li.block::before { content: '×'; background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

/* ---------- side panel ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
@media (max-width: 1060px) { .panel { position: static; max-height: none; } }
.step { padding: 18px 20px 6px; border-bottom: 1px solid var(--line); }
.step h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step h2 span { font: 600 12px/22px var(--mono); width: 22px; height: 22px; text-align: center; border-radius: 50%; background: var(--ink); color: var(--paper); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 500 14px/1 var(--sans); border: 1px solid var(--line-strong); border-radius: 99px; padding: 8px 12px; background: var(--card); cursor: pointer; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip small { font-size: 11px; opacity: .7; margin-left: 4px; }
.cards { display: grid; gap: 8px; margin-bottom: 12px; }
.card-opt { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 9px; cursor: pointer; align-items: start; }
.card-opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: #fffaf2; }
.card-opt input { margin: 2px 0 0; width: auto; accent-color: var(--accent); }
.card-opt b { display: block; font-size: 14px; }
.card-opt small { color: var(--muted); font-size: 12.5px; line-height: 1.35; display: block; }
.card-opt.disabled { opacity: .55; cursor: not-allowed; }
.qty { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px; margin-bottom: 10px; }
.qty input { text-align: center; font: 600 18px/1 var(--mono); }
.qty .btn { padding: 0; font-size: 20px; }
.breaks { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 14px; }
.breaks caption { text-align: left; font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.breaks td { padding: 5px 6px; border-top: 1px solid var(--line); font-family: var(--mono); }
.breaks td:last-child { text-align: right; color: var(--muted); }
.breaks tr { cursor: pointer; }
.breaks tr:hover td { background: var(--paper); }
.breaks tr.on td { background: #fff3ea; font-weight: 600; color: var(--ink); }
.breaks .bar { height: 6px; background: var(--accent); border-radius: 3px; opacity: .75; }
.ship { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.ship label { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; cursor: pointer; align-items: start; }
.ship label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: #fffaf2; }
.ship input { margin: 2px 0 0; width: auto; accent-color: var(--accent); }
.ship b { font-size: 14px; display: block; }
.ship small { color: var(--muted); font-size: 12px; display: block; }
.ship .price { font: 600 14px/1.2 var(--mono); text-align: right; }
.ship .price small { font-family: var(--sans); font-weight: 400; }
.ship .na { opacity: .5; cursor: not-allowed; }
.zip-field input { font: 600 17px/1 var(--mono); letter-spacing: .12em; max-width: 160px; }
.zip-field input.bad { border-color: var(--bad); }
.ship .zip-hint { font-size: 13px; color: var(--muted); padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 9px; }
.rush { display: flex; gap: 10px; align-items: center; font-size: 14px; margin-bottom: 14px; }
.rush input { width: auto; accent-color: var(--accent); }
.rush em { color: var(--muted); font-style: normal; }

/* quote */
.quote { padding: 20px; background: var(--ink); color: var(--paper); border-radius: 0 0 14px 14px; }
.quote-empty { color: #b9b1a3; font-size: 14px; }
.q-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.q-total .amt { font: 900 44px/1 var(--sans); font-stretch: 70%; letter-spacing: -.02em; }
.q-total .each { font: 500 13px/1.3 var(--mono); color: #c9c1b3; text-align: right; }
.q-date { margin: 10px 0 16px; font-size: 15px; }
.q-date b { color: #ffb08f; }
.q-lines { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 16px; }
.q-lines td { padding: 5px 0; border-top: 1px solid #3a362f; vertical-align: top; }
.q-lines td small { display: block; color: #a39b8c; font-size: 11.5px; }
.q-lines td:last-child { text-align: right; font-family: var(--mono); white-space: nowrap; padding-left: 10px; }
.q-manual h3 { font-size: 24px; margin-bottom: 8px; }
.q-manual ul { padding-left: 18px; margin: 8px 0 16px; font-size: 14px; color: #e4dccd; }
.q-manual p { font-size: 14px; color: #c9c1b3; }
.q-fine { font-size: 12px; color: #a39b8c; margin: 10px 0 0; text-align: center; }
.q-loading { opacity: .55; transition: opacity .2s; }

/* ---------- info ---------- */
.info { max-width: 1180px; margin: 0 auto; padding: 56px clamp(16px, 4vw, 48px); border-top: 1px solid var(--line); }
.info h2 { font-size: clamp(32px, 4.5vw, 52px); font-weight: 900; font-stretch: 68%; margin-bottom: 24px; }
.how { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.how li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.how li::before { content: '0' counter(s); font: 600 13px/1 var(--mono); color: var(--accent); display: block; margin-bottom: 12px; }
.how b { display: block; font-size: 22px; font-stretch: 80%; margin-bottom: 6px; }
.how span { color: var(--muted); font-size: 15px; }
@media (max-width: 760px) { .how { grid-template-columns: 1fr; } }
.mat-table-wrap { overflow-x: auto; }
.mat-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.mat-table th, .mat-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mat-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pill { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); white-space: nowrap; }
.pill.lead { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.rules > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.rules h4 { font-size: 19px; margin-bottom: 6px; }
.rules p { margin: 0; color: var(--muted); font-size: 14.5px; }
.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 28px clamp(16px, 4vw, 48px); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); }
dialog::backdrop { background: rgba(29,27,23,.55); backdrop-filter: blur(2px); }
dialog form { padding: 22px 24px; }
dialog header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
dialog h2 { font-size: 28px; font-weight: 900; font-stretch: 70%; }
.x { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); }
.dlg-sum { font-size: 14px; color: var(--muted); margin: 0 0 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
dialog footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.form-err { color: var(--bad); font-size: 14px; }
.done { padding: 36px 28px; text-align: center; }
.done-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px; line-height: 56px; margin: 0 auto 14px; }
.done p { color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 100; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
