:root {
  /* Warm beige: oat and sand surfaces with a soft caramel accent. Low glare, gentle borders, strong text. */
  --bg: #f5efe4;
  --paper: #fbf8f2;
  --ink: #2f2a24;
  --muted: #72685c;
  --line: #8a6a45;
  --rule: #cdb799;
  --line-soft: #e8dcc8;
  --step-bg: #f3ebdd;
  --fill: #f9f5ee;
  --hl: #fbeacb;
  --hl-step: #f3d8a6;
  --accent: #75552f;
  --panel: #f2ebdf;
  --border: #e3d8c6;
  --code-bg: #efe6d6;
  --shadow: 0 1px 2px rgb(60 45 25 / 6%), 0 8px 24px rgb(60 45 25 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1915;
    --paper: #25211c;
    --ink: #efe7da;
    --muted: #b0a492;
    --line: #cfae82;
    --rule: #6f5d45;
    --line-soft: #463b2d;
    --step-bg: #2e2820;
    --fill: #221e19;
    --hl: #4a3d26;
    --hl-step: #6a5530;
    --accent: #e2c49a;
    --panel: #201c18;
    --border: #3a332a;
    --code-bg: #2f2922;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1915; --paper: #25211c; --ink: #efe7da; --muted: #b0a492; --line: #cfae82; --rule: #6f5d45;
  --line-soft: #463b2d; --step-bg: #2e2820; --fill: #221e19; --hl: #4a3d26; --hl-step: #6a5530;
  --accent: #e2c49a; --panel: #201c18; --border: #3a332a; --code-bg: #2f2922; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button, select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover, select:hover { border-color: var(--line); }
:focus-visible { outline: 2px solid var(--line); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px Fraunces, Georgia, serif; }
.logo { color: var(--line); font-size: 22px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  align-items: center;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.seg { display: flex; align-items: center; gap: 2px; }
.seg-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 8px;
}
.seg button {
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
  padding: 4px 11px;
  border-radius: 0;
  margin-left: -1px;
}
.seg button:nth-of-type(1) { border-radius: 7px 0 0 7px; margin-left: 0; }
.seg button:last-child { border-radius: 0 7px 7px 0; }
.seg button[aria-checked="true"] {
  background: var(--line);
  border-color: var(--line);
  color: var(--paper);
  font-weight: 600;
  position: relative;
}

/* ---------- Search ---------- */
.search { position: relative; flex: 1; max-width: 520px; min-width: 220px; }
.search-field { position: relative; }
#search, .search-ghost {
  font: 15px/1.2 Inter, system-ui, sans-serif;
  padding: 10px 40px 10px 14px;
  border: 1.5px solid transparent;
  width: 100%;
}
#search {
  position: relative;
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
  border-radius: 10px;
  z-index: 1;
}
#search:focus { outline: none; border-color: var(--line); }
#search::placeholder { color: var(--muted); }
.search-field::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--paper);
  border-radius: 10px;
}
.search-ghost {
  position: absolute;
  inset: 0;
  color: var(--muted);
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
}
.search-ghost .typed { color: transparent; }
.search-key {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  font: 12px "JetBrains Mono", monospace;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  pointer-events: none;
}
#search:focus ~ .search-key { display: none; }
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 18%);
}
.suggestions li { padding: 8px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.suggestions li b { color: var(--ink); font-weight: 600; }
.suggestions li:hover, .suggestions li[aria-selected="true"] { background: var(--step-bg); color: var(--ink); }

/* ---------- Loading fun ---------- */
.fun-loader { text-align: center; padding: 40px 16px; }
.dance { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; font-size: 34px; line-height: 1; margin-bottom: 22px; }
.dance span {
  display: inline-block;
  animation: boogie 1.1s ease-in-out infinite;
  animation-delay: calc(var(--n) * -0.09s);
}
.dance span:nth-child(odd) { animation-name: boogie-alt; }
@keyframes boogie {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-18px) rotate(12deg) scale(1.12); }
}
@keyframes boogie-alt {
  0%, 100% { transform: translateY(-12px) rotate(10deg); }
  50% { transform: translateY(4px) rotate(-14deg) scale(0.92); }
}
.fun-line {
  font: 500 19px/1.4 Fraunces, Georgia, serif;
  margin: 0 auto;
  max-width: 34ch;
  min-height: 2.8em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
}
.fun-line.show { opacity: 1; transform: none; }
.fun-caption { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.45s ease;
  /* Safety net: never block the page, even if scripts fail. */
  animation: splash-out 0.45s ease 6s forwards;
}
.splash .dance { font-size: 48px; gap: 10px; }
.splash .fun-line { font-size: 24px; }
.splash.gone { opacity: 0; pointer-events: none; }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  .dance span { animation: none; }
  .fun-line { transition: none; }
}

