/* The Study. One hue for the room, one ink per part of speech. */
@font-face { font-family: Libron; src: url(/fonts/Libron-Regular.woff2) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Libron; src: url(/fonts/Libron-Italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Libron; src: url(/fonts/Libron-Bold.woff2) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: Libron; src: url(/fonts/Libron-BoldItalic.woff2) format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }

:root {
  --h: 72;
  --paper: oklch(96.5% 0.014 var(--h));
  --card: oklch(99% 0.008 var(--h));
  --ink: oklch(22% 0.02 var(--h));
  --ink-soft: oklch(45% 0.025 var(--h));
  --ink-faint: oklch(66% 0.02 var(--h));
  --hair: oklch(88% 0.02 var(--h));
  --accent: oklch(78% 0.12 var(--h));
  --accent-deep: oklch(52% 0.13 var(--h));
  --shadow: 0 10px 30px oklch(30% 0.05 var(--h) / 0.10);
  --display: 'Fraunces', Georgia, serif;
  --prose: 'Libron', Georgia, serif;
  --ui: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  /* parts of speech: L and C fixed, hue per part */
  --pos-l: 86%; --pos-c: 0.09;
  --noun: oklch(var(--pos-l) var(--pos-c) 250);
  --pronoun: oklch(var(--pos-l) var(--pos-c) 305);
  --verb: oklch(var(--pos-l) 0.11 22);
  --adjective: oklch(var(--pos-l) var(--pos-c) 180);
  --adverb: oklch(var(--pos-l) 0.11 72);
  --preposition: oklch(var(--pos-l) var(--pos-c) 335);
  --conjunction: oklch(var(--pos-l) var(--pos-c) 210);
  --interjection: oklch(var(--pos-l) 0.11 50);
  --article: oklch(90% 0.01 var(--h));
  --other: oklch(90% 0.01 var(--h));
  --dot: oklch(58% 0.16 22);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --dark: 1; } }
