:root {
  --accent: #d42020;
  --ink: #111111;
  --muted: #57534e;
  --body: #44403c;
  --sheet: #e4e2dc;
  --part: #fbfaf7;
  --floor: #f4f3f0;
  --sans: 'IBM Plex Sans', Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #ffffff; color: var(--ink); font-family: var(--sans); }
body.no-scroll { overflow: hidden; }
a { color: #b91c1c; }
a:hover { color: var(--ink); }
img { max-width: 100%; }
[hidden] { display: none !important; }

.page { padding: 48px 20px 80px; }
.wrap { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.mono { font-family: var(--mono); }

/* ---------- header ---------- */
.hdr { border: 2px solid var(--ink); display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; background: var(--ink); color: #fff; font-family: var(--mono); font-size: 12px; }
.topbar .name { display: flex; align-items: center; gap: 10px; }
.topbar .dot { width: 10px; height: 10px; background: var(--accent); }
.topbar nav { display: flex; gap: 18px; }
.topbar a { color: #fff; }
.topbar a:hover { color: #ffb3b3; }

.intro { padding: 32px 24px 28px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; }
.intro-text { flex: 1 1 380px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.intro h1 { margin: 0; font-size: 40px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.intro h1 span { color: var(--accent); }
.intro p { margin: 0; font-size: 16px; color: var(--body); line-height: 1.6; max-width: 64ch; }
.printer { flex: 0 1 270px; min-width: 220px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.printer svg { width: 100%; max-width: 270px; height: auto; display: block; overflow: visible; }
.printer-cap { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 20px; border-top: 2px solid var(--ink); }
.filterbar .label, .filterbar .rev { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.filterbar .rev { margin-left: auto; }
#filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { all: unset; box-sizing: border-box; cursor: pointer; font-family: var(--mono); font-size: 12px; padding: 0 10px; min-height: 32px; display: inline-flex; align-items: center; border: 1px solid #a8a29e; background: #fff; color: var(--ink); }
.chip.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- laser sheet ---------- */
.sheet { position: relative; background-color: var(--sheet); background-image: radial-gradient(#c9c6bd 1px, transparent 1px); background-size: 16px 16px; border: 1px solid var(--ink); padding: 30px 24px 22px; display: flex; flex-direction: column; gap: 14px; }
.reg { position: absolute; width: 14px; height: 14px; border: 0 solid var(--ink); }
.reg.tl { top: 8px; left: 8px; border-top-width: 1.5px; border-left-width: 1.5px; }
.reg.tr { top: 8px; right: 8px; border-top-width: 1.5px; border-right-width: 1.5px; }
.reg.bl { bottom: 8px; left: 8px; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.reg.br { bottom: 8px; right: 8px; border-bottom-width: 1.5px; border-right-width: 1.5px; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--body); }
.sheet-head .right { display: flex; align-items: center; gap: 14px; }
.recut { all: unset; box-sizing: border-box; cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--ink); border-bottom: 1px solid var(--ink); min-height: 24px; display: inline-flex; align-items: center; }
.recut:hover { color: var(--accent); border-color: var(--accent); }
.recut:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.sheet-body { position: relative; }
.sheet-cta { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; pointer-events: none; }
.runbtn { all: unset; box-sizing: border-box; pointer-events: auto; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 20px; background: var(--ink); color: #fff; font-family: var(--mono); font-size: 14px; letter-spacing: .04em; box-shadow: 4px 4px 0 var(--accent); transition: transform .12s ease, box-shadow .12s ease; }
.runbtn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--accent); }
.runbtn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--accent); }
.runbtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.laserdot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px 2px var(--accent); }
.queued { font-family: var(--mono); font-size: 12px; color: var(--body); background: var(--sheet); padding: 2px 8px; }

.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); grid-auto-rows: minmax(132px, auto); grid-auto-flow: dense; gap: 8px; }
.tile { position: relative; min-width: 0; background: var(--part); border: 1px solid var(--accent); }
.tile.is-open { box-shadow: 4px 4px 0 var(--ink); }
.sp2 { grid-column: span 2; }
.rs2 { grid-row: span 2; }
.full { grid-column: 1 / -1; }
@media (max-width: 520px) { .sp2 { grid-column: span 1; } }

.tab { position: absolute; width: 12px; height: 3px; background: var(--sheet); left: 50%; margin-left: -6px; pointer-events: none; }
.tab.t { top: -2px; } .tab.b { bottom: -2px; }
.tabv { position: absolute; width: 3px; height: 12px; background: var(--sheet); top: 50%; margin-top: -6px; pointer-events: none; }
.tabv.l { left: -2px; } .tabv.r { right: -2px; }

.tilebtn { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 12px; transition: transform .15s ease, box-shadow .15s ease; }
.tilebtn:hover { transform: translate(-2px, -2px); box-shadow: 3px 3px 0 var(--ink); }
.tilebtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.tile-meta { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.part { color: var(--accent); }
.tile-cover { flex: 1 1 auto; min-height: 64px; width: 100%; object-fit: cover; object-position: top; display: block; border: 1px solid #d6d3d1; filter: grayscale(.15); }
.hatch { background: repeating-linear-gradient(45deg, #d8d4cb 0 1px, transparent 1px 7px); }
.tile-hatch { flex: 1 1 auto; min-height: 28px; }
.tile-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 600; line-height: 1.25; }
.tile-year { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); flex: 0 0 auto; }

.tile-open { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.tile-open-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tile-meta-line { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tile-open h2 { margin: 4px 0 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.tile-open p { margin: 0; font-size: 14px; line-height: 1.6; max-width: 64ch; }
.closebtn { all: unset; box-sizing: border-box; cursor: pointer; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 18px; color: #fff; background: var(--accent); }
.closebtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.figs figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.figs figcaption { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.figbtn { all: unset; box-sizing: border-box; display: block; width: 100%; cursor: zoom-in; }
.figbtn img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; border: 1px solid #d6d3d1; display: block; }
.figbtn:hover img { border-color: var(--ink); }
.figbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fig-video video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border: 1px solid #d6d3d1; display: block; }
.photos-soon { height: 120px; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.photos-soon span { background: var(--part); padding: 2px 6px; }
.specs { display: flex; flex-wrap: wrap; gap: 6px 24px; font-family: var(--mono); font-size: 12px; }
.specs .k { color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: center; font-family: var(--mono); font-size: 11px; color: var(--body); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cut { width: 20px; height: 0; border-top: 1px solid var(--accent); }
.legend .eng { width: 20px; height: 10px; background: repeating-linear-gradient(45deg, #b9b5ab 0 1px, transparent 1px 4px); }

/* laser-cut reveal: tiles stay under a dashed toolpath preview until "Send to laser" */
.cover { position: absolute; inset: -2px; background: var(--sheet); border: 1px dashed #a9a59b; z-index: 2; }
.ln { position: absolute; background: var(--accent); box-shadow: 0 0 4px var(--accent); z-index: 3; pointer-events: none; opacity: 0; animation-duration: 1s; animation-timing-function: linear; animation-fill-mode: both; animation-delay: var(--d); }
.ln.t { top: -1px; left: -1px; right: -1px; height: 1px; transform-origin: left; }
.ln.r { top: -1px; bottom: -1px; right: -1px; width: 1px; transform-origin: top; }
.ln.b { bottom: -1px; left: -1px; right: -1px; height: 1px; transform-origin: right; }
.ln.l { top: -1px; bottom: -1px; left: -1px; width: 1px; transform-origin: bottom; }
.laser { position: absolute; left: 0; top: 0; width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px var(--accent), 0 0 12px 4px var(--accent); transform: translate(-50%, -50%); z-index: 4; pointer-events: none; opacity: 0; }

/* two identical sets so "Recut" restarts the animation */
@keyframes coverOff1 { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
@keyframes lnT1 { 0% { transform: scaleX(0); opacity: 1; } 24% { transform: scaleX(1); } 98% { opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes lnR1 { 0%, 24% { transform: scaleY(0); opacity: 1; } 48% { transform: scaleY(1); } 98% { opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
@keyframes lnB1 { 0%, 48% { transform: scaleX(0); opacity: 1; } 72% { transform: scaleX(1); } 98% { opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes lnL1 { 0%, 72% { transform: scaleY(0); opacity: 1; } 96% { transform: scaleY(1); } 98% { opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
@keyframes laserPath1 { 0% { left: 0; top: 0; opacity: 0; } 1% { left: 0; top: 0; opacity: 1; } 24% { left: 100%; top: 0; } 48% { left: 100%; top: 100%; } 72% { left: 0; top: 100%; } 96% { left: 0; top: 0; opacity: 1; } 100% { left: 0; top: 0; opacity: 0; } }
@keyframes coverOff2 { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
@keyframes lnT2 { 0% { transform: scaleX(0); opacity: 1; } 24% { transform: scaleX(1); } 98% { opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes lnR2 { 0%, 24% { transform: scaleY(0); opacity: 1; } 48% { transform: scaleY(1); } 98% { opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
@keyframes lnB2 { 0%, 48% { transform: scaleX(0); opacity: 1; } 72% { transform: scaleX(1); } 98% { opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes lnL2 { 0%, 72% { transform: scaleY(0); opacity: 1; } 96% { transform: scaleY(1); } 98% { opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
@keyframes laserPath2 { 0% { left: 0; top: 0; opacity: 0; } 1% { left: 0; top: 0; opacity: 1; } 24% { left: 100%; top: 0; } 48% { left: 100%; top: 100%; } 72% { left: 0; top: 100%; } 96% { left: 0; top: 0; opacity: 1; } 100% { left: 0; top: 0; opacity: 0; } }
.run1 .cover { pointer-events: none; animation: coverOff1 .35s ease calc(var(--d) + 0.95s) both; }
.run1 .ln.t { animation-name: lnT1; } .run1 .ln.r { animation-name: lnR1; } .run1 .ln.b { animation-name: lnB1; } .run1 .ln.l { animation-name: lnL1; }
.run1 .laser { animation: laserPath1 1s linear var(--d) both; }
.run2 .cover { pointer-events: none; animation: coverOff2 .35s ease calc(var(--d) + 0.95s) both; }
.run2 .ln.t { animation-name: lnT2; } .run2 .ln.r { animation-name: lnR2; } .run2 .ln.b { animation-name: lnB2; } .run2 .ln.l { animation-name: lnL2; }
.run2 .laser { animation: laserPath2 1s linear var(--d) both; }
/* after the cut has played, later re-renders show the finished sheet */
.cut-done .cover, .cut-done .ln, .cut-done .laser { display: none; }

/* ---------- toolkit conveyor ---------- */
.toolkit { border: 2px solid var(--ink); display: flex; flex-direction: column; }
.toolkit-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 20px; background: var(--ink); color: #fff; font-family: var(--mono); font-size: 12px; }
.toolkit-bar .sub { color: #c9c6bd; }
.conveyor { background: var(--floor); padding: 8px 0; }
.conveyor-svg { width: 100%; height: auto; display: block; }
.toolkit-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 20px; border-top: 2px solid var(--ink); font-family: var(--mono); font-size: 12px; color: var(--body); }
.scanbeam { animation: scanPulse 1.6s ease-in-out infinite; }
@keyframes scanPulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.cv-static, .pr-static { display: none; }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 10, .92); display: flex; flex-direction: column; padding: 20px; gap: 14px; }
.lb-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; color: #fff; }
.lb-count { color: #b5b5b5; }
.lb-stage { all: unset; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border: 1px solid #3a3a3a; }
.lb-nav { display: flex; justify-content: center; gap: 8px; }
.lbbtn { all: unset; box-sizing: border-box; cursor: pointer; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; font-family: var(--mono); font-size: 13px; color: #fff; border: 1px solid #6b6b6b; background: var(--ink); }
.lbbtn:hover { border-color: #fff; }
.lbbtn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ln, .laser { display: none; }
  .run1 .cover, .run2 .cover { display: none; }
  .runbtn, .tilebtn { transition: none; }
  .tilebtn:hover { transform: none; }
  .scanbeam { animation: none; }
  .cv-anim, .pr-anim { display: none; }
  .cv-static, .pr-static { display: inline; }
}

@media (max-width: 560px) {
  .page { padding: 20px 12px 48px; }
  .intro h1 { font-size: 32px; }
  .sheet { padding: 28px 12px 18px; }
}