.emo { display: inline-block; width: 1.5em; flex: none; text-align: left; }
.chip .emo:empty, .node .emo:empty { display: none; }
.chip .emo, .node .emo { width: auto; margin-right: 4px; }
.error { color: #c2410c; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: -8px 0 18px; font-size: 13px; color: var(--muted); }
.meta:not(:has(> span:not([hidden]))) { display: none; }
.time {
  color: var(--ink);
  font-weight: 600;
  background: var(--step-bg);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: help;
}
.method { margin-top: 24px; }
.method ol { margin: 0; padding-left: 22px; display: grid; gap: 8px; max-width: 72ch; }

.app {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 20px;
  min-height: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  min-height: 34px;
}
.panel-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.app.editing { grid-template-columns: minmax(300px, 380px) 1fr; }
.output .panel-head { flex-wrap: wrap; }
.head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor[hidden] { display: none; }

.editor { display: flex; flex-direction: column; min-width: 0; }
#src {
  flex: 1;
  min-height: 360px;
  width: 100%;
  resize: vertical;
  padding: 14px;
  font: 13px/1.6 "JetBrains Mono", ui-monospace, monospace;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  tab-size: 2;
  white-space: pre;
}
.help { margin-top: 12px; font-size: 13px; color: var(--muted); }
.help summary { cursor: pointer; color: var(--ink); font-weight: 500; }
.help ul { padding-left: 18px; margin: 8px 0; }
.help li { margin: 3px 0; }
.help code, .help pre {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 1px 4px;
}
.help pre { padding: 8px 10px; margin: 0; color: var(--ink); }

.output { min-width: 0; display: flex; flex-direction: column; }
.tabs { display: inline-flex; background: var(--code-bg); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 5px 14px; border-radius: 7px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }

.sheet {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 24px;
  min-width: 0;
}
#title { font: 700 28px/1.2 Fraunces, Georgia, serif; margin: 0 0 18px; }
.scroll { overflow-x: auto; max-width: 100%; }
.empty { color: var(--muted); }

/* ---------- Grid ---------- */
.grid { width: 100%; border-collapse: collapse; border: 2px solid var(--rule); font-size: 14.5px; }
.grid td { border: 1.5px solid var(--rule); padding: 5px 10px; vertical-align: middle; transition: background 0.12s; }
.grid td.ing { min-width: 220px; width: 34%; }
.grid td.step { text-align: center; min-width: 64px; max-width: 150px; background: var(--step-bg); font-weight: 500; }
.grid td.fill { background: var(--fill); }
.grid td.full { text-align: center; }
.grid td.prep { font-weight: 500; }
.grid td.note { color: var(--muted); font-style: italic; }
.grid td.ing.hl, .grid td.fill.hl { background: var(--hl); }
.grid td.step.hl { background: var(--hl-step); }