:root[data-theme="dark"] { --dark: 1; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: oklch(16% 0.012 var(--h)); --card: oklch(20% 0.014 var(--h));
    --ink: oklch(92% 0.015 var(--h)); --ink-soft: oklch(72% 0.02 var(--h)); --ink-faint: oklch(52% 0.02 var(--h));
    --hair: oklch(28% 0.02 var(--h)); --accent: oklch(70% 0.12 var(--h)); --accent-deep: oklch(80% 0.11 var(--h));
    --shadow: 0 10px 30px oklch(0% 0 0 / 0.45);
    --pos-l: 36%; --pos-c: 0.09; --article: oklch(26% 0.01 var(--h)); --other: oklch(26% 0.01 var(--h));
    --dot: oklch(72% 0.16 22);
  }
}
:root[data-theme="dark"] {
  --paper: oklch(16% 0.012 var(--h)); --card: oklch(20% 0.014 var(--h));
  --ink: oklch(92% 0.015 var(--h)); --ink-soft: oklch(72% 0.02 var(--h)); --ink-faint: oklch(52% 0.02 var(--h));
  --hair: oklch(28% 0.02 var(--h)); --accent: oklch(70% 0.12 var(--h)); --accent-deep: oklch(80% 0.11 var(--h));
  --shadow: 0 10px 30px oklch(0% 0 0 / 0.45);
  --pos-l: 36%; --pos-c: 0.09; --article: oklch(26% 0.01 var(--h)); --other: oklch(26% 0.01 var(--h));
  --dot: oklch(72% 0.16 22);
}
:root[data-face="system"] { --prose: var(--ui); }
:root[data-face="fraunces"] { --prose: var(--display); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--prose); font-size: 18px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-optical-sizing: auto; hanging-punctuation: first last; }
#root { min-height: 100vh; }
a { color: var(--accent-deep); text-decoration: none; }
p { text-wrap: pretty; margin: 0 0 1em; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
::selection { background: var(--accent); color: var(--ink); }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in oklch, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 14px; }
@media (pointer: coarse) { .top { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--paper); } }
.wordmark { font-family: var(--display); font-size: 21px; font-variation-settings: 'SOFT' 60; letter-spacing: 0.01em; color: var(--ink); white-space: nowrap; }
.wordmark i { font-style: italic; color: var(--accent-deep); }
.nav { display: flex; gap: 2px; margin-left: auto; font-family: var(--ui); font-size: 14px; }
@media (max-width: 480px) {
  .top { flex-wrap: wrap; row-gap: 4px; }
  .top .icon-btn { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; margin-left: -8px; }
}
.nav a { color: var(--ink-soft); padding: 8px 10px; border-radius: 999px; min-height: 36px; display: inline-flex; align-items: center; }
.nav a.on { color: var(--ink); background: var(--card); box-shadow: inset 0 0 0 1px var(--hair); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-soft); transition: transform .15s; }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 20px; height: 20px; }
main { max-width: 680px; margin: 0 auto; padding: 18px 20px calc(48px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) { main { padding: 36px 24px 80px; } }
.view { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }
.rise > * { animation: rise .4s cubic-bezier(.22,1,.36,1) backwards; }
.rise > :nth-child(2) { animation-delay: .05s } .rise > :nth-child(3) { animation-delay: .1s }
.rise > :nth-child(4) { animation-delay: .15s } .rise > :nth-child(5) { animation-delay: .2s } .rise > :nth-child(n+6) { animation-delay: .24s }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.eyebrow { font-family: var(--ui); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 10px; }
.card { background: var(--card); border-radius: 22px; padding: 22px; box-shadow: var(--shadow), 0 0 0 1px var(--hair); }
.card + .card { margin-top: 16px; }
.hair { border: 0; border-top: 1px solid var(--hair); margin: 28px 0; }
.muted { color: var(--ink-soft); }
.small { font-family: var(--ui); font-size: 14px; color: var(--ink-soft); }

/* ---------- login ---------- */
.door { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.door form { width: min(360px, 100%); display: grid; gap: 12px; }
.door h1 { font-size: 40px; text-align: center; margin-bottom: 4px; font-variation-settings: 'SOFT' 80; }
.door .sub { text-align: center; color: var(--ink-soft); margin-bottom: 18px; font-style: italic; }
.field { background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 14px 16px; width: 100%; color: var(--ink); font-family: var(--ui); font-size: 17px; }
.field:focus { outline: none; border-color: var(--accent-deep); }
.btn { font-family: var(--ui); font-size: 16px; font-weight: 500; min-height: 48px; padding: 0 22px; border-radius: 999px;
  background: var(--ink); color: var(--paper); display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s; }
.btn:active { transform: scale(.96); }
.btn.quiet { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--hair); }
.btn.quiet.on { background: var(--accent); box-shadow: none; }
.err { color: oklch(52% 0.16 22); font-family: var(--ui); font-size: 14px; text-align: center; min-height: 1.4em; }

/* ---------- the sentence stage ---------- */
.stage { position: relative; padding: 10px 0 26px; }
.sentence { font-family: var(--prose); font-size: clamp(24px, 5.4vw, 34px); line-height: 1.5; letter-spacing: -0.005em; margin: 0; position: relative; }
.sentence.verse { white-space: pre-wrap; }
.w { display: inline; border-radius: 6px; padding: 0 .08em; margin: 0 -.08em; transition: background-color .35s cubic-bezier(.22,1,.36,1), color .35s; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.stage.reading > .sentence .w { color: var(--ink-faint); }
.stage.reading > .sentence .w.read, .stage.reading > .sentence .w.now { color: var(--ink); }
.stage.reading > .sentence .w.now { color: var(--accent-deep); }
.stage[data-pos~="noun"] .w[data-pos="noun"] { background: var(--noun); }
.stage[data-pos~="pronoun"] .w[data-pos="pronoun"] { background: var(--pronoun); }
.stage[data-pos~="verb"] .w[data-pos="verb"] { background: var(--verb); }
.stage[data-pos~="adjective"] .w[data-pos="adjective"] { background: var(--adjective); }
.stage[data-pos~="adverb"] .w[data-pos="adverb"] { background: var(--adverb); }
.stage[data-pos~="preposition"] .w[data-pos="preposition"] { background: var(--preposition); }
.stage[data-pos~="conjunction"] .w[data-pos="conjunction"] { background: var(--conjunction); }
.stage[data-pos~="interjection"] .w[data-pos="interjection"] { background: var(--interjection); }
.stage[data-pos~="article"] .w[data-pos="article"] { background: var(--article); }
.stage[data-pos~="verb"] .w[data-pos="verb"].heart { animation: heart .9s cubic-bezier(.34,1.56,.64,1) 1; display: inline-block; }
@keyframes heart { 0% { transform: scale(1); } 18% { transform: scale(1.12); } 36% { transform: scale(1); } 54% { transform: scale(1.08); } 100% { transform: scale(1); } }
.dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--dot); left: 0; top: 0; opacity: 0; pointer-events: none; will-change: transform; box-shadow: 0 2px 8px oklch(40% 0.15 22 / .35); }
.stage.reading .dot { opacity: 1; }
.stage.done .dot { opacity: 0; transition: opacity .5s; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip { font-family: var(--ui); font-size: 13px; min-height: 34px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--hair); color: var(--ink-soft); transition: transform .15s, background-color .2s; }
.chip:active { transform: scale(.94); }
.chip.on { color: var(--ink); box-shadow: none; }
.chip .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.chip.on { background: var(--c); }
.chip.on .sw { background: var(--ink); opacity: .55; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }
.controls .btn { min-height: 42px; padding: 0 18px; font-size: 15px; }

