/* Toolwoven Maze Lab — "pencil route" workbook styling.
   Ink rules, square corners, one red-pen accent for routes and answers. System fonts only. */
:root {
  --ink: #14161a;
  --ink-2: #3a3f47;
  --muted: #555c67;
  --paper: #ffffff;
  --wash: #f3f5f8;
  --stage: #dde7f2;
  --rule: #cfd5de;
  --red: #d42a1f;
  --red-ink: #b3221a;
  --focus: #1f5bd6;
  --display: Futura, "Futura PT", "Century Gothic", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--body); }
a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--red-ink); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; z-index: 50; }
.skip:focus { top: 10px; color: #fff; }
.mono { font-family: var(--mono); }

/* ---------- header ---------- */
.site { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 32px; min-height: 66px; border-bottom: 2px solid var(--ink); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand b { display: block; font: 700 21px/1.05 var(--display); letter-spacing: .01em; }
.brand small { display: block; font-size: 13px; color: var(--muted); }
.site nav { display: flex; gap: 6px; }
.site nav a { display: inline-flex; align-items: center; min-height: 42px; padding: 0 12px; font-size: 15px; font-weight: 600; text-decoration: none; }
.site nav a:hover { color: var(--ink); background: var(--wash); box-shadow: inset 0 -3px 0 var(--red); }

/* ---------- intro ---------- */
.intro { padding: 26px 32px 22px; max-width: 1100px; }
.intro h1 { margin: 0 0 8px; font: 700 clamp(30px, 3.6vw, 46px)/1.08 var(--display); letter-spacing: -.01em; }
.intro h1 span { font-weight: 400; color: var(--ink-2); }
.intro p { margin: 0; max-width: 780px; font-size: 17px; color: var(--ink-2); }

/* ---------- maker ---------- */
.maker { display: grid; grid-template-columns: minmax(0, 1fr) 452px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.stage-col { background: var(--stage); padding: 18px 28px 22px; min-width: 0; }
.stage-col > * { max-width: 900px; margin-left: auto; margin-right: auto; }
.stage-bar { display: flex; align-items: center; gap: 14px; min-height: 44px; }
.page-info { margin: 0; font-size: 15px; flex: 1; min-width: 0; }
.stamp { flex: none; display: inline-block; padding: 3px 10px; border: 2px solid var(--red); color: var(--red-ink); background: #fff; font: 700 13px/1.3 var(--body); letter-spacing: .08em; text-transform: uppercase; transform: rotate(-2deg); }
.stamp[hidden] { display: none; }
.pager { display: flex; gap: 6px; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 2px solid var(--ink); background: #fff; font-size: 20px; line-height: 1; padding: 0; }
.icon-btn:hover:not(:disabled) { background: var(--ink); color: #fff; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.bar-pdf { min-height: 44px; padding: 0 16px; border: 2px solid var(--ink); background: var(--ink); color: #fff; font-size: 15px; font-weight: 700; }
.bar-pdf:hover { box-shadow: 3px 3px 0 var(--red); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-btn svg circle { fill: currentColor; stroke: none; }
.stage { background-color: var(--stage); background-position: center top; padding: 18px 0 22px; display: flex; justify-content: center; }
.sheet { height: clamp(440px, calc(100vh - 330px), 900px); aspect-ratio: 210 / 297; max-width: 100%; background: #fff; border: 2px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); }
.sheet svg { display: block; }
.facts { display: flex; flex-wrap: wrap; gap: 0; margin: 0 auto 14px; background: #fff; border: 2px solid var(--ink); }
.facts div { padding: 8px 14px; border-right: 1px solid var(--rule); flex: 1 1 auto; }
.facts div:last-child { border-right: 0; }
.facts dt { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; }
.tray-title { margin: 0 0 6px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.tray { display: flex; gap: 10px; overflow-x: auto; padding: 4px 4px 10px; scrollbar-width: thin; }
.tray button { flex: none; width: 104px; border: 0; background: none; padding: 0; text-align: left; }
.thumb { display: block; aspect-ratio: 210 / 297; background: #fff; border: 2px solid #8f98a6; }
.tray button[aria-current="page"] .thumb { border-color: var(--ink); box-shadow: 4px 4px 0 var(--red); }
.tray button:hover .thumb { border-color: var(--ink); }
.cap { display: block; margin-top: 5px; font-size: 13px; line-height: 1.3; color: var(--ink-2); }
.cap.ans { color: var(--red-ink); }
.tray button[aria-current="page"] .cap { font-weight: 700; color: var(--ink); }

/* ---------- steps (the route) ---------- */
.steps { position: relative; padding: 22px 28px 26px 26px; border-left: 2px solid var(--ink); background: #fff; }
.steps::before { content: ""; position: absolute; left: 42px; top: 44px; bottom: 120px; border-left: 3px dashed var(--red); }
.step { position: relative; border: 0; margin: 0 0 22px; padding: 0 0 0 56px; min-width: 0; }
.step legend, .step h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 12px -56px; padding: 0; font: 700 20px/1.2 var(--display); }
.node { flex: none; position: relative; z-index: 1; width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--ink); color: #fff; font: 700 16px/1 var(--body); box-shadow: 0 0 0 5px #fff; }
.node.star { background: var(--red); font-size: 18px; }
.hint { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.msg { margin: 0; font-size: 14px; color: var(--red-ink); font-weight: 600; }
.msg:empty { display: none; }

.tile input, .seg input, .lvl input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.shapes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 74px; border: 2px solid var(--ink); background: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.tile svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.tile svg circle { fill: currentColor; stroke: none; }
.tile span:hover { background: var(--wash); }
.tile input:checked + span { background: var(--ink); color: #fff; }
.tile input:focus-visible + span, .seg input:focus-visible + span, .lvl input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.levels-pick { display: grid; gap: 6px; }
.lvl span { display: grid; grid-template-columns: 86px 1fr auto; align-items: center; gap: 10px; min-height: 46px; padding: 6px 12px; border: 2px solid var(--ink); background: #fff; cursor: pointer; }
.lvl b { font-size: 16px; }
.lvl em { font-style: normal; font-size: 15px; }
.lvl i { font-style: normal; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.lvl span:hover { background: var(--wash); }
.lvl input:checked + span { background: var(--ink); color: #fff; }
.lvl input:checked + span i { color: #d7dbe2; }

.field { display: block; margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.field > span, .field > label { display: block; margin-bottom: 5px; }
.field input[type="text"], .field input[type="number"] { display: block; width: 100%; height: 46px; margin-top: 5px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 0; background: #fff; font-size: 16px; font-weight: 400; }
.field > label + .seed-row input, .stepper input { margin-top: 0 !important; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2.tight { gap: 8px; margin: 8px 0; }
.stepper { display: grid; grid-template-columns: 46px 1fr 46px; }
.stepper button { height: 46px; border: 2px solid var(--ink); background: #fff; font-size: 20px; padding: 0; }
.stepper button:hover { background: var(--ink); color: #fff; }
.stepper input { text-align: center; border-left: 0 !important; border-right: 0 !important; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.seg { display: flex; }
.seg label { flex: 1 1 0; min-width: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 4px 8px; border: 2px solid var(--ink); margin-left: -2px; background: #fff; font-size: 15px; font-weight: 600; text-align: center; line-height: 1.2; cursor: pointer; }
.seg label:first-child span { margin-left: 0; }
.seg span:hover { background: var(--wash); }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seed-row { display: grid; grid-template-columns: 1fr 46px; }
.seed-row input { font-family: var(--mono) !important; font-size: 15px !important; border-right: 0 !important; }
.seed-row .icon-btn { width: 46px; height: 46px; }
.checks { display: grid; gap: 2px; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex: none; }

.finish { margin-bottom: 0; }
.primary { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 60px; padding: 8px 18px; border: 2px solid var(--ink); background: var(--ink); color: #fff; font-size: 18px; font-weight: 700; text-align: left; }
.primary small { font-size: 13px; font-weight: 500; color: #cfd4dc; }
.primary:hover { background: #000; box-shadow: 4px 4px 0 var(--red); }
.secondary { white-space: nowrap; min-height: 48px; padding: 6px 12px; border: 2px solid var(--ink); background: #fff; font-size: 16px; font-weight: 600; }
.secondary:hover { background: var(--wash); }
.linkish { min-height: 42px; padding: 0; border: 0; background: none; font-size: 15px; font-weight: 600; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.linkish:hover { color: var(--red-ink); }
.status { min-height: 44px; margin: 6px 0 0; font-size: 14px; color: var(--ink-2); }

/* ---------- content bands ---------- */
.band { max-width: 1180px; margin: 0 auto; padding: 56px 32px 8px; }
.band h2 { margin: 0 0 14px; font: 700 30px/1.15 var(--display); }
.band-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 28px; align-items: end; margin-bottom: 18px; }
.band-head h2 { margin: 0; }
.band-head p { margin: 0; color: var(--ink-2); }
.age-table { border-top: 2px solid var(--ink); }
.age-row { display: grid; grid-template-columns: 130px 150px 120px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.age-row.head { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 0; }
.age-row b { font-size: 17px; }
.uses-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 2px solid var(--ink); }
.uses-grid article { padding: 16px 22px 8px 0; }
.uses-grid article + article { padding-left: 22px; border-left: 1px solid var(--rule); }
.uses-grid h3 { margin: 0 0 6px; font-size: 18px; }
.uses-grid p { margin: 0; color: var(--ink-2); }
.faq { padding-bottom: 64px; }
.faq details { border-top: 2px solid var(--ink); }
.faq details:last-of-type { border-bottom: 2px solid var(--ink); }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 54px; font-size: 17px; font-weight: 700; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 2px solid var(--ink); font-size: 20px; line-height: 1; }
.faq details[open] summary::after { content: "−"; background: var(--ink); color: #fff; }
.faq details p { margin: 0 0 16px; max-width: 760px; color: var(--ink-2); }

.site-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 22px 32px; border-top: 2px solid var(--ink); font-size: 15px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-foot nav a { display: inline-flex; align-items: center; min-height: 40px; font-weight: 600; }
.dock { display: none; }

/* ---------- article pages (guides, about, privacy) ---------- */
.doc { max-width: 860px; margin: 0 auto; padding: 36px 24px 64px; }
.doc h1 { margin: 0 0 12px; font: 700 clamp(30px, 4vw, 42px)/1.1 var(--display); }
.doc .lede { font-size: 18px; color: var(--ink-2); margin: 0 0 28px; }
.doc h2 { margin: 40px 0 10px; padding-top: 14px; border-top: 2px solid var(--ink); font: 700 25px/1.2 var(--display); }
.doc h3 { margin: 22px 0 6px; font-size: 18px; }
.doc p, .doc li { color: var(--ink-2); }
.doc li { margin-bottom: 6px; }
.doc .cta { display: inline-flex; align-items: center; min-height: 48px; padding: 0 18px; background: var(--ink); color: #fff; font-weight: 700; text-decoration: none; }
.doc .cta:hover { color: #fff; box-shadow: 4px 4px 0 var(--red); }
.examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; margin: 18px 0 8px; }
.examples figure { margin: 0; }
.examples .pic { display: block; aspect-ratio: 1; border: 2px solid var(--ink); background: #fff; padding: 6px; }
.examples .pic svg { width: 100%; height: 100%; display: block; }
.examples figcaption { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.examples figcaption b { color: var(--ink); }
.examples a { text-decoration: none; display: block; }
.examples a:hover .pic { box-shadow: 4px 4px 0 var(--red); }
.examples a:hover figcaption b { text-decoration: underline; }
.level-card { display: grid; grid-template-columns: 180px 1fr; gap: 22px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.level-card .pic { aspect-ratio: 1; border: 2px solid var(--ink); background: #fff; padding: 6px; }
.level-card .pic svg { width: 100%; height: 100%; display: block; }
.level-card h3 { margin: 0 0 4px; }
.level-card .meta { margin: 0 0 6px; font-weight: 600; color: var(--ink); }
.level-card p { margin: 0 0 8px; }

/* ---------- print: only the worksheet pages ---------- */
#printRoot { display: none; }
@media print {
  body > *:not(#printRoot) { display: none !important; }
  body { background: #fff; }
  #printRoot { display: block; }
  #printRoot .pp { overflow: hidden; break-after: page; page-break-after: always; }
  #printRoot .pp:last-child { break-after: auto; page-break-after: auto; }
  #printRoot svg { display: block; }
}

/* ---------- narrower screens ---------- */
@media (max-width: 1180px) {
  .maker { grid-template-columns: minmax(0, 1fr) 410px; }
  .steps { padding-right: 20px; }
}
@media (max-width: 899px) {
  body { padding-bottom: 78px; }
  .site { padding: 8px 16px; flex-wrap: wrap; gap: 4px; }
  .site nav { gap: 0; margin-left: -10px; flex-wrap: wrap; }
  .site nav a { padding: 0 10px; }
  .intro { padding: 18px 16px 16px; }
  .intro p { font-size: 16px; }
  .maker { grid-template-columns: 1fr; }
  .stage-col { padding: 12px 16px 16px; }
  .sheet { height: auto; width: 100%; box-shadow: 5px 5px 0 var(--ink); }
  .stage { padding: 10px 5px 16px 0; }
  .steps { border-left: 0; border-top: 2px solid var(--ink); padding: 20px 16px 8px; }
  .steps::before { left: 32px; }
  .step { padding-left: 50px; }
  .step legend, .step h2 { margin-left: -50px; }
  .band { padding: 40px 16px 8px; }
  .band-head { grid-template-columns: 1fr; gap: 8px; }
  .age-row { grid-template-columns: 90px 1fr; gap: 2px 12px; }
  .age-row.head { display: none; }
  .age-table.compact .age-row { grid-template-columns: 76px 1fr 1fr 1fr; gap: 8px; }
  .age-table.compact .age-row.head { display: grid; font-size: 12.5px; letter-spacing: .02em; }
  .age-table.compact .age-row > * { grid-column: auto !important; grid-row: auto !important; }
  .age-row span:nth-of-type(3) { grid-column: 2; }
  .age-row span:last-child { grid-column: 1 / -1; }
  .age-row b { grid-row: span 2; }
  .uses-grid { grid-template-columns: 1fr; }
  .uses-grid article, .uses-grid article + article { padding: 14px 0 6px; border-left: 0; border-top: 1px solid var(--rule); }
  .uses-grid article:first-child { border-top: 0; }
  .site-foot { padding: 18px 16px; }
  .bar-pdf { display: none; }
  .dock { display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 2px solid var(--ink); }
  .dock .primary { flex: 1.6; min-height: 52px; justify-content: center; font-size: 17px; }
  .dock .secondary { flex: 1; min-height: 52px; }
  .level-card { grid-template-columns: 110px 1fr; gap: 14px; }
}
@media (max-width: 520px) {
  .row2 { grid-template-columns: 1fr; gap: 0; }
  .row2.tight { grid-template-columns: 1fr 1fr; gap: 8px; }
  .lvl span { grid-template-columns: 74px 1fr; }
  .lvl i { grid-column: 2; }
  .facts div { flex: 1 1 45%; border-bottom: 1px solid var(--rule); }
  .brand small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