/* ---------- Graph ---------- */
.graph { position: relative; margin: 6px 0; }
.graph svg { position: absolute; inset: 0; overflow: visible; }
.graph path { fill: none; stroke: var(--line-soft); stroke-width: 2; transition: stroke 0.12s; }
.graph path.hl { stroke: var(--line); stroke-width: 2.5; }
.node {
  position: absolute;
  transform: translateY(-50%);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.3;
  background: var(--paper);
  border: 1.5px solid var(--line-soft);
  overflow-wrap: anywhere;
  transition: background 0.12s, border-color 0.12s;
}
.node.step {
  background: var(--step-bg);
  border-color: var(--rule);
  text-align: center;
  font-weight: 500;
  border-radius: 16px;
  padding: 7px 12px;
}
.node.hl { background: var(--hl); border-color: var(--line); }
.node.step.hl { background: var(--hl-step); }
.side { list-style: none; padding: 0; margin: 0 0 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.side li { border: 1.5px dashed var(--line); border-radius: 8px; padding: 6px 12px; font-size: 13.5px; }
.side.note { margin: 16px 0 0; }
.side.note li { font-style: italic; color: var(--muted); }

/* ---------- Steps ---------- */
.sheet h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
.prep-list { margin: 0 0 20px; padding-left: 20px; }
.prep-list.notes { margin: 20px 0 0; color: var(--muted); font-style: italic; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: background 0.12s;
}
.steps > li::before {
  content: counter(step);
  grid-row: span 2;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--line); color: var(--paper);
  font-weight: 600; font-size: 14px;
}
.steps > li.hl { background: var(--step-bg); }
.verb { font-weight: 600; font-size: 16px; margin-bottom: 6px; }
.verb::first-letter { text-transform: uppercase; }
.inputs { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: var(--code-bg); }
.chip.ref { background: transparent; border: 1.5px solid var(--line); color: var(--accent); font-weight: 500; }
.chip.hl { background: var(--hl); }

@media (max-width: 860px) {
  .app, .app.editing { grid-template-columns: 1fr; padding: 16px; }
  .output { order: -1; }
  .topbar { padding: 12px 16px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .toolbar { padding: 8px 16px; gap: 8px 16px; }
  #src { min-height: 260px; }
  .sheet { padding: 16px; }
  .grid { font-size: 13px; }
  .grid td { padding: 4px 6px; }
  .grid td.ing { min-width: 130px; }
  .grid td.step { min-width: 44px; }
}

@media print {
  body { background: #fff; }
  .topbar, .toolbar, .editor, .panel-head { display: none; }
  .app { display: block; padding: 0; }
  .sheet { border: 0; box-shadow: none; padding: 0; }
  .scroll { overflow: visible; }
}

/* ---------- Links & footer ---------- */
a.brand { color: inherit; text-decoration: none; }
.button-link {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  text-decoration: none;
}
.button-link:hover { border-color: var(--line); }
.site-footer {
  text-align: center;
  padding: 28px 16px 36px;
  color: var(--muted);
  font: italic 500 15px Fraunces, Georgia, serif;
}
.site-footer a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1.5px solid var(--line-soft);
}
.site-footer a:hover { border-bottom-color: var(--line); }

/* ---------- About ---------- */
.about { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 20px; }
.about h2 { font: 700 30px/1.2 Fraunces, Georgia, serif; margin: 0 0 8px; }
.about-hero { text-align: center; padding: 56px 0 36px; }
.float-row { display: flex; justify-content: center; gap: 14px; font-size: 26px; margin-bottom: 18px; }
.float-row span { animation: float 3.2s ease-in-out infinite; }
.float-row span:nth-child(2) { animation-delay: -0.6s; }
.float-row span:nth-child(3) { animation-delay: -1.2s; }
.float-row span:nth-child(4) { animation-delay: -1.8s; }
.float-row span:nth-child(5) { animation-delay: -2.4s; }
@keyframes float { 50% { transform: translateY(-7px) rotate(6deg); } }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 10px; }
.about-hero h1 { font: 700 clamp(34px, 6vw, 56px)/1.08 Fraunces, Georgia, serif; margin: 0 auto 18px; max-width: 16ch; letter-spacing: -0.01em; }
.lede { font-size: 18px; line-height: 1.6; color: var(--muted); max-width: 60ch; margin: 0 auto; }

