/* Designitudle — 8-bit drafting arcade.
   Layout: a cabinet on a starfield. Print + inspection on the left, workshop on the right.
   Palette is PICO-8; hard 4px borders, pixel-step corners, hard drop shadows, no blur anywhere.
   Single deliberate visual world (dark cabinet, light panels), so there is no light/dark switch. */
:root {
  color-scheme: dark;
  --k: #000000;
  --navy: #1d2b53;
  --plum: #7e2553;
  --green-d: #008751;
  --brown: #ab5236;
  --gray-d: #5f574f;
  --gray: #c2c3c7;
  --white: #fff1e8;
  --red: #ff004d;
  --orange: #ffa300;
  --yellow: #ffec27;
  --green: #00e436;
  --blue: #29adff;
  --lav: #83769c;
  --pink: #ff77a8;
  --peach: #ffccaa;
  --ink: #000000;
  --paper: #fff1e8;
  --well: #e7dccf;
  --f-display: "Press Start 2P", "Courier New", monospace;
  --f-pixel: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "VT323", ui-monospace, Menlo, monospace;
  --f-draw: "Barlow Condensed", "Arial Narrow", sans-serif;
  --px: 4px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
img { max-width: 100%; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { background: var(--navy); }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font-family: var(--f-body); font-size: 17px; line-height: 1.4;
  background-color: var(--navy);
  background-image:
    radial-gradient(var(--blue) 1px, transparent 1.5px),
    radial-gradient(var(--white) 1px, transparent 1.5px),
    linear-gradient(rgba(0,0,0,.18) 50%, transparent 50%);
  background-size: 97px 89px, 151px 131px, 100% 4px;
  background-position: 13px 7px, 61px 43px, 0 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 14px 48px;
  image-rendering: pixelated;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 4px solid var(--yellow); outline-offset: 2px; }
.app { max-width: 1340px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

/* pixel-step frame: a 4px black border with notched corners, plus a hard drop shadow */
.px {
  position: relative; background: var(--paper);
  clip-path: polygon(0 var(--px), var(--px) var(--px), var(--px) 0, calc(100% - var(--px)) 0, calc(100% - var(--px)) var(--px), 100% var(--px), 100% calc(100% - var(--px)), calc(100% - var(--px)) calc(100% - var(--px)), calc(100% - var(--px)) 100%, var(--px) 100%, var(--px) calc(100% - var(--px)), 0 calc(100% - var(--px)));
  box-shadow: inset 0 0 0 4px var(--k);
}
.shadow { filter: drop-shadow(6px 6px 0 var(--k)); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; color: var(--white); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.sprite { width: 64px; height: 64px; flex: none; image-rendering: pixelated; }
.sprite.hop { animation: hop .5s steps(5) 1; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12px); } 70% { transform: translateY(-4px); } }
.logo { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(17px, 4.2vw, 34px); line-height: 1.15; letter-spacing: 0; color: var(--yellow); text-shadow: 4px 4px 0 var(--plum), 8px 8px 0 var(--k); word-break: break-all; }
.logo span { color: var(--blue); }
.sub { font-family: var(--f-pixel); font-weight: 600; font-size: 13px; color: var(--peach); margin-top: 10px; letter-spacing: .04em; line-height: 1.6; }
.sub b { color: var(--yellow); font-weight: 400; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.selwrap { display: inline-flex; align-items: center; gap: 8px; background: var(--k); color: var(--white); padding: 6px 10px; box-shadow: 0 0 0 4px var(--blue); font-family: var(--f-pixel); font-weight: 600; font-size: 13px; }
.selwrap select { background: var(--k); border: 0; color: var(--yellow); font-family: var(--f-pixel); font-weight: 600; font-size: 13px; padding: 4px 0; max-width: 62vw; }

/* ---------- buttons ---------- */
.btn { --b: var(--gray); --t: var(--k); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: var(--b); color: var(--t);
  padding: 11px 14px 10px; font-family: var(--f-pixel); font-weight: 600; font-size: 14px; line-height: 1.2; text-transform: uppercase;
  box-shadow: inset 0 0 0 4px var(--k), inset -4px -8px 0 rgba(0,0,0,.22), 4px 4px 0 var(--k); }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translate(4px, 4px); box-shadow: inset 0 0 0 4px var(--k), inset 4px 4px 0 rgba(0,0,0,.22); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.y { --b: var(--yellow); }
.btn.r { --b: var(--red); --t: var(--white); }
.btn.g { --b: var(--green); }
.btn.b { --b: var(--blue); }
.btn.k { --b: var(--k); --t: var(--white); box-shadow: inset 0 0 0 4px var(--lav), 4px 4px 0 var(--plum); }
.btn.big { padding: 15px 18px 14px; font-size: 13px; }
.btn.sm { padding: 8px 10px 7px; font-size: 9px; }
.btn svg { width: 16px; height: 16px; shape-rendering: crispEdges; }

/* ---------- layout ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr); gap: 26px; align-items: start; min-width: 0; max-width: 100%; }
.col { display: flex; flex-direction: column; gap: 26px; min-width: 0; }
@media (max-width: 980px) { .grid { display: flex; flex-direction: column; } .col { display: contents; } .print { order: 1; } .shop { order: 2; } .board { order: 3; } }
.card { min-width: 0; max-width: 100%; }
.card > .px { padding-bottom: 4px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 10px; flex-wrap: wrap; }
.card-h h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 14px; display: flex; align-items: center; gap: 10px; text-transform: uppercase; }
.card-h h2 i { width: 12px; height: 12px; background: var(--red); box-shadow: 0 0 0 3px var(--k); display: inline-block; }
.hint { font-size: 15px; color: var(--gray-d); }
.bar { height: 12px; background: repeating-linear-gradient(90deg, var(--k) 0 4px, transparent 4px 8px); opacity: .12; margin: 0 18px; }

/* ---------- print ---------- */
.print-scroll { overflow-x: auto; padding: 4px 16px 8px; }
.sheet { background: #fff; padding: 6px; box-shadow: 0 0 0 4px var(--k), 6px 6px 0 4px var(--lav); margin: 4px; }
.drawing { display: block; width: 100%; height: auto; }
.drawing text { font-family: var(--f-draw); fill: #12182e; }
.d-vis { stroke: #12182e; stroke-width: .45; fill: none; stroke-linecap: square; stroke-linejoin: miter; }
.d-hid { stroke: #12182e; stroke-width: .28; fill: none; stroke-dasharray: 1.6 .9; }
.d-ctr { stroke: var(--red); stroke-width: .16; stroke-dasharray: 5 1 .8 1; }
.d-dim { stroke: #4a5068; stroke-width: .14; fill: none; }
.d-thd { stroke: #12182e; stroke-width: .2; fill: none; }
.d-hidthd { stroke-dasharray: 1 .7; }
.d-frame { fill: none; stroke: #12182e; stroke-width: .35; }
.d-box, .d-sym { fill: none; stroke: #12182e; stroke-width: .28; }
.d-rule { stroke: #12182e; stroke-width: .18; }
.d-datum { fill: #12182e; }
.drawing .d-num { font-size: 2.5px; font-weight: 600; }
.drawing .d-tag { font-size: 2.6px; font-weight: 700; fill: #1b6fd6; }
.drawing .d-view { font-size: 2.3px; font-weight: 700; letter-spacing: .3px; fill: #4a5068; }
.drawing .d-thead { font-size: 2.1px; font-weight: 700; letter-spacing: .25px; }
.drawing .d-th { font-size: 1.85px; font-weight: 700; fill: #4a5068; }
.drawing .d-td { font-size: 2.15px; font-weight: 500; }
.drawing .d-tagc { fill: #1b6fd6; font-weight: 700; }
.drawing .d-tk { font-size: 1.7px; font-weight: 700; letter-spacing: .25px; fill: #4a5068; }
.drawing .d-tv { font-size: 2.8px; font-weight: 600; }
.err-cell { fill: var(--red); opacity: .65; }
.print-foot { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 18px 18px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.toggle input { accent-color: var(--red); width: 18px; height: 18px; }
.tip { margin: 0 18px 18px; padding: 12px 14px; background: var(--k); color: var(--yellow); font-family: var(--f-body); font-size: 16px; box-shadow: inset 0 0 0 3px var(--orange); }
.tip::before { content: "TIP> "; font-family: var(--f-pixel); font-weight: 600; font-size: 13px; color: var(--orange); }
.swipe { display: none; font-size: 14px; color: var(--gray-d); }
@media (max-width: 680px) { .swipe { display: inline; } }
.stars { font-family: var(--f-pixel); font-weight: 600; font-size: 13px; color: var(--orange); letter-spacing: 2px; }

/* ---------- workshop ---------- */
.shop > .px { display: flex; flex-direction: column; }
.stage { position: relative; height: clamp(320px, 52vh, 520px); margin: 4px 16px 0; overflow: hidden; background: var(--navy); box-shadow: 0 0 0 4px var(--k); touch-action: none; }
.stage canvas.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage svg.sk { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #10183a; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.stage svg.sk.pan { cursor: grab; }

.stage-tools { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; pointer-events: none; z-index: 2; }
.stage-tools > * { pointer-events: auto; }
.chip { border: 0; padding: 6px 8px 5px; background: var(--k); color: var(--white); font-family: var(--f-pixel); font-weight: 600; font-size: 12px; box-shadow: inset 0 0 0 2px var(--lav); }
.chip.on { background: var(--yellow); color: var(--k); box-shadow: inset 0 0 0 2px var(--k), 3px 3px 0 var(--k); }
.stage-note { position: absolute; left: 10px; top: 44px; font-family: var(--f-num); font-size: 18px; color: var(--green); background: rgba(0,0,0,.7); padding: 0 8px; pointer-events: none; z-index: 2; }
.stage-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; pointer-events: none; z-index: 2; }
.stage-empty div { background: var(--k); color: var(--white); padding: 16px 18px; max-width: 330px; box-shadow: inset 0 0 0 4px var(--yellow), 6px 6px 0 var(--plum); }
.stage-empty b { font-family: var(--f-display); font-weight: 400; font-size: 12px; color: var(--yellow); display: block; margin-bottom: 10px; }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dock { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px; background: var(--k); box-shadow: inset 0 0 0 3px var(--lav), 4px 4px 0 var(--plum); z-index: 2; }
.dock-btn { border: 0; background: transparent; width: 56px; padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--f-pixel); font-weight: 600; font-size: 11px; color: var(--white); }
.dock-btn svg { width: 22px; height: 22px; }
.dock-btn.on { background: var(--yellow); color: var(--k); box-shadow: inset 0 0 0 2px var(--k); }
.spacer { flex: 1; }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.chip.undo:not(:disabled) { box-shadow: inset 0 0 0 2px var(--orange); color: var(--orange); }
/* number-entry bar: exact values while sketching */
.dimbar { position: absolute; left: 10px; top: 44px; right: 10px; z-index: 3; display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; width: max-content; max-width: calc(100% - 20px); background: rgba(0,0,0,.88); padding: 8px 10px; box-shadow: inset 0 0 0 2px var(--yellow), 4px 4px 0 var(--plum); }
.dimbar .dt { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; color: var(--white); align-self: center; text-transform: uppercase; }
.dimbar label { display: flex; flex-direction: column; gap: 3px; font-family: var(--f-pixel); font-weight: 600; font-size: 11px; color: var(--yellow); text-transform: uppercase; }
.dimbar input { width: 78px; background: #000; border: 0; color: var(--green); font-family: var(--f-num); font-size: 24px; line-height: 1; padding: 3px 6px 1px; box-shadow: inset 0 0 0 2px var(--gray-d); }
.dimbar input.typed { color: var(--yellow); box-shadow: inset 0 0 0 2px var(--yellow); }
.dimbar input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--blue); }
.dimbar input.bad { color: var(--red); box-shadow: inset 0 0 0 2px var(--red); }
.dimbar .btn { align-self: flex-end; }
.dimbar .read { flex-basis: 100%; font-family: var(--f-num); font-size: 15px; color: var(--green); line-height: 1; }

.panel { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.tree { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.feat { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; background: var(--well); box-shadow: inset 0 0 0 3px var(--k); }
.badge { width: 36px; height: 36px; display: grid; place-items: center; color: var(--white); flex: none; box-shadow: inset 0 0 0 3px var(--k); }
.badge.join { background: var(--blue); color: var(--k); }
.badge.cut { background: var(--red); }
.badge svg { width: 18px; height: 18px; }
.feat .txt { min-width: 0; flex: 1; border: 0; background: none; text-align: left; padding: 0; }
.feat .txt b { font-family: var(--f-pixel); font-weight: 600; font-size: 13px; display: block; margin-bottom: 4px; }
.feat .txt span { font-size: 15px; color: var(--gray-d); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { border: 0; background: transparent; width: 32px; height: 32px; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--yellow); box-shadow: inset 0 0 0 2px var(--k); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; box-shadow: none; }
.icon-btn svg { width: 18px; height: 18px; }
.empty-tree { padding: 14px; background: repeating-linear-gradient(45deg, var(--well) 0 8px, var(--paper) 8px 16px); box-shadow: inset 0 0 0 3px var(--k); text-align: center; font-size: 16px; }
.row-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.msg { font-size: 16px; min-height: 1.4em; }
.msg.bad { color: var(--red); }
.group { background: var(--well); box-shadow: inset 0 0 0 3px var(--k); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.group h3 { margin: 0; font-family: var(--f-pixel); font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 10px; text-transform: uppercase; }
.group h3 .step { width: 22px; height: 22px; background: var(--k); color: var(--yellow); display: grid; place-items: center; font-size: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > span { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; line-height: 1.4; text-transform: uppercase; }
.fld input, .fld select { width: 100%; min-width: 0; border: 0; background: var(--k); color: var(--green); padding: 4px 8px 2px; font-family: var(--f-num); font-size: 22px; line-height: 1; box-shadow: inset 0 0 0 3px var(--gray-d); font-variant-numeric: tabular-nums; }
.fld input:focus, .fld select:focus { outline: none; box-shadow: inset 0 0 0 3px var(--yellow); }
.fld input.bad { color: var(--red); box-shadow: inset 0 0 0 3px var(--red); }
.seg { display: inline-flex; gap: 0; flex-wrap: wrap; box-shadow: inset 0 0 0 3px var(--k); background: var(--paper); padding: 3px; }
.seg button { border: 0; padding: 8px 10px 7px; background: transparent; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.seg button.on { background: var(--k); color: var(--yellow); }
.seg button.on.cut { background: var(--red); color: var(--white); }
.seg button.on.join { background: var(--blue); color: var(--k); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.verts { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) 32px; gap: 6px; align-items: center; max-height: 230px; overflow: auto; }
.verts .vn { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; }
.verts input { width: 100%; min-width: 0; border: 0; background: var(--k); color: var(--green); padding: 2px 6px; font-family: var(--f-num); font-size: 20px; box-shadow: inset 0 0 0 3px var(--gray-d); }
.small { font-size: 15px; margin: 0; }
.small b { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; }

/* ---------- inspection ---------- */
.hud { margin: 0 18px 8px; padding: 12px; background: var(--k); color: var(--white); box-shadow: inset 0 0 0 3px var(--lav); }
.hud-top { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--f-pixel); font-weight: 600; font-size: 13px; }
.hud-top b { font-family: var(--f-num); font-size: 30px; font-weight: 400; color: var(--green); line-height: 1; }
.hp { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; margin-top: 10px; }
.hp i { height: 16px; background: #26304f; }
.hp i.on { background: var(--green); box-shadow: inset 0 -4px 0 var(--green-d); }
.hp i.on.mid { background: var(--yellow); box-shadow: inset 0 -4px 0 var(--orange); }
.hp i.on.low { background: var(--red); box-shadow: inset 0 -4px 0 var(--plum); }
.rows { padding: 10px 18px 6px; display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: 22px repeat(var(--nt, 5), minmax(0, 1fr)) 66px; gap: 8px; align-items: center; }
.row .n { font-family: var(--f-pixel); font-weight: 600; font-size: 13px; }
.tile { height: 52px; display: grid; place-items: center; align-content: center; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; line-height: 1; background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(0,0,0,.07) 6px 8px); box-shadow: inset 0 0 0 3px var(--gray); }
.tile.ok { background: var(--green); box-shadow: inset 0 0 0 4px var(--k), inset -4px -6px 0 var(--green-d); }
.tile.near { background: var(--yellow); box-shadow: inset 0 0 0 4px var(--k), inset -4px -6px 0 var(--orange); }
.tile.miss { background: var(--lav); color: var(--white); box-shadow: inset 0 0 0 4px var(--k), inset -4px -6px 0 var(--gray-d); }
.tile small { display: block; font-size: 10px; margin-top: 4px; }
.tile.pop { animation: pop .42s steps(4) both; }
@keyframes pop { 0% { transform: scale(.2); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@media (max-width: 480px) { .tile { font-size: 7px; height: 44px; } .row { gap: 5px; grid-template-columns: 18px repeat(var(--nt, 5), minmax(0, 1fr)) 52px; } }
.row .score { font-family: var(--f-num); font-size: 22px; text-align: right; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 18px 16px; font-size: 15px; }
.legend i { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; box-shadow: inset 0 0 0 2px var(--k); }
.end { margin: 0 18px 18px; padding: 16px; background: var(--k); color: var(--white); box-shadow: inset 0 0 0 4px var(--yellow); display: flex; flex-direction: column; gap: 12px; }
.end h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 16px; line-height: 1.4; color: var(--yellow); }
.end.lost h3 { color: var(--red); }
.end p { margin: 0; }
.acts { display: flex; gap: 12px; flex-wrap: wrap; }
.countdown { padding: 0 18px 20px; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; }
.countdown b { font-family: var(--f-num); font-size: 24px; font-weight: 400; color: var(--plum); vertical-align: -3px; }

/* ---------- modals ---------- */
.scrim { position: fixed; inset: 0; background: rgba(29, 43, 83, .82); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { max-width: 600px; width: 100%; max-height: 88vh; overflow: auto; padding: 22px 24px; }
.modal h3 { margin: 0 0 12px; font-family: var(--f-display); font-weight: 400; font-size: 18px; line-height: 1.3; }
.modal h4 { margin: 18px 0 6px; font-family: var(--f-pixel); font-weight: 600; font-size: 14px; color: var(--plum); }
.modal p, .modal li { max-width: 64ch; }
.modal ul { padding-left: 20px; margin: 4px 0; display: flex; flex-direction: column; gap: 4px; list-style: square; }
.modal .close { float: right; margin-left: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin: 12px 0; }
.stats div { background: var(--k); color: var(--white); padding: 10px 4px; }
.stats b { display: block; font-family: var(--f-num); font-size: 34px; font-weight: 400; color: var(--yellow); line-height: 1; }
.stats span { font-family: var(--f-pixel); font-weight: 600; font-size: 11px; }
.dist { display: flex; flex-direction: column; gap: 6px; }
.dist div { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: center; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; }
.dist em { font-style: normal; background: var(--lav); color: var(--white); padding: 4px 6px; min-width: 28px; text-align: right; }
.dist em.me { background: var(--green); color: var(--k); }
kbd { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; background: var(--k); color: var(--yellow); padding: 2px 5px; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; image-rendering: pixelated; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--k); color: var(--yellow); padding: 12px 16px; font-family: var(--f-pixel); font-weight: 600; font-size: 13px; line-height: 1.5; z-index: 70; box-shadow: inset 0 0 0 3px var(--yellow), 5px 5px 0 var(--plum); max-width: calc(100vw - 32px); }
.foot { color: var(--peach); font-size: 15px; text-align: center; }
.foot a { color: var(--yellow); }
@media (prefers-reduced-motion: reduce) { .tile.pop, .sprite.hop, .blink, .sprite[class*='t-'] { animation: none !important; } }

/* ---------- ribbon (Inventor-style command bar) ---------- */
.ribbon { margin: 0 16px 8px; background: var(--k); color: var(--white); box-shadow: inset 0 0 0 3px var(--lav); overflow-x: auto; }
.rb-tabs { display: flex; gap: 2px; align-items: stretch; background: #10183a; padding: 4px 4px 0; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; }
.rb-tabs > span { padding: 6px 10px 5px; color: var(--lav); }
.rb-tabs > span.on { background: var(--k); color: var(--yellow); box-shadow: inset 0 3px 0 var(--yellow); }
.rb-tabs .rb-mode { margin-left: auto; color: var(--green); text-transform: uppercase; }
.rb-body { display: flex; gap: 0; padding: 6px 4px 4px; min-width: max-content; }
.rb-grp { display: flex; flex-direction: column; align-items: stretch; padding: 0 6px; border-right: 2px solid #26304f; }
.rb-grp:last-child { border-right: 0; }
.rb-row { display: flex; gap: 2px; }
.rb-cap { font-family: var(--f-pixel); font-weight: 600; font-size: 10px; color: var(--lav); text-align: center; text-transform: uppercase; margin-top: 4px; letter-spacing: .04em; }
.rb { border: 0; background: transparent; color: var(--white); min-width: 58px; padding: 5px 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--f-pixel); font-weight: 600; font-size: 11px; line-height: 1.25; text-align: center; }
.rb svg { width: 22px; height: 22px; }
.rb.big { min-width: 74px; }
.rb.big svg { width: 28px; height: 28px; }
.rb:hover:not(:disabled) { background: #26304f; }
.rb.on { background: var(--yellow); color: var(--k); box-shadow: inset 0 0 0 2px var(--k); }
.rb.green { color: var(--green); }
.rb.red { color: var(--red); }
.rb:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- view cube ---------- */
.vc-wrap { position: absolute; top: 8px; right: 8px; z-index: 3; width: 112px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.viewcube { width: 104px; height: 104px; display: block; cursor: grab; touch-action: none; background: radial-gradient(circle, rgba(255,255,255,.08), transparent 70%); }
.vc-home { border: 0; background: var(--k); color: var(--yellow); width: 30px; height: 26px; font-size: 16px; box-shadow: inset 0 0 0 2px var(--lav); position: absolute; top: 0; left: 0; }

/* status bar along the bottom of the viewport */
.stage .stage-note { left: 0; right: 0; bottom: 0; top: auto; padding: 2px 10px; font-size: 16px; background: rgba(0,0,0,.82); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- model browser ---------- */
.browser { background: var(--well); box-shadow: inset 0 0 0 3px var(--k); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.br-head { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; padding: 2px 4px; color: var(--plum); }
.br-row { display: flex; align-items: center; gap: 6px; font-size: 15px; padding: 3px 6px; border: 0; background: none; text-align: left; width: 100%; }
.br-row span { color: var(--gray-d); }
.br-row svg { width: 16px; height: 16px; flex: none; }
.br-origin summary { cursor: pointer; font-size: 15px; padding: 3px 6px; }
.br-origin summary span { color: var(--gray-d); font-size: 13px; }
.br-plane { padding-left: 22px; }
.br-plane:hover, .br-sketch:hover { background: var(--yellow); }
.br-sketch { padding-left: 34px; font-size: 14px; }
.br-end { color: var(--red); font-family: var(--f-pixel); font-weight: 600; font-size: 12px; padding: 6px; }
.feat { flex-direction: column; align-items: stretch; gap: 2px; padding: 6px; }
.feat-row { display: flex; align-items: center; gap: 8px; }
.feat.supp .feat-row b, .feat.supp .feat-row span { text-decoration: line-through; opacity: .55; }
.feat.dragging { opacity: .45; }
.feat.drop-above { box-shadow: inset 0 4px 0 var(--blue), inset 0 0 0 3px var(--k); }
.feat .grip { cursor: grab; font-family: var(--f-pixel); font-weight: 600; font-size: 13px; color: var(--gray-d); padding: 0 2px; user-select: none; }

/* ---------- print zoom ---------- */
.zoombar { display: flex; gap: 8px; align-items: center; padding: 0 18px 8px; flex-wrap: wrap; }
.zoombar .zl { font-family: var(--f-num); font-size: 22px; min-width: 52px; text-align: center; }
.print-scroll { max-height: 72vh; overflow: auto; touch-action: pan-x pan-y; }
.print-scroll.zoomed { cursor: grab; }
.print-scroll .sheet { width: 100%; min-width: 0; }
.print-scroll.big { max-height: calc(88vh - 80px); padding: 4px; }
.modal.wide { max-width: min(1400px, 96vw); padding: 14px; }
.modal.wide .zoombar { padding: 0 0 10px; }
.d-isobox { fill: #f6f7fa; stroke: #12182e; stroke-width: .2; }
.drawing .d-num { font-size: 2.9px; }
.drawing .d-td { font-size: 2.3px; }
.drawing .d-tag { font-size: 2.9px; }
@media (max-width: 680px) { .sheet { min-width: 0; } }
@media (max-width: 480px) { .feat .grip { display: none; } .rb { min-width: 50px; } }

/* dimension input: one compact strip docked bottom-left, see-through until you use it */
.dimbar { left: 8px !important; top: auto !important; bottom: 30px; right: auto; flex-wrap: nowrap; align-items: center; gap: 6px; padding: 4px 6px; max-width: calc(100% - 16px); overflow-x: auto;
  background: rgba(0,0,0,.45); box-shadow: inset 0 0 0 1px rgba(255,236,39,.5); opacity: .8; transition: opacity .15s, background .15s; }
.dimbar:hover, .dimbar:focus-within { opacity: 1; background: rgba(0,0,0,.88); box-shadow: inset 0 0 0 2px var(--yellow); }
.dimbar label { flex-direction: row; align-items: center; gap: 4px; font-size: 6px; white-space: nowrap; }
.dimbar input { width: 58px; font-size: 19px; padding: 1px 4px 0; background: rgba(0,0,0,.6); }
.dimbar .dt { font-size: 7px; white-space: nowrap; }
.dimbar .btn.sm { padding: 5px 7px 4px; font-size: 7px; box-shadow: inset 0 0 0 2px var(--k), 2px 2px 0 var(--k); }
.dimbar .read { flex-basis: auto; font-size: 14px; white-space: nowrap; opacity: .8; }
.dock { bottom: 30px; }
@media (max-width: 560px) { .dimbar .read { display: none; } .dimbar input { width: 48px; } }

/* about: crawlable description for search engines and new visitors */
.about { padding: 22px 24px 18px; color: var(--ink); }
.about h2 { margin: 0 0 12px; font-family: var(--f-display); font-weight: 400; font-size: 14px; color: var(--plum); }
.about h3 { margin: 0 0 6px; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; line-height: 1.5; }
.about p { margin: 0 0 10px; max-width: 75ch; }
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.about-grid > div { background: var(--well); box-shadow: inset 0 0 0 3px var(--k); padding: 12px 14px; }
.about-grid p { margin: 0; font-size: 15px; }

/* build timer */
.timer-wrap { display: inline-flex; align-items: center; gap: 8px; background: var(--k); padding: 2px 10px 0; box-shadow: inset 0 0 0 2px var(--lav); }
.tlab { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; color: var(--lav); }
.timer { font-family: var(--f-num); font-weight: 400; font-size: 28px; line-height: 1; color: var(--gray-d); min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.timer.run { color: var(--green); }
.timer.won { color: var(--yellow); }
.timer.lost { color: var(--red); }

/* learn: step-by-step solution */
.learn-cta { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center; background: #10183a; padding: 12px 14px; box-shadow: inset 0 0 0 3px var(--green); }
.learn-cta b { font-family: var(--f-pixel); font-weight: 600; font-size: 13px; color: var(--green); grid-column: 1; }
.learn-cta span { grid-column: 1; font-size: 15px; color: var(--white); }
.learn-cta .btn { grid-column: 2; grid-row: 1 / span 2; }
@media (max-width: 560px) { .learn-cta { grid-template-columns: 1fr; } .learn-cta .btn { grid-column: 1; grid-row: auto; } }
.modal.learn { max-width: min(1180px, 96vw); }
.lr-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.lr-head h3 { margin: 0; }
.lr-label { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; color: var(--plum); }
.lr-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.lr-dot { width: 34px; height: 30px; border: 0; font-family: var(--f-pixel); font-weight: 600; font-size: 13px; background: var(--well); box-shadow: inset 0 0 0 3px var(--k); }
.lr-dot.join { border-bottom: 5px solid var(--yellow); }
.lr-dot.cut { border-bottom: 5px solid var(--red); }
.lr-dot.done { background: #d9f7e3; }
.lr-dot.on { background: var(--k); color: var(--yellow); }
.lr-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 820px) { .lr-grid { grid-template-columns: minmax(0, 1fr); } }
.lr-pics { display: grid; gap: 12px; }
.lr-pics figure { margin: 0; background: #fff; box-shadow: inset 0 0 0 3px var(--k); padding: 8px; }
.lr-pics figcaption { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; color: var(--plum); margin: 2px 2px 8px; }
.lr-pics svg, .lr-pics img { display: block; width: 100%; height: auto; max-height: 300px; object-fit: contain; }
.modal .lr-title { margin: 0 0 12px; font-family: var(--f-pixel); font-weight: 600; font-size: 15px; line-height: 1.5; color: var(--k); }
.lr-list { margin: 0 0 12px; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.lr-list ul { margin: 6px 0 0; padding-left: 18px; list-style: square; display: flex; flex-direction: column; gap: 4px; }
.lr-box { background: var(--well); box-shadow: inset 0 0 0 3px var(--k); padding: 10px 12px; margin-bottom: 10px; }
.lr-box h5 { margin: 0 0 6px; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; color: var(--plum); }
.lr-box p { margin: 0 0 6px; font-size: 16px; }
.lr-box p:last-child { margin-bottom: 0; }
.lr-box.habit { background: #fff6c2; }
.lr-box.done { background: #d9f7e3; }
.lr-nav { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

/* feature tools: sliders, warnings, pattern picker */
.slide { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; align-items: end; }
.slide input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 0 0 4px; cursor: ew-resize; }
.slide input[type=range]::-webkit-slider-runnable-track { height: 10px; background: var(--k); box-shadow: inset 0 0 0 2px var(--gray-d); }
.slide input[type=range]::-moz-range-track { height: 10px; background: var(--k); box-shadow: inset 0 0 0 2px var(--gray-d); }
.slide input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 26px; margin-top: -8px; background: var(--yellow); box-shadow: inset 0 0 0 3px var(--k); border: 0; }
.slide input[type=range]::-moz-range-thumb { width: 18px; height: 26px; border-radius: 0; background: var(--yellow); box-shadow: inset 0 0 0 3px var(--k); border: 0; }
.slide input[type=range]:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.warn { color: var(--red); }
.badge.thr { background: var(--orange, #ffa300); color: var(--k); }
.seg button svg { width: 14px; height: 14px; vertical-align: -3px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick-list .btn { justify-content: flex-start; text-align: left; gap: 10px; }
.pick-list .btn svg { width: 18px; height: 18px; flex: none; }
.pick-list .btn .small { opacity: .75; }
.lr-nosk { display: grid; place-items: center; gap: 10px; padding: 24px; background: #fbfaf6; min-height: 160px; text-align: center; color: #12182e; }
.lr-nosk svg { width: 56px; height: 56px; }
.lr-dot.thr { border-bottom: 5px solid #ffa300; }
/* training tutor */
.tutor { margin: 0 16px 10px; background: var(--paper); box-shadow: inset 0 0 0 3px var(--k), 4px 4px 0 var(--green); padding: 10px 12px; }
.tu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tu-tog { border: 0; background: none; padding: 0; text-align: left; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tu-tog b { font-family: var(--f-pixel); font-weight: 600; font-size: 13px; background: var(--green); color: var(--k); padding: 4px 6px 3px; }
.tu-tog span { font-size: 17px; font-weight: 600; }
.tu-tog em { font-style: normal; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; opacity: .7; }
.tu-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.tu-dots button { min-width: 28px; height: 26px; border: 0; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; background: var(--well); box-shadow: inset 0 0 0 2px var(--k); }
.tu-dots button.done { background: #d9f7e3; color: #0b6b2e; }
.tu-dots button.on { background: var(--k); color: var(--yellow); }
.tu-intro { margin-top: 10px; }
.tu-intro p { margin: 0 0 8px; font-size: 16px; }
.tu-skills { display: flex; flex-wrap: wrap; gap: 6px; }
.tu-skills span { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; background: var(--k); color: var(--yellow); padding: 4px 6px 3px; }
.tu-step h4 { margin: 12px 0 8px; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; color: var(--plum); line-height: 1.5; }
.tu-step .lr-list { font-size: 16px; }
.tu-step details { margin: 0 0 6px; background: var(--well); box-shadow: inset 0 0 0 2px var(--k); padding: 6px 10px; }
.tu-step summary { cursor: pointer; font-family: var(--f-pixel); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.tu-step details p { margin: 6px 0 0; font-size: 15px; }
.tu-status { margin: 8px 0 0; font-size: 15px; padding: 6px 10px; background: #10183a; color: var(--white); }
.tu-status.ok { background: #0b6b2e; }
.tu-done { margin-top: 10px; padding: 8px 10px; background: #d9f7e3; box-shadow: inset 0 0 0 3px #0b6b2e; font-size: 16px; }
.tu-done b { font-family: var(--f-pixel); font-weight: 600; font-size: 12px; }
.tu-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* fillet / chamfer */
.badge.mod { background: var(--peach, #ffccaa); color: var(--k); }
.lr-dot.mod { border-bottom: 5px solid var(--blue); }
.edge-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.edge-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; background: var(--well); box-shadow: inset 0 0 0 2px var(--k); padding: 4px 4px 4px 10px; font-size: 15px; }
.edge-row b { font-family: var(--f-pixel); margin-right: 6px; }

/* ---------- the robot: poke him ---------- */
.sprite-btn { position: relative; border: 0; background: none; padding: 0; cursor: pointer; flex: none; line-height: 0; }
.sprite-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 4px; }
.sprite-btn:active .sprite { transform: scale(.92); }
.bot-say { position: absolute; left: 8px; top: 74px; z-index: 30; width: max-content; max-width: min(300px, 78vw); background: var(--white); color: var(--k); font-family: var(--f-body); font-size: 15px; line-height: 1.35; text-align: left; padding: 8px 11px; box-shadow: inset 0 0 0 3px var(--k), 4px 4px 0 var(--k); white-space: normal; pointer-events: none; }
.bot-say::before { content: ""; position: absolute; left: 22px; top: -9px; border: 6px solid transparent; border-bottom: 6px solid var(--k); border-top: 0; }
.bot-fx { position: fixed; z-index: 40; pointer-events: none; font-size: 20px; line-height: 1; animation: botfx 1.3s ease-out forwards; }
@keyframes botfx { from { transform: translate(0, 0) scale(1); opacity: 1; } to { transform: translate(var(--dx, 0), -70px) scale(1.4); opacity: 0; } }
.sprite.t-flip { animation: t-flip .7s steps(8) 1; }
@keyframes t-flip { 0% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-26px) rotate(-180deg); } 100% { transform: translateY(0) rotate(-360deg); } }
.sprite.t-spin { animation: t-spin .8s steps(8) 1; }
@keyframes t-spin { to { transform: rotateY(720deg); } }
.sprite.t-dance { animation: t-dance 1.2s steps(2) 1; }
@keyframes t-dance { 0%, 50%, 100% { transform: rotate(0); } 12%, 62% { transform: rotate(-14deg) translateX(-4px); } 37%, 87% { transform: rotate(14deg) translateX(4px); } }
.sprite.t-squash { animation: t-squash .7s steps(6) 1; transform-origin: 50% 100%; }
@keyframes t-squash { 30% { transform: scale(1.35, .55); } 60% { transform: scale(.75, 1.35) translateY(-10px); } 100% { transform: scale(1); } }
.sprite.t-rainbow { animation: t-rainbow 1.6s steps(12) 1; }
@keyframes t-rainbow { to { filter: hue-rotate(720deg) saturate(2); } }
.sprite.t-glitch { animation: t-glitch .9s steps(1) 1; }
@keyframes t-glitch { 0% { transform: translate(0); } 10% { transform: translate(-5px, 2px) skewX(20deg); filter: invert(1); } 25% { transform: translate(4px, -3px); filter: none; } 40% { transform: translate(-2px, 0) scaleX(-1); } 55% { transform: translate(6px, 1px) skewY(-15deg); filter: hue-rotate(160deg); } 70% { transform: translate(-3px, -2px); filter: none; } 85% { transform: translate(2px, 2px) scale(1.1); } 100% { transform: none; } }
.sprite.t-zoom { animation: t-zoom 2.4s steps(2) 1; position: relative; z-index: 35; }
@keyframes t-zoom { 0% { transform: translateX(0); } 35% { transform: translateX(min(70vw, 900px)) scaleX(1); } 36% { transform: translateX(min(70vw, 900px)) scaleX(-1); } 70% { transform: translateX(0) scaleX(-1); } 71%, 100% { transform: translateX(0) scaleX(1); } }
.sprite.t-ghost { animation: t-ghost 2s steps(6) 1; }
@keyframes t-ghost { 40%, 60% { opacity: .12; transform: translateY(-6px); } }
.sprite.t-giant { animation: t-giant 1.4s steps(4) 1; position: relative; z-index: 35; transform-origin: 0 0; }
@keyframes t-giant { 30%, 70% { transform: scale(2.2); } }
.sprite.t-shake { animation: t-shake .6s steps(2) 1; }
@keyframes t-shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-3px); } }
