/* ==========================================================================
   Tompines · paper, ink and a little whimsy
   ========================================================================== */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/inter-latin-ext-variable.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/inter-latin-variable.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face { font-family: 'Zilla Slab'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/zilla-slab-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Zilla Slab'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/zilla-slab-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Zilla Slab'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/zilla-slab-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Zilla Slab'; font-style: italic; font-weight: 500; font-display: swap; src: url('fonts/zilla-slab-latin-500-italic.woff2') format('woff2'); }
@property --sky-a { syntax: '<color>'; inherits: true; initial-value: #a9cbe0; }
@property --sky-b { syntax: '<color>'; inherits: true; initial-value: #d6e4e6; }
@property --sky-c { syntax: '<color>'; inherits: true; initial-value: #f3ead2; }

:root {
  color-scheme: light;
  --paper: #f6f0e4;
  --paper-2: #efe6d3;
  --card: #fbf7ee;
  --ink: #2a2420;
  --ink-2: #4a4038;
  --muted: #6f6359;
  --line: #ddd0ba;
  --green: #1f3d36;
  --green-2: #2b5248;
  --gold: #d9a441;
  --gold-2: #e7c873;
  --red: #b4503b;
  --link: #1d6656;
  --serif: 'Zilla Slab', Rockwell, 'Roboto Slab', Georgia, serif;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --grain: url('assets/grain.png');
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0; overflow-x: clip;
  color: var(--ink);
  background: var(--paper) var(--grain);
  font: 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button, a, input, summary, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { color: inherit; cursor: pointer; transition: background .18s, box-shadow .18s, transform .18s, color .18s; }
button:disabled, select:disabled { cursor: default; opacity: .46; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -80px; left: 16px; z-index: 40; padding: 12px 18px; border-radius: 10px; background: var(--card); border: 1.5px solid var(--ink); }
.skip-link:focus { top: 12px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--green); margin: 0; letter-spacing: -.01em; }
.eyebrow, .section-kicker { margin: 0 0 10px; font-size: 11.5px; font-weight: 650; letter-spacing: .16em; text-transform: uppercase; color: var(--red); }

/* ---------------------------------------------------------------- masthead */
.masthead {
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 64px; padding: 8px max(24px, calc((100% - 1240px)/2));
  background: rgba(246,240,228,.86); backdrop-filter: blur(10px) saturate(1.1); -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border-bottom: 1px solid rgba(42,36,32,.16);
}
.brand, .footer-brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--green); }
.brand svg { flex: none; }
.brand > svg:first-child { width: 34px; height: 35px; }
.brand .wordmark { width: auto; height: 34px; }
.brand-name { font-family: var(--serif); font-size: 25px; font-weight: 620; letter-spacing: -.015em; line-height: 1; }
.site-nav { display: flex; align-items: center; gap: 26px; }
.nav-link { color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 500; min-height: 44px; display: inline-flex; align-items: center; }
.nav-link:hover, .nav-link[aria-current=page] { color: var(--green); text-decoration: underline wavy var(--gold); text-underline-offset: 7px; text-decoration-thickness: 1.5px; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1.5px solid rgba(42,36,32,.3); border-radius: 50%; background: transparent; color: var(--ink-2); }
.nav-icon:hover { border-color: var(--ink); color: var(--ink); }
.nav-icon .sound-on { display: none; }
.nav-icon[aria-pressed=true] { background: var(--green); color: var(--paper); border-color: var(--green); }
.nav-icon[aria-pressed=true] .sound-on { display: inline; }
.nav-icon[aria-pressed=true] .sound-off { display: none; }

/* ---------------------------------------------------------------- hero scene */
.hero { position: relative; isolation: isolate; padding: 30px 24px 0; }
.scene {
  position: absolute; z-index: -1; left: 0; right: 0; top: -64px; height: var(--scene-h, 72%);
  overflow: hidden; pointer-events: none;
  --sky-a: #9fc4dc; --sky-b: #cfe1e6; --sky-c: #f4ead1;
  --town-filter: none; --lights: 0; --stars: 0; --sun: 1; --moon: 0; --sun-x: 78%; --sun-y: 18%; --moon-x: 80%; --moon-y: 16%;
  transition: --sky-a 1.6s ease, --sky-b 1.6s ease, --sky-c 1.6s ease;
}
.scene[data-sky=dawn]      { --sky-a: #8f97bf; --sky-b: #e2b9b4; --sky-c: #f6d6a8; --town-filter: sepia(.2) saturate(1.05) hue-rotate(-10deg) brightness(.95); --lights: .3; --stars: .25; --sun-x: 12%; --sun-y: 52%; }
.scene[data-sky=morning]   { --sky-a: #9fc4dc; --sky-b: #cfe1e6; --sky-c: #f4ead1; }
.scene[data-sky=day]       { --sky-a: #8fbfe0; --sky-b: #c6dfe9; --sky-c: #eef0e2; --sun-x: 64%; --sun-y: 12%; }
.scene[data-sky=midday]    { --sky-a: #7fb6dd; --sky-b: #bfdcea; --sky-c: #f0f1e4; --town-filter: brightness(1.04) saturate(1.06); --sun-x: 50%; --sun-y: 6%; }
.scene[data-sky=afternoon] { --sky-a: #93bcd6; --sky-b: #d7dfd8; --sky-c: #f6e3bf; --town-filter: sepia(.12) saturate(1.1); --sun-x: 30%; --sun-y: 16%; }
.scene[data-sky=sunset]    { --sky-a: #6a6c9e; --sky-b: #e59a78; --sky-c: #f7cf8f; --town-filter: sepia(.32) saturate(1.25) hue-rotate(-14deg) brightness(.9); --lights: .45; --sun-x: 16%; --sun-y: 46%; }
.scene[data-sky=evening]   { --sky-a: #2a2a4b; --sky-b: #5b4f78; --sky-c: #b07d7c; --town-filter: brightness(.6) saturate(.8) hue-rotate(10deg); --lights: .9; --stars: .55; --sun: 0; --moon: 1; --moon-x: 70%; --moon-y: 22%; }
.scene[data-sky=twilight]  { --sky-a: #1b2a4e; --sky-b: #3d5a8a; --sky-c: #8a8fb3; --town-filter: brightness(.55) saturate(.78) hue-rotate(14deg); --lights: .9; --stars: .45; --sun: 0; --moon: .8; --moon-x: 24%; --moon-y: 26%; }
.scene[data-sky=night]     { --sky-a: #0d1424; --sky-b: #1b2742; --sky-c: #34405d; --town-filter: brightness(.42) saturate(.7) hue-rotate(18deg); --lights: 1; --stars: 1; --sun: 0; --moon: 1; --moon-x: 76%; --moon-y: 14%; }

.sky { position: absolute; inset: 0; background: linear-gradient(180deg, var(--sky-a) 0%, var(--sky-b) 52%, var(--sky-c) 100%); }
.sky::after { content: ''; position: absolute; inset: 0; background: var(--grain); mix-blend-mode: multiply; opacity: .55; }
.stars { position: absolute; inset: 0 0 35% 0; opacity: var(--stars); transition: opacity 1.6s; }
.stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff7dc; box-shadow: 0 0 4px #fff3c0; animation: twinkle 3s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .25; } to { opacity: 1; } }
.sun, .moon { position: absolute; width: clamp(70px, 8.5vw, 132px); aspect-ratio: 1; translate: -50% -50%; transition: left 2s ease, top 2s ease, opacity 1.4s; }
.sun { left: var(--sun-x); top: var(--sun-y); opacity: var(--sun); animation: sun-turn 160s linear infinite; }
.moon { left: var(--moon-x); top: var(--moon-y); opacity: var(--moon); }
@keyframes sun-turn { to { rotate: 360deg; } }

/* The stage: a 2400 x 900 drawing, scaled by scene.js to cover the scene, anchored bottom centre */
.stage { position: absolute; left: 50%; bottom: 0; width: 2400px; height: 900px; transform-origin: 50% 100%; transform: translateX(-50%) scale(var(--s, .6)); }
.stage img { position: absolute; display: block; max-width: none; user-select: none; -webkit-user-drag: none; }
.world { position: absolute; inset: 0; filter: var(--town-filter); transition: filter 1.6s ease, transform .6s ease-out; transform: translate3d(calc(var(--px, 0) * -8px), calc(var(--py, 0) * -3px), 0); }
.sky-movers { position: absolute; inset: 0; transition: transform .6s ease-out; transform: translate3d(calc(var(--px, 0) * -22px), calc(var(--py, 0) * -6px), 0); }
.layer-img { left: 0; top: 0; width: 2400px; height: 900px; }
.stage .lights { opacity: var(--lights); transition: opacity 1.6s ease, transform .6s ease-out; mix-blend-mode: screen; transform: translate3d(calc(var(--px, 0) * -8px), calc(var(--py, 0) * -3px), 0); }
.ground-fade { position: absolute; left: 0; right: 0; bottom: 0; height: 7%; background: linear-gradient(rgba(246,240,228,0), var(--paper) 95%); }

/* Everything that travels: vehicles, walkers, cyclists, clouds, birds, trains */
.mv { left: 0; will-change: transform; animation: go var(--dur, 30s) linear infinite; animation-delay: var(--delay, 0s); }
.mv.left { animation-name: go-left; }
@keyframes go { from { transform: translateX(calc(-100% - 10px)); } to { transform: translateX(2410px); } }
@keyframes go-left { from { transform: translateX(2410px); } to { transform: translateX(calc(-100% - 10px)); } }
.mv.train { animation-name: train-go; }
.mv.train.left { animation-name: train-go-left; }
@keyframes train-go { 0% { transform: translateX(calc(-100% - 10px)); } 50%, 100% { transform: translateX(2410px); } }
@keyframes train-go-left { 0% { transform: translateX(2410px); } 50%, 100% { transform: translateX(calc(-100% - 10px)); } }
.mv.plane { animation: plane 75s linear infinite; animation-delay: -18s; }
@keyframes plane { 0% { transform: translate(-200px, 40px); } 55%, 100% { transform: translate(2500px, -30px); } }
.tree { transform-origin: 50% 100%; animation: sway var(--sway, 7s) ease-in-out infinite alternate; animation-delay: var(--delay, 0s); }
@keyframes sway { from { transform: rotate(-1deg); } to { transform: rotate(1deg); } }
.kite { transform-origin: 0 100%; animation: kite 7s ease-in-out infinite alternate; }
@keyframes kite { from { transform: rotate(-3deg); } to { transform: rotate(2.5deg); } }
.umbrella-sway { transform-origin: 50% 100%; animation: sway 3.2s ease-in-out infinite alternate; }

/* ---------------------------------------------------------------- hero content */
.hero-inner { max-width: 1240px; margin: 0 auto; }
.cartouche {
  position: relative; max-width: 620px; margin: 0 auto; padding: 26px 40px 26px; text-align: center;
  background: var(--card) var(--grain); border: 1.5px solid var(--ink); border-radius: 3px;
  box-shadow: inset 0 0 0 5px var(--card), inset 0 0 0 6px rgba(42,36,32,.55), 0 18px 40px rgba(31,40,45,.18);
}
.cartouche::before, .cartouche::after { content: '✦'; position: absolute; top: 50%; translate: 0 -50%; color: var(--gold); font-size: 13px; }
.cartouche::before { left: 14px; } .cartouche::after { right: 14px; }
h1 { font-size: clamp(46px, 6vw, 72px); line-height: .95; font-weight: 700; letter-spacing: -.02em; }
h1 em { font-style: italic; font-weight: 500; padding-right: .04em; color: var(--red); position: relative; white-space: nowrap; }
h1 em::after {
  content: ''; position: absolute; left: -2%; right: -4%; bottom: -.12em; height: .22em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14'%3E%3Cpath d='M2 9c10-8 16 6 26-1s14-6 22 0 16 5 24-1 16-6 22 0 12 4 22-2' fill='none' stroke='%23d9a441' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}
.intro-text { max-width: 46ch; margin: 14px auto 0; font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.spin-controls { margin-top: 18px; }
.spin-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 210px; min-height: 50px; padding: 12px 26px;
  border: 1.5px solid var(--ink); border-radius: 999px; background: var(--green); color: #fbf5e6;
  font-size: 15.5px; font-weight: 600; letter-spacing: .01em; box-shadow: 0 4px 0 var(--ink);
}
.spin-button:hover:not(:disabled) { background: var(--green-2); transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.spin-button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.spin-button[aria-busy=true] svg { animation: turn 1.2s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- wheels */
.wheels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px; margin: 30px auto 0; max-width: 1180px; }
.wheel-card { --accent: #2f6f62; display: flex; flex-direction: column; min-width: 0; }
.wheel-card.time { --accent: #41557f; }
.wheel-card.feeling { --accent: #a4485e; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; max-width: 340px; margin: 0 auto 10px; }
.card-top h2 {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 15px 7px; font-size: 19px; line-height: 1.1; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 rgba(42,36,32,.25);
}
.card-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-family: var(--body); font-size: 12.5px; font-weight: 700; font-style: normal; line-height: 1; align-self: center; }
.lock-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 36px; padding: 5px 12px;
  border: 1.5px solid var(--ink); border-radius: 999px; background: var(--card); color: var(--ink-2); font-size: 12.5px; font-weight: 600; box-shadow: 0 2px 0 rgba(42,36,32,.25);
}
.lock-button:hover:not(:disabled) { color: var(--ink); background: #fff; }
.lock-button[aria-pressed=true] { background: var(--accent); color: #fff; border-color: var(--ink); }
.wheel-card.nudge .lock-button { animation: nudge .4s; }
@keyframes nudge { 25% { transform: translateX(-4px) rotate(-3deg); } 75% { transform: translateX(4px) rotate(3deg); } }
.wheel-wrap {
  position: relative; width: 100%; max-width: 340px; aspect-ratio: 1; margin: 0 auto;
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.wheel-wrap.grabbing { cursor: grabbing; }
.wheel-wrap::after { content: ''; position: absolute; z-index: -1; left: 10%; right: 10%; bottom: -5%; height: 12%; border-radius: 50%; background: rgba(30,24,20,.28); filter: blur(12px); }
.wheel-svg, .wheel-face { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.wheel-svg { transform-origin: 50% 50%; will-change: transform; }
.wheel-face { pointer-events: none; filter: drop-shadow(0 6px 10px rgba(30,24,20,.22)); }
.wheel-grain { position: absolute; inset: 7%; border-radius: 50%; background: var(--grain); mix-blend-mode: multiply; opacity: .8; pointer-events: none; }
.pointer { position: absolute; z-index: 3; width: 11%; left: 44.5%; top: -5%; overflow: visible; transform-origin: 50% 25%; pointer-events: none; filter: drop-shadow(0 3px 2px rgba(30,24,20,.35)); }
.pointer path { fill: #d0533f; stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: round; }
.pointer circle { fill: #fbf8f0; stroke: var(--ink); stroke-width: 1.6; }
.wheel-card.locked .wheel-wrap { cursor: not-allowed; }
.wheel-card.locked .wheel-face .bezel-ring { stroke: var(--accent); }
.wheel-label { font-family: var(--body); font-size: 10.6px; font-weight: 560; letter-spacing: -.01em; }
.bezel-text { font-family: var(--body); font-size: 7.4px; font-weight: 650; }
.result-area { display: flex; flex: 1; flex-direction: column; align-items: center; text-align: center; min-height: 96px; padding: 20px 10px 2px; }
.result { margin: 0; max-width: 100%; font-family: var(--serif); font-size: 29px; font-weight: 560; line-height: 1.1; color: var(--ink); overflow-wrap: anywhere; }
.wheel-card.spinning .result { color: var(--muted); font-style: italic; font-weight: 400; }
.wheel-card.landed .result { animation: land .6s cubic-bezier(.2,1.6,.4,1); }
@keyframes land { from { transform: scale(.86); color: var(--accent); } 60% { color: var(--accent); } }
.meaning { margin: 7px 0 0; max-width: 290px; color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.single-spin { display: inline-flex; align-items: center; justify-content: center; gap: 7px; align-self: center; min-height: 44px; padding: 8px 12px; border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 600; }
.single-spin:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 5px; }

/* story ticket */
.ticket-row { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 18px auto 0; text-align: center; }
.ticket {
  --notch: radial-gradient(circle at 0 50%, transparent 9px, #000 9.5px) left / 51% 100% no-repeat, radial-gradient(circle at 100% 50%, transparent 9px, #000 9.5px) right / 51% 100% no-repeat;
  display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 6px 16px; padding: 13px 30px; max-width: 100%;
  background: #fff8e6 var(--grain); color: var(--ink); text-decoration: none;
  border-top: 1.5px dashed rgba(42,36,32,.5); border-bottom: 1.5px dashed rgba(42,36,32,.5);
  -webkit-mask: var(--notch); mask: var(--notch);
  filter: drop-shadow(0 4px 6px rgba(30,24,20,.12));
}
.ticket.fresh { animation: ticket .7s cubic-bezier(.2,1.3,.4,1); }
@keyframes ticket { from { transform: translateY(14px) rotate(-1.5deg); opacity: 0; } }
.ticket-label { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--red); }
.ticket-choices { font-family: var(--serif); font-style: italic; font-size: 20px; line-height: 1.3; }
.ticket-choices .sep { color: var(--gold); font-style: normal; font-size: 13px; margin: 0 8px; vertical-align: 2px; }
.ticket-go { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 650; color: var(--link); }
.ticket:hover .ticket-go { text-decoration: underline; text-underline-offset: 4px; }
.wheel-tip { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.wheel-tip strong { color: var(--ink-2); font-weight: 650; }

/* settings */
.exercise-settings { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 14px 30px; max-width: 980px; margin: 22px auto 0; padding: 18px 0 30px; border-top: 1px solid var(--line); }
.setting-field { width: 196px; flex-shrink: 0; }
.setting-field label { display: block; margin-bottom: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
select { appearance: none; width: 100%; min-height: 44px; border: 0; border-bottom: 1.5px solid var(--ink); border-radius: 0; padding: 9px 26px 7px 0; color: var(--ink); background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%232a2420' stroke-width='1.8'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 3px center; font-size: 15px; cursor: pointer; }
select:hover:not(:disabled) { color: var(--link); }
.settings-explanation { margin-left: auto; text-align: right; }
.combination-count { margin: 0; color: var(--muted); font-size: 12.5px; }
.combination-count strong { font-family: var(--serif); color: var(--green); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bank-count { margin: 0; font-size: 11.5px; color: var(--muted); }
.edit-button { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 8px 16px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--card); font-size: 13px; font-weight: 600; color: var(--ink); }
.edit-button:hover:not(:disabled) { background: #fff; }

/* ---------------------------------------------------------------- writing */
.micro { font-size: 12px; color: var(--muted); line-height: 1.65; margin: 8px 0 0; }
.writing-section { position: relative; isolation: isolate; padding: 70px 24px 64px; }
.writing-section::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--paper-2) var(--grain); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.writing-heading { max-width: 920px; margin: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 26px; }
.writing-heading > div:first-child { max-width: 580px; }
.writing-heading h2 { font-size: 44px; line-height: 1.05; }
.writing-heading p:not(.section-kicker) { color: var(--ink-2); font-size: 15.5px; line-height: 1.7; margin: 14px 0 0; }
.export-actions { display: flex; align-items: center; flex-shrink: 0; gap: 20px; }
.download-button, .outline-button, .text-button { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 8px 2px; border: 0; background: none; color: var(--link); font-size: 13px; font-weight: 600; white-space: nowrap; }
.download-button:hover:not(:disabled), .outline-button:hover:not(:disabled), .text-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 4px; }
.export-status { max-width: 920px; min-height: 20px; margin: 10px auto 0; color: var(--link); font-size: 12px; }
.prompt-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 14px; }
.outline-button { padding: 8px 4px; }
.notebook-paper { --paper-left: 82px; --paper-right: 42px; --rule-height: 34px; position: relative; isolation: isolate; max-width: 920px; margin: 4px auto 0; padding: 31px var(--paper-right) 28px var(--paper-left); border-radius: 2px 3px 4px 2px; background: linear-gradient(95deg,#f9f7ed 0%,#fffdf7 3%,#fffefa 12%,#fffefa 96%,#fdfbf4 100%); box-shadow: 0 1px 2px #3d332d18, 0 18px 45px #4b454014; }
.notebook-paper::before { content: ''; position: absolute; top: 0; bottom: 0; left: 59px; width: 1px; background: #ce8b8a66; z-index: 1; pointer-events: none; }
.notebook-paper::after { content: ''; position: absolute; z-index: -1; top: 7px; left: 3px; right: -2px; bottom: -4px; border-radius: 1px; background: #fffdf8; box-shadow: 0 1px 2px #3d332d14; transform: rotate(.12deg); }
.paper-header { min-height: 54px; }
.chosen-prompt { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 13.5px; line-height: 1.8; color: #625d56; }
.chosen-prompt strong { font-weight: 600; }
.lesson-focus { margin: 7px 0 0; font-size: 11.5px; line-height: 1.6; color: #797165; }
.paper-writing { margin: 17px calc(-1*var(--paper-right)) 0 calc(-1*var(--paper-left)); padding: 0 var(--paper-right) 0 var(--paper-left); background: repeating-linear-gradient(to bottom,transparent 0,transparent 26px,#a6c2d83d 26px,#a6c2d83d 27px,transparent 27px,transparent var(--rule-height)); }
.planning, .review { max-width: 920px; margin: 10px auto 14px; }
summary { display: flex; align-items: center; justify-content: space-between; list-style: none; gap: 12px; cursor: pointer; min-height: 52px; padding: 15px 0; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--line); }
summary::-webkit-details-marker { display: none; }
summary > span { color: var(--muted); font-size: 20px; font-weight: 400; line-height: 1; transition: transform .18s; }
details[open] > summary > span { transform: rotate(45deg); }
.planning ol { list-style: none; display: grid; grid-template-columns: repeat(3,1fr); gap: 24px; padding: 0; margin: 16px 0 17px; }
.planning li, .planning p, .review li { color: var(--ink-2); font-size: 13.5px; line-height: 1.75; }
.planning li strong { display: block; font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--green); margin-bottom: 4px; }
.planning p { margin: 0 0 17px; }
#paragraph { display: block; width: 100%; min-height: 340px; padding: 0; margin: 0; resize: none; overflow: hidden; border: 0; border-radius: 0; background: transparent; color: #34312d; font-size: 18px; line-height: var(--rule-height); }
#paragraph::placeholder { color: #8b8274; font-size: 16px; font-style: italic; }
#paragraph:focus-visible { outline: none; }
#paragraph:disabled { opacity: .5; }
.review ul { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px 28px; padding-left: 18px; margin: 16px 0; }
.writing-status { max-width: 920px; margin: 18px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- saved prompts */
.saved-section { padding: 64px 24px 40px; max-width: 968px; margin: auto; }
.saved-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.saved-heading h2 { font-size: 28px; }
.history-filter { display: flex; flex-shrink: 0; gap: 18px; }
.history-filter button { min-height: 44px; border: 0; border-bottom: 2px solid transparent; padding: 8px 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.history-filter button[aria-pressed=true] { border-bottom-color: var(--gold); color: var(--ink); }
.card-stack { margin-top: 27px; }
.card-stack:has(.history-list:empty) { display: none; }
.history-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px 24px; padding: 0; margin: 0; list-style: none; }
.history-row { position: relative; isolation: isolate; display: flex; align-items: stretch; gap: 2px; background: linear-gradient(100deg,#faf7ee,#fffef9 20%,#fffdf7); border: 1px solid #e3dccb; border-radius: 2px; box-shadow: 0 1px 2px #4b403110, 0 7px 18px #4b403108; }
.history-row::before { content: ''; position: absolute; top: 25px; left: 23px; right: 23px; height: 1px; background: #c5a19c66; pointer-events: none; }
.history-row::after { content: ''; position: absolute; z-index: -1; top: 4px; bottom: -4px; left: 3px; right: -3px; background: #fdfbf4; border: 1px solid #e3dccb; border-radius: 2px; transform: rotate(.16deg); pointer-events: none; }
.history-row:nth-child(2n)::after { transform: rotate(-.15deg); }
.history-row.current .history-choices { color: var(--link); }
.history-load { display: flex; flex: 1; flex-direction: column; justify-content: space-between; gap: 14px; min-width: 0; min-height: 145px; padding: 39px 0 22px 23px; background: none; border: 0; text-align: left; }
.history-load:hover .history-choices { text-decoration: underline; text-underline-offset: 4px; }
.history-choices { color: #49463f; font-family: var(--serif); font-size: 17px; line-height: 1.5; font-weight: 500; overflow-wrap: anywhere; }
.history-meta { padding-top: 9px; border-top: 1px solid #b1c2d333; font-size: 10.5px; line-height: 1.7; color: #797165; }
.history-star { align-self: flex-start; min-width: 44px; min-height: 44px; margin: 29px 9px 0 3px; border: 0; padding: 8px; background: none; color: #92846a; font-size: 23px; }
.history-star:hover { color: #9c772d; }
.history-star[aria-pressed=true] { color: #c08a1e; }
.earlier-prompts { margin-top: 25px; }
.earlier-prompts > summary { color: var(--muted); font-size: 12.5px; }
.earlier-prompts .history-list { margin-top: 12px; }
.history-empty { margin: 24px 0; font-size: 14px; color: var(--muted); font-style: italic; }
.history-empty:empty { display: none; }
.memory-note { border-top: 1px solid var(--line); padding-top: 17px; margin-top: 16px; font-size: 11.5px; }

/* ---------------------------------------------------------------- notes shelf */
.notes-section { max-width: 968px; margin: 0 auto; padding: 60px 24px 90px; }
.notes-heading { max-width: 620px; }
.notes-heading h2 { font-size: 44px; }
.notes-heading p:not(.section-kicker) { color: var(--ink-2); font-size: 15.5px; margin: 10px 0 0; }
.shelf { list-style: none; padding: 0; margin: 36px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px; position: relative; }
.note { display: flex; gap: 24px; align-items: flex-start; padding: 22px; background: var(--card) var(--grain); border: 1.5px solid var(--ink); border-radius: 4px; box-shadow: 0 4px 0 rgba(42,36,32,.18); }
.note-cover { flex: none; width: 128px; display: block; transform: rotate(-2deg); transition: transform .35s cubic-bezier(.2,1.4,.4,1); box-shadow: 0 2px 3px rgba(0,0,0,.18), 0 12px 22px rgba(30,24,20,.22); }
.note-cover img { display: block; width: 100%; height: auto; }
.note:hover .note-cover { transform: rotate(0deg) translateY(-4px) scale(1.03); }
.note-subject { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--red); }
.note h3 { font-size: 25px; line-height: 1.15; }
.note h3 a { color: inherit; text-decoration: none; }
.note h3 a:hover { text-decoration: underline wavy var(--gold); text-underline-offset: 6px; text-decoration-thickness: 1.5px; }
.note-desc { margin: 8px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.note-meta { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.note-actions { display: flex; gap: 18px; margin-top: 12px; }
.note-actions a { font-size: 13.5px; font-weight: 650; min-height: 32px; display: inline-flex; align-items: center; }
.note-soon { border-style: dashed; border-color: rgba(42,36,32,.4); background: transparent; box-shadow: none; }
.note-cover-empty { width: 128px; aspect-ratio: 579/819; display: grid; place-items: center; border: 1.5px dashed rgba(42,36,32,.35); color: rgba(42,36,32,.4); transform: rotate(2deg); box-shadow: none; }
.note-cover-empty svg { width: 56%; }
.note-soon h3 { color: var(--muted); }

/* ---------------------------------------------------------------- footer: one quiet line */
.site-footer { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 28px; padding: 16px 24px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.site-footer nav { display: flex; gap: 18px; }
.site-footer a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.site-footer a:hover { color: var(--link); text-decoration: underline wavy var(--gold); }
.site-footer p { margin: 0; }

/* ---------------------------------------------------------------- dialog, toast */
dialog { width: min(1120px,94vw); max-height: 91dvh; overflow-y: auto; padding: 30px; background: var(--paper) var(--grain); border: 1.5px solid var(--ink); border-radius: 8px; color: var(--ink); box-shadow: 0 24px 100px rgba(20,30,28,.35); }
dialog::backdrop { background: rgba(20,30,28,.45); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.dialog-heading h2 { font-size: 30px; }
.icon-button { display: inline-flex; justify-content: center; align-items: center; width: 44px; height: 44px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--card); color: var(--ink); font-size: 25px; line-height: 1; font-weight: 300; }
.icon-button:hover { background: #fff; }
.editor-intro { margin: 19px 0 0; font-size: 14px; line-height: 1.7; color: var(--ink-2); }
.syntax { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.editor-columns { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; margin-top: 22px; }
.editor-columns label { display: block; margin-bottom: 9px; font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--green); }
.editor-columns textarea { width: 100%; height: 300px; resize: vertical; padding: 13px; color: var(--ink-2); background: #fffdf7; border: 1.5px solid var(--line); border-radius: 6px; font-size: 13px; line-height: 1.8; }
.editor-columns textarea:focus { border-color: var(--ink); outline: none; }
.form-error { min-height: 18px; color: #9d3d4a; font-size: 12px; line-height: 1.65; margin: 9px 0 0; }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 20px; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 11px 24px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--green); color: #fbf5e6; font-size: 14px; font-weight: 600; box-shadow: 0 3px 0 var(--ink); }
.primary-button:hover { background: var(--green-2); }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(90vw,600px); padding: 14px 22px; color: #f6eedc; background: var(--green); border: 1.5px solid var(--ink); border-radius: 12px; box-shadow: 0 8px 26px rgba(20,30,28,.3); font-size: 13.5px; line-height: 1.6; }

/* ---------------------------------------------------------------- about page */
.about-banner { position: relative; height: clamp(240px, 34vw, 420px); overflow: hidden; isolation: isolate; margin-top: -64px; }
.about-banner .scene { top: 0; height: 100%; }
.about-article { max-width: 680px; margin: 0 auto; padding: 0 24px 90px; position: relative; }
.about-card { margin-top: -90px; padding: 44px 52px 48px; background: var(--card) var(--grain); border: 1.5px solid var(--ink); border-radius: 3px; box-shadow: inset 0 0 0 6px var(--card), inset 0 0 0 7px rgba(42,36,32,.5), 0 18px 40px rgba(31,40,45,.14); }
.about-card h1 { font-size: clamp(42px, 6vw, 62px); }
.equation { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 16px; margin: 30px 0; padding: 22px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-family: var(--serif); font-size: clamp(26px, 4.4vw, 38px); color: var(--ink); }
.equation .op { color: var(--gold); font-style: normal; }
.equation .piece { position: relative; }
.equation .piece small { position: absolute; left: 50%; top: 100%; translate: -50% 2px; font-family: var(--body); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.equation .result-word { color: var(--green); font-weight: 650; }
.equation .result-word b { color: var(--red); font-weight: 650; }
.prose p { font-size: 17px; line-height: 1.75; color: var(--ink-2); margin: 0 0 18px; }
.prose h2 { font-size: 27px; margin: 38px 0 12px; }
.prose a { color: var(--link); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.prose a:hover { text-decoration: underline wavy var(--gold); }
.prose em { font-family: var(--serif); font-size: 1.06em; }
.aside { display: flex; gap: 18px; align-items: flex-start; margin: 28px 0; padding: 18px 20px; background: var(--paper-2); border-left: 3px solid var(--gold); }
.aside svg { flex: none; width: 52px; height: 52px; }
.aside p { margin: 0; font-size: 15px; }
.signoff { font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--green); margin-top: 30px !important; }

/* 404 */
.lost { max-width: 560px; margin: 12vh auto; padding: 0 24px; text-align: center; }
.lost h1 { font-size: 56px; }
.lost p { color: var(--ink-2); font-size: 17px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .wheels { gap: 18px; }
  .result { font-size: 24px; }
  .writing-heading { flex-wrap: wrap; align-items: flex-start; }
  .prompt-actions { justify-content: flex-start; }
}
@media (max-width: 860px) {
  .shelf { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .masthead { padding: 8px 16px; gap: 10px; }
  .brand svg { width: 32px; height: 32px; } .brand-name { font-size: 21px; }
  .site-nav { gap: 14px; } .nav-link { font-size: 14px; }
  .hero { padding: 18px 16px 0; }
  .cartouche { padding: 20px 22px 22px; }
  .cartouche::before, .cartouche::after { display: none; }
  .intro-text { font-size: 14.5px; }
  .wheels { gap: 10px; margin-top: 22px; }
  .card-top { flex-direction: column; gap: 6px; margin-bottom: 8px; }
  .card-top h2 { font-size: 14px; padding: 4px 10px 5px; } .card-num { display: none; }
  .lock-button { min-height: 32px; padding: 3px 9px; font-size: 11px; }
  .lock-button svg { width: 13px; height: 13px; }
  .result-area { padding: 14px 0 0; min-height: 80px; }
  .result, .result.long-word { font-size: 18px; }
  .meaning { font-size: 11.5px; }
  .single-spin { font-size: 12px; padding: 8px 2px; gap: 4px; }
  .single-spin svg { width: 13px; height: 13px; }
  .ticket { padding: 12px 22px; }
  .ticket-choices { font-size: 17px; }
  .exercise-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-bottom: 24px; }
  .setting-field { width: auto; min-width: 0; }
  .settings-explanation { grid-column: 1/-1; margin: 0; text-align: left; }
  .edit-button { grid-column: 1/-1; justify-self: start; }
  .writing-section { padding: 44px 16px; }
  .writing-heading { display: block; } .writing-heading h2 { font-size: 34px; }
  .export-actions { margin-top: 12px; gap: 22px; }
  .planning ol, .review ul { grid-template-columns: 1fr; gap: 14px; }
  .chosen-prompt { display: grid; gap: 2px; font-size: 12.5px; }
  .notebook-paper { --paper-left: 41px; --paper-right: 21px; padding-top: 24px; padding-bottom: 24px; }
  .notebook-paper::before { left: 24px; }
  .paper-header { min-height: 80px; }
  #paragraph { font-size: 16px; }
  .writing-status { gap: 6px; align-items: flex-start; flex-direction: column; font-size: 11px; }
  .saved-section { padding: 44px 16px 30px; }
  .saved-heading { display: block; } .history-filter { display: inline-flex; margin-top: 14px; }
  .history-list { grid-template-columns: 1fr; gap: 19px; }
  .notes-section { padding: 44px 16px 70px; }
  .notes-heading h2 { font-size: 36px; }
  .note { flex-direction: column; gap: 18px; padding: 18px; }
  .note-cover, .note-cover-empty { width: 112px; }
  dialog { padding: 22px; }
  .editor-columns { grid-template-columns: 1fr; gap: 15px; }
  .editor-columns textarea { height: 175px; font-size: 14px; }
  .dialog-actions { flex-direction: column; align-items: stretch; gap: 16px; }
  .dialog-actions .primary-button { width: 100%; }
  .about-card { margin-top: -60px; padding: 30px 22px 34px; }
  .prose p { font-size: 16px; }
}
@media (max-width: 560px) {
  .wheel-label, .bezel-text { display: none; }
  .wheels { gap: 8px; }
  .result, .result.long-word { font-size: 16px; }
  .pointer { width: 14%; left: 43%; top: -7%; }
}
@media (max-width: 380px) {
  .brand-name { font-size: 19px; } .site-nav { gap: 10px; } .nav-icon { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .spin-button, .primary-button { border: 1px solid ButtonText; }
  .scene { display: none; }
}
@media print {
  @page { size: A4; margin: 18mm; }
  body { background: #fff; color: #000; font-size: 12pt; overflow: visible; }
  .masthead, .hero, .site-footer, .notes-section, .export-actions, .export-status, .prompt-actions, .saved-section, .planning, .review, .writing-status, dialog, .toast, .skip-link, .section-kicker { display: none !important; }
  main { padding: 0; max-width: none; }
  .writing-section { padding: 0; margin: 0; }
  .writing-section::before { display: none; }
  .writing-heading { display: block; max-width: none; }
  .writing-heading > div:first-child { max-width: none; }
  .writing-heading h2 { font-size: 21pt; color: #000; }
  .writing-heading p { font-size: 11pt; color: #333; }
  .notebook-paper { padding: 0; margin: 18px 0; background: none; box-shadow: none; border: 0; }
  .notebook-paper::before, .notebook-paper::after { display: none; }
  .paper-header { min-height: 0; }
  .chosen-prompt { display: block !important; font-size: 11pt; }
  .chosen-prompt span { display: block; }
  .lesson-focus { font-size: 10pt; color: #555; }
  .paper-writing { display: none; }
  .print-writing { margin-top: 25px; white-space: pre-wrap; font-size: 12pt; line-height: 2; }
  .print-lines { margin-top: 25px; height: 420px; background: repeating-linear-gradient(to bottom,white 0,white 35px,#bbb 35px,#bbb 36px); print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
.scene.paused *, .scene.paused { animation-play-state: paused !important; }

/* Wide screens: a low, wide title card so the wheels and results sit higher */
@media (min-width: 1000px) {
  .hero { padding-top: 18px; }
  .cartouche { max-width: 900px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; text-align: left; padding: 18px 44px 18px 40px; }
  .cartouche h1 { grid-column: 1; grid-row: 1 / span 2; padding-right: 34px; }
  .cartouche .intro-text { grid-column: 2; grid-row: 1; margin: 0; padding-left: 32px; border-left: 1px solid var(--line); max-width: none; font-size: 15px; line-height: 1.55; }
  .cartouche .spin-controls { grid-column: 2; grid-row: 2; margin: 0; padding: 12px 0 0 32px; border-left: 1px solid var(--line); }
  .cartouche::before, .cartouche::after { display: none; }
  .wheels { margin-top: 22px; }
  .wheel-wrap { max-width: clamp(270px, calc(100svh - 380px), 340px); }
  .card-top { max-width: clamp(270px, calc(100svh - 380px), 340px); }
}

.prose .eyebrow { font-size: 11.5px; line-height: 1.4; color: var(--red); margin: 0 0 12px; }
.prose .equation { gap: 26px 12px; font-size: clamp(22px, 3.1vw, 30px); line-height: 1.2; color: var(--ink); margin: 28px 0 34px; padding: 22px 8px 34px; }
@media (max-width: 760px) { .site-nav .nav-spin { display: none; } }
.crane-hook { animation: trolley 26s ease-in-out infinite alternate; }
@keyframes trolley { from { transform: translateX(-220px); } to { transform: translateX(120px); } }

/* ---------------------------------------------------------------- side tour: vignettes in the margins of wide screens */
.lower { position: relative; }
.side-tour { display: none; }
@media (min-width: 1360px) {
  .side-tour { position: absolute; z-index: 1; top: 40px; bottom: 80px; width: calc((100% - 1000px) / 2); display: flex; flex-direction: column; justify-content: space-around; align-items: center; pointer-events: none; }
  .side-tour.left { left: 0; } .side-tour.right { right: 0; }
  .side-tour figure { margin: 0; width: min(280px, 92%); text-align: center; }
  .side-tour img { display: block; width: 100%; height: auto; }
  .side-tour figcaption { display: inline-block; margin-top: 2px; padding: 3px 11px 4px; font-family: var(--serif); font-size: 14.5px; font-weight: 600; color: var(--green); background: var(--card); border: 1.2px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 rgba(42,36,32,.2); }
  .side-tour figcaption::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #d0533f; border: 1px solid var(--ink); vertical-align: 1px; }
}
.note h3 .by { font-weight: 400; font-style: italic; color: var(--ink-2); }