.shot { max-width: 860px; margin: 12px auto 64px; }
.window {
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #25211c;
  box-shadow: 0 2px 4px rgb(0 0 0 / 8%), 0 24px 60px rgb(60 45 25 / 18%);
  transform: rotate(-0.6deg);
}
.window-bar { display: flex; gap: 7px; padding: 11px 14px; background: #2f2922; }
.window-bar i { width: 11px; height: 11px; border-radius: 50%; background: #4a4136; }
.window-bar i:first-child { background: #e8735a; }
.window-bar i:nth-child(2) { background: #e9c05a; }
.window-bar i:nth-child(3) { background: #6fbf73; }
.window img { display: block; width: 100%; height: auto; }
.callouts { list-style: none; counter-reset: c; padding: 0; margin: 0; display: grid; gap: 18px; }
.callouts li { counter-increment: c; position: relative; padding-left: 40px; line-height: 1.5; color: var(--muted); }
.callouts li b { color: var(--ink); display: block; }
.callouts li::before {
  content: counter(c);
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--line); color: var(--paper);
  font-weight: 700; font-size: 14px;
}

.section-lede { color: var(--muted); font-size: 17px; margin: 0 0 24px; }
.why, .shapes { margin-bottom: 64px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-icon {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--step-bg);
  font-size: 22px;
  margin-bottom: 14px;
}
.card h3 { font: 700 19px/1.3 Fraunces, Georgia, serif; margin: 0 0 6px; }
.card p { margin: 0; color: var(--muted); line-height: 1.55; }

.shape-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 0; }
.shape-list div { border-top: 2px solid var(--line); padding-top: 14px; }
.shape-list dt { font-weight: 600; margin-bottom: 4px; }
.shape-list dd { margin: 0; color: var(--muted); line-height: 1.5; }

.about .note {
  text-align: center;
  background: var(--step-bg);
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  padding: 44px 28px;
  margin-bottom: 28px;
}
.about .note p { max-width: 58ch; margin: 0 auto 14px; line-height: 1.65; font-size: 17px; }
.note-kind { font: italic 500 20px/1.5 Fraunces, Georgia, serif; color: var(--accent); }
.cta {
  display: inline-block;
  margin-top: 10px;
  background: var(--line);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  padding: 11px 22px;
  border-radius: 999px;
}
.cta:hover { filter: brightness(1.08); }
.credit { text-align: center; color: var(--muted); font-size: 13px; max-width: 62ch; margin: 0 auto; }

@media (max-width: 760px) {
  .shot { grid-template-columns: 1fr; }
  .shape-list, .cards { grid-template-columns: 1fr; }
  .about { padding: 0 16px; }
  .about-hero { padding-top: 36px; }
  .window { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .float-row span { animation: none; }
}

/* ---------- Editor hint & manual ---------- */
.editor-hint {
  margin: -2px 0 12px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
  background: var(--step-bg);
  border: 1px dashed var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.help h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); }
.help p { margin: 6px 0; line-height: 1.5; }
.help .help-list { padding-left: 20px; margin: 6px 0; }
.help .help-list li { margin: 4px 0; line-height: 1.45; }
.help b { color: var(--ink); font-weight: 600; }
.help-example { display: grid; gap: 8px; margin: 10px 0; }
.help-example pre { white-space: pre; overflow-x: auto; line-height: 1.6; }
.help-example .k { color: var(--accent); font-weight: 500; }
.help-example .c { color: var(--muted); }
.help-arrow { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.help-arrow::after { content: " ↓"; }
.grid.mini { font-size: 12.5px; border-width: 1.5px; }
.grid.mini td { padding: 4px 8px; }
.grid.mini td.ing { min-width: 0; }
.grid.mini td.step { min-width: 0; }
.help-tip { font-size: 12.5px; }
.help kbd {
  font: 11px "JetBrains Mono", monospace;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  background: var(--paper);
  color: var(--ink);
}

/* ---------- Check-offs ---------- */
.grid td.ing, .grid td.step, .node, .steps > li, .chip { cursor: pointer; }
.grid td[role="button"]:focus-visible, .node:focus-visible, .steps > li:focus-visible { outline: 2px solid var(--line); outline-offset: -2px; }
.grid td.is-done, .node.is-done, .steps > li.is-done, .chip.is-done { opacity: 0.42; }
.grid td.fill.is-done { opacity: 0.42; }
.graph path.is-done { opacity: 0.35; }
.grid td.is-done .step-text, .grid td.ing.is-done, .node.is-done, .chip.is-done, .steps > li.is-done .verb {
  text-decoration: line-through;
  text-decoration-color: var(--line);
  text-decoration-thickness: 2px;
}
.grid td.step.is-done::after, .node.step.is-done::after { content: " ✓"; color: var(--accent); font-weight: 700; }
.grid td.step.is-ready, .node.step.is-ready, .steps > li.is-ready {
  box-shadow: inset 0 0 0 2.5px var(--accent);
  animation: ready-glow 2.4s ease-in-out infinite;
}
@keyframes ready-glow { 50% { box-shadow: inset 0 0 0 2.5px var(--line-soft); } }
.progress { font-weight: 600; color: var(--ink); }
.progress-hint { font-weight: 400; color: var(--muted); }
.link-button {
  border: 0; background: none; padding: 0; margin-left: 6px;
  color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 2px;
}
.scale-note { margin: -8px 0 16px; font-size: 13px; color: var(--muted); }
.scale-note::before { content: "⚖️ "; }

/* ---------- Timers ---------- */
.timer-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 6px; }
.grid td.full .timer-btns, .side .timer-btns, .prep-list .timer-btns, .verb .timer-btns { display: inline-flex; margin: 0 0 0 8px; vertical-align: middle; }
.timer-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--accent);
  white-space: nowrap;
  text-decoration: none;
}
.timer-btn:hover { background: var(--line); color: var(--paper); }
.timer-tray {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(300px, calc(100vw - 32px));
}
.timer-tray[hidden] { display: none; }
.timer {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 22%);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
}
.timer-label { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-clock { font: 700 24px/1.1 "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.timer.paused .timer-clock { color: var(--muted); }
.timer-controls { display: flex; gap: 4px; }
.timer-controls button { padding: 3px 9px; font-size: 13px; }
.timer-controls .primary { background: var(--line); border-color: var(--line); color: var(--paper); font-weight: 600; }
.timer-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 0; background: var(--line); transition: width 0.25s linear; }
.timer.ringing { border-color: #e9a23b; animation: ring 0.9s ease-in-out infinite; }
.timer.ringing .timer-clock { color: #d9822b; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-2deg); } 40% { transform: rotate(2deg); } 60% { transform: rotate(-1deg); } }
@media (max-width: 860px) {
  .timer-tray { left: 16px; right: 16px; width: auto; }
}

/* ---------- Reading comfort ---------- */
.reading-note {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 90ch;
}
.reading-note b { color: var(--ink); }
:root[data-reading="easy"] body,
:root[data-reading="easy"] body :is(h1, h2, h3, h4, p, li, td, th, button, input, select, a, span, div, dt, dd, label, summary, b, i, em, strong):not(pre *, .timer-clock) {
  font-family: "Atkinson Hyperlegible", Verdana, sans-serif !important;
  font-style: normal !important;
}
:root[data-reading="easy"] body { letter-spacing: 0.02em; word-spacing: 0.12em; }
:root[data-reading="easy"] :is(.sheet, .about) { zoom: 1.1; }
:root[data-reading="easy"] :is(.grid td, .node, .steps li, .method li, .card p, .lede, .note p) { line-height: 1.6; }
:root[data-reading="easy"] :is(.grid td.step, .node.step) { text-align: left; }
:root[data-reading="easy"] .timer-clock { font-family: "JetBrains Mono", ui-monospace, monospace !important; }

@media (prefers-reduced-motion: reduce) {
  .grid td.step.is-ready, .node.step.is-ready, .steps > li.is-ready, .timer.ringing { animation: none; }
}
@media print {
  .timer-tray, .timer-btns, .progress, .reading-note { display: none !important; }
}
.grid.mini td { cursor: default; }
.progress .tick { color: var(--accent); font-weight: 800; margin-right: 2px; }

/* ---------- Text size ---------- */
/* Zooming the page scales every size in the design together, like browser zoom. */
:root[data-size="small"] body { zoom: 0.9; }
:root[data-size="large"] body { zoom: 1.15; }
:root[data-size="xlarge"] body { zoom: 1.3; }
.size-seg button { min-width: 34px; padding: 2px 8px; line-height: 1; }
.size-seg .aa { font-weight: 700; font-family: Fraunces, Georgia, serif; }

/* ---------- About: Why CookNoBook ---------- */
.perks-section { margin-bottom: 64px; }
.perks { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.perks li {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 16px;
  align-items: start;
  padding: 18px 20px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-left: 4px solid var(--line);
  border-radius: 14px;
}
.perk-icon {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--step-bg);
  font-size: 24px;
}
.perks h3 { font: 700 19px/1.3 Fraunces, Georgia, serif; margin: 2px 0 6px; }
.perks p { margin: 0; color: var(--muted); line-height: 1.6; }
.credit a { color: var(--accent); }
@media (max-width: 760px) {
  .perks li { grid-template-columns: 1fr; gap: 10px; }
}

/* Server-rendered copy of a recipe, shown only when scripts are off. */
.static-recipe { max-width: 720px; margin: 24px auto; padding: 0 20px; line-height: 1.6; }
.static-recipe h1 { font: 700 32px Fraunces, Georgia, serif; }
img.logo { width: 26px; height: 26px; display: block; border-radius: 6px; }

/* ---------- Share menu ---------- */
.share-wrap { position: relative; }
.share-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  min-width: 230px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgb(0 0 0 / 22%);
}
.share-menu[hidden] { display: none; }
.share-menu [role="menuitem"] {
  display: block;
  text-align: left;
  border: 0;
  background: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.share-menu [role="menuitem"][hidden] { display: none; }
.share-menu [role="menuitem"]:hover, .share-menu [role="menuitem"]:focus-visible { background: var(--step-bg); outline: none; }
@media print { .share-wrap { display: none; } }

.notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--step-bg);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Cards view ---------- */
.cards-view { max-width: 640px; margin: 0 auto; }
.card-progress { height: 6px; border-radius: 6px; background: var(--line-soft); overflow: hidden; margin-bottom: 16px; }
.card-progress i { display: block; height: 100%; background: var(--line); transition: width 0.3s ease; }
.flashcard {
  min-height: 300px;
  padding: 28px 30px;
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: 20px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 6%), 0 18px 40px rgb(60 45 25 / 12%);
  touch-action: pan-y;
  user-select: none;
}
.flashcard.enter-next { animation: card-in-right 0.25s ease; }
.flashcard.enter-prev { animation: card-in-left 0.25s ease; }
@keyframes card-in-right { from { opacity: 0; transform: translateX(28px) rotate(1deg); } }
@keyframes card-in-left { from { opacity: 0; transform: translateX(-28px) rotate(-1deg); } }
.card-kicker { margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.card-done { color: var(--muted); text-transform: none; letter-spacing: 0; }
.card-title { font: 700 28px/1.25 Fraunces, Georgia, serif; margin: 0 0 18px; }
.card-title .timer-btns { justify-content: flex-start; margin-top: 10px; }
.card-title .timer-btn { font: 600 14px Inter, system-ui, sans-serif; padding: 4px 12px; }
.card-sub { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.card-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.card-list li { padding: 10px 12px; border-radius: 10px; background: var(--step-bg); font-size: 16px; line-height: 1.4; }
.card-list .emo { width: 1.6em; }
.card-list.prep li, .card-list.notes li { background: none; border: 1px dashed var(--rule); }
.card-list .from-step { background: none; border: 1.5px solid var(--line-soft); font-weight: 500; }
.card-list .from-step span { font-weight: 400; color: var(--muted); }
.card-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.card-nav button { padding: 10px 18px; font-size: 15px; border-radius: 999px; }
.card-nav button:disabled { opacity: 0.4; cursor: default; }
.card-nav .primary { background: var(--line); border-color: var(--line); color: var(--paper); font-weight: 600; }
.card-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-hint { text-align: center; font-size: 12.5px; color: var(--muted); margin: 12px 0 0; }
@media (max-width: 860px) {
  .flashcard { padding: 22px 20px; min-height: 260px; }
  .card-title { font-size: 24px; }
  .card-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .flashcard.enter-next, .flashcard.enter-prev { animation: none; }
}

/* ---------- About: the four formats ---------- */
.format {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 32px;
  align-items: center;
  margin: 0 0 40px;
}
.format:nth-of-type(even) .format-shot { order: 2; }
.format-shot { margin: 0; transform: none; }
.format-text h3 { font: 700 24px/1.2 Fraunces, Georgia, serif; margin: 0 0 6px; }
.format-text > p { margin: 0 0 14px; color: var(--muted); line-height: 1.55; }
.format-steps { list-style: none; counter-reset: fs; padding: 0; margin: 0; display: grid; gap: 10px; }
.format-steps li { counter-increment: fs; position: relative; padding-left: 36px; line-height: 1.5; }
.format-steps li::before {
  content: counter(fs);
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--step-bg); border: 1.5px solid var(--line);
  color: var(--accent); font-weight: 700; font-size: 12.5px;
}
@media (max-width: 760px) {
  .format { grid-template-columns: 1fr; gap: 16px; }
  .format:nth-of-type(even) .format-shot { order: 0; }
}

/* ---------- Copy pop-up ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 70;
  width: min(440px, calc(100vw - 32px));
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgb(0 0 0 / 25%);
  cursor: pointer;
  animation: toast-in 0.2s ease;
}
.toast[hidden] { display: none; }
.toast strong { font-size: 15px; color: var(--ink); }
.toast span { font-size: 13.5px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Story preview ---------- */
.story-dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 18px;
  border: 1.5px solid var(--rule);
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 80px rgb(0 0 0 / 35%);
}
.story-dialog::backdrop { background: rgb(20 16 12 / 55%); }
.story-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.story-head h2 { font: 700 20px Fraunces, Georgia, serif; margin: 0; }
.story-close { border-radius: 999px; padding: 4px 10px; }
.story-preview {
  display: block;
  width: 100%;
  max-height: 58vh;
  object-fit: contain;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  background: var(--step-bg);
}
.story-help { font-size: 13.5px; line-height: 1.5; color: var(--muted); margin: 12px 0; }
.story-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.story-actions .primary { background: var(--line); border-color: var(--line); color: var(--paper); font-weight: 600; }
.story-actions [hidden] { display: none; }

.feedback {
  text-align: center;
  margin: 8px auto 20px;
  font: 500 19px/1.5 Fraunces, Georgia, serif;
  color: var(--ink);
}
.feedback a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1.5px solid var(--line-soft);
}
.feedback a:hover { border-bottom-color: var(--line); }

