/* Toolwoven Word Scramble Studio — "letter tiles on a teal rack" */
:root {
  --bg: #e6efee;
  --desk: #cddfdd;
  --white: #ffffff;
  --ink: #102a2c;
  --ink-2: #2c474a;
  --muted: #475f62;
  --line: #9db4b3;
  --line-2: #d3e1e0;
  --teal: #0b6b70;
  --teal-d: #074f53;
  --teal-soft: #d9ecea;
  --tile: #f6ca52;
  --tile-hi: #fbdc85;
  --tile-edge: #c4961a;
  --tile-ink: #2e2200;
  --warn-bg: #fff2d4;
  --warn: #8a4a00;
  --ok: #17643a;
  --bad: #a3261b;
  --display: "Gill Sans", "Gill Sans MT", Seravek, "Trebuchet MS", Calibri, system-ui, sans-serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --gutter: clamp(16px, 3vw, 36px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--ui); }
a { color: var(--teal-d); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
code { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 10; background: var(--ink); color: #fff; padding: 10px 14px; font-weight: 700; }
.skip:focus { top: 12px; color: #fff; }

/* ---------- tiles ---------- */
.brand-tiles { display: inline-flex; gap: 3px; }
.brand-tiles i, .rack i {
  font-style: normal; display: inline-grid; place-items: center; font-family: var(--display); font-weight: 700;
  background: var(--tile); color: var(--tile-ink); border-radius: 4px; box-shadow: inset 0 -3px 0 var(--tile-edge);
}
.brand-tiles i { width: 28px; height: 30px; font-size: 18px; padding-bottom: 2px; }
.brand-tiles.small i { width: 22px; height: 24px; font-size: 14px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px var(--gutter); background: var(--teal); color: #fff; min-height: 60px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-name { display: grid; line-height: 1.15; }
.brand-name b { font: 600 19px var(--display); letter-spacing: .01em; }
.brand-name small { font-size: 12.5px; opacity: .9; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a { color: #fff; text-decoration: none; font-weight: 600; font-size: 15px; padding: 9px 12px; border-radius: 4px; min-height: 40px; display: inline-flex; align-items: center; }
.topnav a:hover { background: var(--teal-d); color: #fff; }
.top :focus-visible { outline-color: #fff; }

/* ---------- intro ---------- */
.intro { display: flex; align-items: center; gap: clamp(18px, 3vw, 40px); padding: 16px var(--gutter) 16px; max-width: 1480px; margin: 0 auto; }
.rack { position: relative; display: flex; gap: 5px; padding: 0 10px 12px; flex: none; }
.rack::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 11px; background: var(--teal); border-radius: 2px 2px 6px 6px; box-shadow: inset 0 3px 0 rgba(255,255,255,.18); }
.rack i { width: 34px; height: 38px; font-size: 22px; padding-bottom: 3px; position: relative; z-index: 1; }
.intro h1 { margin: 0; font: 600 clamp(28px, 3vw, 40px)/1.08 var(--display); letter-spacing: -.01em; }
.lede { margin: 6px 0 0; font-size: 16.5px; color: var(--ink-2); max-width: 66ch; }

/* ---------- maker ---------- */
.maker { display: grid; grid-template-columns: minmax(0, 1fr) 420px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: var(--desk); }
.stage { padding: 16px var(--gutter) 24px; min-width: 0; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.stage-info { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 320px; }
.example-tag {
  flex: none; font: 700 13px var(--ui); letter-spacing: .14em; text-transform: uppercase; padding: 6px 10px 7px;
  background: var(--tile); color: var(--tile-ink); border-radius: 4px; box-shadow: inset 0 -3px 0 var(--tile-edge);
}
.example-tag[hidden] { display: none; }
.summary { margin: 0; font-size: 15px; color: var(--ink-2); }
.summary b { color: var(--ink); }
.stage-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pager select { flex: 0 1 300px; min-width: 0; }
.edit-link { display: none; margin-left: auto; font-weight: 600; font-size: 15px; padding: 10px 0; min-height: 44px; }
.status { min-height: 1.5em; margin: 4px 0 2px; font-size: 15px; font-weight: 600; color: var(--ok); }
.desk { display: flex; justify-content: center; }
.sheet { width: 100%; max-width: 660px; background: #fff; box-shadow: 0 1px 0 rgba(16,42,44,.25), 0 12px 28px rgba(16,42,44,.18); position: relative; }
.sheet svg { display: block; width: 100%; height: auto; }
/* Keep the page's shape before the preview is drawn, so nothing below it jumps. The head script adds .pp-letter from the saved paper. */
.sheet:empty { aspect-ratio: 210 / 297; }
.pp-letter .sheet:empty { aspect-ratio: 215.9 / 279.4; }
.sheet.is-key::before { content: "Answer key"; position: absolute; top: -12px; right: 14px; font: 700 12px var(--ui); letter-spacing: .1em; text-transform: uppercase; background: var(--ink); color: #fff; padding: 4px 9px; border-radius: 3px; }
.empty { aspect-ratio: 210 / 297; display: grid; place-content: center; text-align: center; gap: 6px; color: var(--muted); padding: 24px; }
.empty b { font: 600 22px var(--display); color: var(--ink); }

/* buttons & fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px; flex-direction: column;
  min-height: 44px; padding: 6px 16px; border: 2px solid var(--ink); border-radius: 4px; background: var(--white); color: var(--ink);
  font: 600 15px/1.15 var(--ui); cursor: pointer;
}
.btn:hover { background: var(--teal-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--teal); border-color: var(--teal-d); color: #fff; min-width: 170px; }
.btn-primary:hover { background: var(--teal-d); }
.btn-primary small { font-size: 12.5px; font-weight: 500; opacity: .92; }
.btn-icon { width: 44px; padding: 0; font-size: 20px; }
select, input[type="text"], input:not([type]), input[type="number"], textarea {
  font: 16px var(--ui); color: var(--ink); background: var(--white); border: 1.5px solid #6f8d8f; border-radius: 3px; min-height: 44px; padding: 8px 10px; width: 100%;
}
select { padding-right: 30px; }
textarea { font: 15px/1.6 var(--mono); resize: vertical; min-height: 290px;
  background-image: linear-gradient(transparent calc(1.6em - 1px), var(--line-2) 1px); background-size: 100% 1.6em; background-position: 0 9px; background-attachment: local; }
input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 2px #f5c6c0; }

/* check list */
.check { max-width: 660px; margin: 18px auto 0; background: var(--white); border: 1.5px solid var(--line); border-radius: 4px; }
.check summary { cursor: pointer; padding: 11px 14px; font-size: 15px; min-height: 44px; }
.check summary .ok { color: var(--ok); font-weight: 700; }
.check summary .bad, td.bad { color: var(--bad); font-weight: 700; }
td.ok { color: var(--ok); }
.check-body { padding: 0 14px 14px; }
.check-note { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.table-scroll { overflow-x: auto; }
.check table { border-collapse: collapse; width: 100%; font-size: 15px; }
.check th, .check td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.check th { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- panel ---------- */
.panel { background: var(--white); border-left: 2px solid var(--ink); min-width: 0; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 2; background: var(--bg); }
.tabs [role="tab"] {
  min-height: 52px; border: 0; border-right: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
  font: 600 16px var(--display); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.tabs [role="tab"]:last-child { border-right: 0; }
.tabs [role="tab"] b { display: inline-grid; place-items: center; width: 22px; height: 24px; font-size: 14px; border-radius: 3px; background: var(--white); border: 1.5px solid var(--line); }
.tabs [role="tab"][aria-selected="true"] { background: var(--white); box-shadow: inset 0 -4px 0 var(--teal); }
.tabs [role="tab"][aria-selected="true"] b { background: var(--tile); border-color: var(--tile-edge); color: var(--tile-ink); }
.tabs [role="tab"]:hover { background: var(--white); }
.tabs [role="tab"]:focus-visible { outline-offset: -4px; }
.pane { padding: 18px 20px 24px; }
.lbl { display: block; font-weight: 700; font-size: 15px; margin: 16px 0 6px; }
.pane > .lbl:first-child, .pane > fieldset:first-child > .lbl { margin-top: 0; }
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 18px; }
.lbl-row .lbl { margin: 0; }
.count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.opt { font-weight: 400; color: var(--muted); font-size: 14px; }
.help { margin: 4px 0 8px; font-size: 14px; color: var(--muted); }
.help code { background: var(--teal-soft); padding: 1px 5px; border-radius: 3px; color: var(--ink); }
.linkbtn { background: none; border: 0; padding: 8px 0; min-height: 40px; color: var(--teal-d); font: 600 15px var(--ui); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.undo { margin-top: 8px; padding: 4px 12px; background: var(--teal-soft); border-radius: 3px; font-size: 15px; }
.undo[hidden] { display: none; }
.notices { display: grid; gap: 8px; margin-top: 10px; }
.notice { margin: 0; padding: 9px 12px; font-size: 14.5px; border-left: 4px solid; border-radius: 2px; }
.notice.warn { background: var(--warn-bg); border-color: #c27c00; color: var(--warn); }
.notice.info { background: var(--teal-soft); border-color: var(--teal); color: var(--ink-2); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend.lbl { padding: 0; margin: 0 0 6px; }
.seg-field { margin-top: 18px; }
.levels > legend.lbl { margin-bottom: 0; }

/* level cards */
.levels { display: grid; gap: 8px; }
.level { display: block; position: relative; cursor: pointer; }
.level input, .seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.level span { display: grid; grid-template-columns: 82px 1fr; gap: 2px 10px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 4px; font-size: 15px; }
.level b { font: 700 17px var(--display); grid-row: span 2; align-self: center; }
.level code { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.level input:checked + span { background: var(--tile-hi); border-color: var(--tile-edge); box-shadow: inset 0 -3px 0 var(--tile-edge); }
.level input:checked + span code { color: var(--tile-ink); }
.level input:focus-visible + span, .seg input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.seg { display: flex; flex-wrap: wrap; }
.seg label { position: relative; flex: 1 1 auto; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 12px; border: 2px solid var(--line); margin-left: -2px; font-weight: 600; font-size: 15px; cursor: pointer; text-align: center; }
.seg label:first-child span { margin-left: 0; border-radius: 4px 0 0 4px; }
.seg label:last-child span { border-radius: 0 4px 4px 0; }
.seg input:checked + span { background: var(--tile-hi); border-color: var(--tile-edge); position: relative; z-index: 1; box-shadow: inset 0 -3px 0 var(--tile-edge); }
.checks { display: grid; gap: 4px; margin-top: 14px; }
.chk { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; font-size: 15px; font-weight: 600; min-height: 40px; }
.chk input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--teal); flex: none; }
.chk small { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.joined, .stepper { display: flex; }
.joined input { border-radius: 3px 0 0 3px; min-width: 0; }
.joined .btn { border-radius: 0 4px 4px 0; margin-left: -2px; padding: 6px 12px; }
.stepper .btn, .joined .btn { flex: none; }
.stepper input { text-align: center; border-radius: 0; min-width: 0; -moz-appearance: textfield; }
.stepper .btn:first-child { border-radius: 4px 0 0 4px; }
.stepper .btn:last-child { border-radius: 0 4px 4px 0; }
.stepper input::-webkit-inner-spin-button { display: none; }

/* ---------- content ---------- */
.info { max-width: 1120px; margin: 0 auto; padding: 18px var(--gutter) 30px; }
.block { padding: 30px 0 8px; border-bottom: 1.5px solid var(--line); }
.block:last-child { border-bottom: 0; }
.block h2 { font: 600 clamp(25px, 2.6vw, 31px)/1.15 var(--display); margin: 0 0 10px; }
.block h3 { font: 600 19px var(--display); margin: 0 0 6px; }
.block p { max-width: 72ch; }
.note { color: var(--ink-2); font-size: 15.5px; }
.levels-table { border-collapse: collapse; width: 100%; background: var(--white); font-size: 15.5px; }
.levels-table th, .levels-table td { padding: 10px 12px; border: 1.5px solid var(--line); text-align: left; vertical-align: top; }
.levels-table thead th { background: var(--ink); color: #fff; font-size: 14px; letter-spacing: .04em; }
.levels-table tbody th { font: 700 17px var(--display); }
.levels-table code { font-size: 15px; letter-spacing: .14em; font-weight: 700; background: var(--tile-hi); padding: 2px 6px; border-radius: 3px; }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.cols p { font-size: 15.5px; margin-top: 0; }
#faq details { border-top: 1.5px solid var(--line-2); }
#faq details:last-of-type { border-bottom: 1.5px solid var(--line-2); }
#faq summary { cursor: pointer; font-weight: 700; padding: 12px 0; min-height: 44px; }
#faq details p { margin: 0 0 14px; }

/* ---------- simple pages (about / privacy) ---------- */
.doc { max-width: 760px; margin: 0 auto; padding: 34px var(--gutter) 50px; }
.doc .kicker { display: inline-block; font: 700 13px var(--ui); letter-spacing: .14em; text-transform: uppercase; background: var(--tile); color: var(--tile-ink); padding: 5px 9px 6px; border-radius: 4px; box-shadow: inset 0 -3px 0 var(--tile-edge); margin: 0 0 12px; }
.doc h1 { font: 600 clamp(30px, 4vw, 42px)/1.1 var(--display); margin: 0 0 14px; }
.doc h2 { font: 600 24px var(--display); margin: 28px 0 8px; }
.doc .lede { font-size: 18px; }
.doc .updated { color: var(--muted); font-size: 15px; }

/* ---------- footer ---------- */
.foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; padding: 18px var(--gutter); border-top: 2px solid var(--ink); background: var(--white); font-size: 15px; }
.foot-brand { display: inline-flex; align-items: center; gap: 10px; font: 600 16px var(--display); }
.foot p { margin: 0; color: var(--muted); }
.foot nav { display: flex; flex-wrap: wrap; gap: 0 6px; }
.foot nav a { font-weight: 600; padding: 9px 10px; min-height: 40px; display: inline-flex; align-items: center; }

.print-area { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .maker { grid-template-columns: minmax(0, 1fr) 380px; }
}
@media (max-width: 900px) {
  .maker { grid-template-columns: 1fr; }
  .panel { border-left: 0; border-top: 2px solid var(--ink); }
  .tabs { position: static; }
  .edit-link { display: inline-flex; align-items: center; }
  .cols { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 640px) {
  .top { padding-top: 8px; padding-bottom: 8px; }
  .summary { min-height: 3em; line-height: 1.5; } /* two lines reserved: the summary is filled in after load */
  .topnav a:not([href="/about"]) { display: none; }
  .brand-name small { display: none; }
  .intro { flex-direction: column; align-items: flex-start; gap: 14px; padding-top: 18px; padding-bottom: 16px; }
  .rack i { width: 32px; height: 36px; font-size: 20px; }
  .rack { gap: 4px; padding: 0 6px 10px; }
  .lede { font-size: 16px; }
  .stage { padding: 12px 16px 20px; }
  .stage-actions { width: 100%; }
  .stage-actions .btn { flex: 1 1 0; }
  .pager select { flex: 1 1 160px; }
  .edit-link { width: 100%; margin-left: 0; }
  .pane { padding: 16px; }
  .level span { grid-template-columns: 72px 1fr; }
  .two { grid-template-columns: 1fr; }
  .levels-table thead { display: none; }
  .levels-table, .levels-table tbody, .levels-table tr, .levels-table th, .levels-table td { display: block; }
  .levels-table tr { border: 1.5px solid var(--line); border-bottom: 0; }
  .levels-table tr:last-child { border-bottom: 1.5px solid var(--line); }
  .levels-table th, .levels-table td { border: 0; padding: 6px 12px; }
  .levels-table tbody th { background: var(--teal-soft); }
  .levels-table td::before { content: attr(data-label); display: block; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- print: only the worksheet pages ---------- */
@media print {
  body { background: #fff; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; }
  .print-page { overflow: hidden; break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-page svg { display: block; }
}
.next-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px;margin-top:12px}
.next-grid a{display:block;padding:14px 16px;border:1.5px solid currentColor;border-radius:10px;text-decoration:none;color:inherit;line-height:1.45}
.next-grid a b{display:block;margin-bottom:2px;text-decoration:underline;text-underline-offset:3px}
/* /guides articles (tools/guides.cjs) */
.doc.guide { max-width: 820px; }
.guide .crumbs { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.guide .crumbs a { color: inherit; }
.guide .byline { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.guide h3 { font: 600 19px var(--display); margin: 20px 0 6px; }
.guide .g-cta { display: inline-block; margin: 4px 8px 4px 0; padding: 10px 16px; border-radius: 8px; background: var(--teal); color: #fff; font-weight: 700; text-decoration: none; border: 1.5px solid var(--teal-d); }
.guide .g-cta:hover { background: var(--teal-d); }
.guide .g-cta.ghost { background: var(--white); color: var(--teal-d); }
.guide .g-cta.ghost:hover { background: var(--teal-soft); }
.guide .g-table { overflow-x: auto; margin: 12px 0 18px; }
.guide .g-table table { font-size: 15px; }
.guide .g-table th, .guide .g-table td { padding: 8px 10px; border: 1.5px solid var(--line); text-align: left; vertical-align: top; }
.guide .g-table thead th { background: var(--ink); color: #fff; font-size: 13px; letter-spacing: .03em; }
.guide .g-table.wide table { min-width: 620px; }
.guide .g-table code { font: 600 14px var(--mono); letter-spacing: .06em; }
.guide .note { color: var(--muted); font-size: 14px; }
.guide figure.g-shot { margin: 20px 0 24px; }
.guide figure.g-shot img { display: block; width: 100%; height: auto; border: 1.5px solid var(--line); border-radius: 8px; background: var(--white); }
.guide figure.g-shot.tall img { max-width: 520px; }
.guide figcaption { color: var(--muted); font-size: 14.5px; margin-top: 8px; }
.guide .g-list, .guide .g-more { padding-left: 0; list-style: none; }
.guide .g-list li { background: var(--white); border: 1.5px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.guide .g-list li a { font: 600 19px var(--display); }
.guide .g-list li p { margin: 6px 0 0; color: var(--muted); }
.guide .g-more li { margin: 6px 0; }
.guide .sources li { overflow-wrap: anywhere; }
.lists{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:18px 28px;margin-top:8px}
.lists ul{list-style:none;padding:0;margin:6px 0 0}
.lists li{padding:5px 0;border-bottom:1px solid var(--line)}
.lists li small{color:var(--muted);margin-left:6px}
.lists .guide-link{font-size:15px;margin:8px 0 0}
