/* Plus-Plus Puzzle Maker */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img { max-width: 100%; }
/* Layout: a three-part workbench — controls rail, 3D stage, and a tabbed sheet (facts / build steps / parts list)
   styled after a toy-set instruction booklet: pale stage, boxed callouts, big rounded step numerals. */
:root {
  --bg: #EEF3F8;
  --surface: #FFFFFF;
  --surface-2: #F5F8FB;
  --stage: #DCE7F1;
  --ink: #15202C;
  --muted: #586777;
  --line: #CFDAE5;
  --accent: #1463D6;
  --accent-ink: #FFFFFF;
  --mark: #F2700F;
  --warn-bg: #FFF1DC;
  --warn-ink: #7A4300;
  --plan-old: #C5D0DB;
  --plan-below: #E4EBF2;
  --plan-line: #33414F;
  --font-display: "Fredoka", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E141B; --surface: #172029; --surface-2: #1D2832; --stage: #1B2631; --ink: #E7EEF5; --muted: #94A4B4;
    --line: #2C3946; --accent: #62A6FF; --accent-ink: #08121F; --mark: #FF9447; --warn-bg: #3A2A12; --warn-ink: #FFD49A;
    --plan-old: #4A5866; --plan-below: #26323E; --plan-line: #DCE5EE; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E141B; --surface: #172029; --surface-2: #1D2832; --stage: #1B2631; --ink: #E7EEF5; --muted: #94A4B4;
  --line: #2C3946; --accent: #62A6FF; --accent-ink: #08121F; --mark: #FF9447; --warn-bg: #3A2A12; --warn-ink: #FFD49A;
  --plan-old: #4A5866; --plan-below: #26323E; --plan-line: #DCE5EE; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.45; }
.wrap { max-width: 1500px; margin: 0 auto; padding-inline: 16px; padding-block: 14px 28px; display: flex; flex-direction: column; gap: 14px; }
header.top { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
header.top h1 { font-family: var(--font-display); font-weight: 600; font-size: 26px; margin: 0; letter-spacing: -0.01em; }
header.top h1 span { color: var(--accent); }
header.top p { margin: 0; color: var(--muted); max-width: 70ch; }

.bench { display: grid; grid-template-columns: 286px minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1180px) { .bench { grid-template-columns: 286px minmax(0, 1fr); } .sheet { grid-column: 1 / -1; } }
@media (max-width: 760px) { .bench { grid-template-columns: minmax(0, 1fr); } }

.rail { display: flex; flex-direction: column; gap: 12px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.group h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 0; font-weight: 600; }
.drop { border: 2px dashed var(--line); border-radius: 8px; padding: 14px 10px; text-align: center; background: var(--surface-2); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.drop.over { border-color: var(--accent); background: var(--stage); }
.drop strong { font-size: 14px; }
.drop small { color: var(--muted); }
.fname { font-family: var(--font-data); font-size: 12px; overflow-wrap: anywhere; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > label { flex: 1 1 96px; min-width: 0; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
select, input[type="number"] { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-width: 0; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }
button { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: 0.45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.detail-read { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.detail-read b { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.detail-read span { font-family: var(--font-data); font-size: 12px; color: var(--muted); text-align: right; }
.ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.swatches button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); margin: 0; }

.stagebox { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 10px); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
@media (max-width: 760px) { .stagebox { position: static; } }
.stage { position: relative; background: var(--stage); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: clamp(320px, 66vh, 680px); }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage .tag { position: absolute; left: 10px; top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; font-size: 12px; font-weight: 600; }
.stage .busy { position: absolute; right: 10px; top: 10px; background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 4px 9px; font-size: 12px; font-weight: 600; }
.stage .nogl { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); }
.stagebar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }

.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 11px 8px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button:first-child { border-top-left-radius: 10px; } .tabs button:last-child { border-top-right-radius: 10px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.pane { padding: 14px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin: 0; }
.facts div { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--surface-2); min-width: 0; }
.facts div.wide { grid-column: span 2; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-family: var(--font-display); font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts dd small { display: block; font-family: var(--font-data); font-size: 11.5px; font-weight: 400; color: var(--muted); }
.notes { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.notes li { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.notes li.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
h3 { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 0; }
.prose { margin: 0; max-width: 66ch; color: var(--ink); }
.prose + .prose { margin-top: -6px; }

.stepnav { display: flex; align-items: center; gap: 8px; }
.stepnav .num { font-family: var(--font-display); font-weight: 600; font-size: 34px; line-height: 1; color: var(--accent); min-width: 2ch; font-variant-numeric: tabular-nums; }
.stepnav .of { color: var(--muted); font-size: 12px; flex: 1; min-width: 0; }
.stepnav .of b { display: block; color: var(--ink); font-size: 14px; }
.stepnav button { font-weight: 600; padding: 8px 12px; }
.planbox { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 8px; }
.planbox canvas { display: block; width: 100%; height: auto; }
.callout { border: 2px solid var(--accent); border-radius: 8px; padding: 9px 11px; display: flex; flex-direction: column; gap: 4px; }
.callout b { font-family: var(--font-display); font-size: 15px; }
.callout ul { margin: 0; padding-left: 18px; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; font-size: 12px; color: var(--muted); }
.legend div { display: flex; gap: 8px; align-items: center; }
.sw { flex: none; width: 16px; height: 16px; border-radius: 3px; border: 1px solid var(--plan-line); }
.sw.old { background: var(--plan-old); } .sw.below { background: var(--plan-below); } .sw.now { background: var(--mark); }
.sw.up { background: repeating-linear-gradient(45deg, var(--mark) 0 3px, var(--surface) 3px 6px); }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
td.n, th.n { text-align: right; font-family: var(--font-data); }
tfoot td { font-weight: 600; border-bottom: 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--line); vertical-align: -1px; margin-right: 7px; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-weight: 500; max-width: calc(100% - 32px); z-index: 10; }