/* ---------- About: friend photo ---------- */
/* One 800×560 stage, scaled as a whole so the arrow always lands on his head. */
.friend { margin: 0 auto 56px; max-width: 800px; }
.friend-stage { position: relative; width: 100%; aspect-ratio: 800 / 560; container-type: inline-size; }
.polaroid {
  position: absolute;
  left: 5%;
  top: 4%;
  width: 44%;
  margin: 0;
  padding: 1.5% 1.5% 7%;
  background: #fbf8f2;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 10%), 0 18px 40px rgb(60 45 25 / 22%);
  transform: rotate(-5deg);
}
.polaroid img { display: block; width: 100%; height: auto; border-radius: 2px; }
.friend-arrow { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.friend-arrow path { fill: none; stroke: var(--accent); stroke-width: 3.2; stroke-dasharray: 2 9; stroke-linecap: round; }
.friend-arrow marker path { fill: var(--accent); stroke: var(--bg); stroke-width: 1.2; stroke-dasharray: none; }
.friend-note {
  position: absolute;
  left: 58%;
  top: 64%;
  width: 38%;
  margin: 0;
  font: 600 4.6cqw/1.15 Caveat, "Comic Sans MS", cursive;
  color: var(--ink);
  transform: rotate(-3deg);
}
:root[data-reading="easy"] body .friend .friend-note { font-family: Caveat, cursive !important; }