.src { font-family: var(--ui); font-size: 13px; color: var(--ink-faint); margin-top: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.star { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; position: relative; color: var(--ink-faint); margin-left: auto; transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.star svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.star:active { transform: scale(.82); }
.star.on { color: var(--accent-deep); }
.star.on svg { fill: var(--accent); }
.star.on.just { animation: pop .3s cubic-bezier(.34,1.8,.64,1); }
.star.on.just::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; border: 2px solid var(--accent-deep); animation: bloom .55s ease-out forwards; }
@keyframes pop { 0% { transform: scale(.6); } }
@keyframes bloom { to { transform: scale(2); opacity: 0; } }

.reading-note { margin-top: 22px; }
.reading-note h3 { font-size: 15px; font-family: var(--ui); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 8px; }
.companion { border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; margin: 18px 0; }
.companion .q { font-size: 20px; line-height: 1.5; font-style: italic; }
.companion .who { font-family: var(--ui); font-size: 13px; color: var(--ink-faint); margin-top: 6px; }

/* grow */
.grow-stage { margin-top: 10px; }
.grow-stage .sentence .w.new { animation: rise .45s cubic-bezier(.22,1,.36,1) backwards; display: inline-block; }
.grow-steps { display: flex; gap: 6px; margin-top: 14px; }
.grow-steps i { width: 8px; height: 8px; border-radius: 50%; background: var(--hair); transition: background-color .3s, transform .3s; }
.grow-steps i.on { background: var(--accent-deep); transform: scale(1.25); }
.grow-note { margin-top: 12px; color: var(--ink-soft); font-size: 16px; }

/* ---------- lists ---------- */
.list { display: grid; gap: 12px; }
.row { background: var(--card); border-radius: 18px; padding: 16px 18px; box-shadow: 0 0 0 1px var(--hair); display: block; color: inherit; transition: transform .2s ease, box-shadow .2s ease; }
@media (hover: hover) { .row:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 0 0 1px var(--hair); } }
.row:active { transform: scale(.985); }
.row .t { font-size: 19px; line-height: 1.4; }
.row .m { font-family: var(--ui); font-size: 13px; color: var(--ink-faint); margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.row .m .n { font-family: var(--display); font-size: 15px; color: var(--accent-deep); }
.row.read .m::after { content: 'read'; color: var(--accent-deep); }
.part-head { font-family: var(--display); font-size: 15px; font-style: italic; color: var(--ink-faint); margin: 26px 0 10px; }
.part-head:first-child { margin-top: 0; }

/* ---------- chapter prose ---------- */
.chapter h1 { font-size: clamp(34px, 7vw, 48px); line-height: 1.1; font-variation-settings: 'SOFT' 60; margin: 6px 0 22px; }
.chapter h2 { font-size: 24px; margin: 36px 0 12px; }
.chapter p { font-size: 19px; }
.chapter blockquote { margin: 18px 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--accent); font-style: italic; font-size: 19px; }
.chapter blockquote cite { display: block; font-style: normal; font-family: var(--ui); font-size: 13px; color: var(--ink-faint); margin-top: 6px; }
.chapter ul { padding-left: 1.2em; } .chapter li { margin: .3em 0; }
.chapter .sins { background: var(--card); border-radius: 18px; padding: 16px 20px; box-shadow: 0 0 0 1px var(--hair); margin: 18px 0; font-size: 17px; }
.chapter .sins h3 { font-family: var(--ui); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 8px; }
.inline-specimen { margin: 26px 0; }
.inline-specimen .eyebrow { margin-bottom: 4px; }
.inline-specimen .sentence { font-size: clamp(21px, 4.6vw, 27px); }
.chapter-foot { margin-top: 40px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- today ---------- */
.today-date { font-family: var(--display); font-style: italic; color: var(--ink-soft); margin-bottom: 6px; }
.shelf-link { display: block; margin-top: 10px; }
.empty { text-align: center; color: var(--ink-soft); padding: 48px 12px; font-style: italic; }

/* ---------- settings sheet ---------- */
.sheet-scrim { position: fixed; inset: 0; background: oklch(10% 0.01 var(--h) / .35); z-index: 20; animation: fadeOnly .2s ease; }
@keyframes fadeOnly { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--card); border-radius: 24px 24px 0 0; padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow); animation: up .32s cubic-bezier(.22,1,.36,1); max-width: 560px; margin: 0 auto; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet h2 { font-size: 22px; margin-bottom: 14px; }
.seg { display: flex; gap: 6px; background: var(--paper); padding: 4px; border-radius: 999px; margin: 6px 0 14px; }
.seg button { flex: 1; min-height: 38px; border-radius: 999px; font-family: var(--ui); font-size: 14px; color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--hair); }
.sheet .label { font-family: var(--ui); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }

.notice { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--card); color: var(--ink);
  border-radius: 18px; padding: 12px 18px; box-shadow: var(--shadow), 0 0 0 1px var(--hair); font-family: var(--ui); font-size: 14px; z-index: 30; animation: up .3s cubic-bezier(.22,1,.36,1); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
  .dot { display: none; }
}

/* ---------- fine-tuning pass, 2026-10-09 ---------- */
/* text size */
:root[data-size="small"] body { font-size: 16px; }
:root[data-size="large"] body { font-size: 20px; }
:root[data-size="large"] .sentence { font-size: clamp(27px, 6vw, 38px); }
:root[data-size="large"] .chapter p { font-size: 21px; }

/* the parts colour in, in reading order */
.w { transition-delay: calc(var(--i, 0) * 26ms); }
.stage.deal > .sentence .w { animation: rise .5s cubic-bezier(.22,1,.36,1) backwards; animation-delay: calc(var(--i, 0) * 55ms + .1s); display: inline-block; }

/* tap a word: it says what it is */
.pos-label { position: absolute; transform: translate(-50%, -115%); font-family: var(--ui); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; background: var(--ink); color: var(--paper); pointer-events: none; white-space: nowrap; z-index: 2;
  animation: labelIn .22s cubic-bezier(.34,1.56,.64,1); transition: opacity .3s, transform .3s; }
.pos-label::after { content: ''; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 8px; background: var(--ink); transform: translateX(-50%) rotate(45deg); }
.pos-label.gone { opacity: 0; transform: translate(-50%, -135%); }
@keyframes labelIn { from { opacity: 0; transform: translate(-50%, -95%); } }
.w { cursor: default; }

/* the rhythm left behind after a reading */
.trace { display: flex; gap: 3px; height: 10px; margin: 10px 0 0; align-items: flex-end; opacity: 0; transition: opacity .5s; cursor: pointer; }
.trace.show { opacity: 1; }
.trace i { display: block; height: 4px; border-radius: 2px; background: var(--accent); min-width: 2px; animation: traceUp .5s cubic-bezier(.22,1,.36,1) backwards; }
.trace i:nth-child(n) { animation-delay: calc(var(--d, 300) * 0.0003s); }
@keyframes traceUp { from { transform: scaleY(0); } }
.stage.reading .trace { opacity: 0; }

/* new words rise in one after another in a grown sentence */
.grow-stage .sentence .w.new { animation-delay: calc(var(--n, 0) * 60ms + .08s); }
.grow-steps i { cursor: pointer; width: 10px; height: 10px; }

/* the read mark stamps down */
.btn.stamp.just { animation: stamp .32s cubic-bezier(.22,1,.36,1); }
@keyframes stamp { 0% { transform: scale(1.18); opacity: .4; } 60% { transform: scale(.97); } 100% { transform: scale(1); } }

/* walking the shelf from a sentence */
.walk { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; }
.walk-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 10px; border-radius: 999px; color: var(--ink-soft); font-family: var(--ui); font-size: 14px; transition: transform .15s; }
.walk-btn:active { transform: scale(.94); }
.walk-btn svg { width: 18px; height: 18px; }

/* keys in the room */
.keys p { font-family: var(--ui); font-size: 13px; color: var(--ink-soft); line-height: 2; margin: 4px 0 12px; }
kbd { font-family: var(--ui); font-size: 12px; background: var(--paper); border: 1px solid var(--hair); border-radius: 6px; padding: 1px 6px; margin-right: 3px; color: var(--ink); }

/* the thumb: every control at least 44px on touch */
@media (pointer: coarse) {
  .chip { min-height: 40px; padding: 0 14px; font-size: 14px; }
  .nav a { min-height: 44px; }
  .star, .icon-btn { width: 44px; height: 44px; }
  .controls .btn { min-height: 46px; }
  .grow-steps { gap: 10px; } .grow-steps i { width: 12px; height: 12px; }
  .w { padding: .1em .08em; }
}
