/* Design tokens — memorial editorial, reading first */
:root {
  --paper: #f6f2ea;
  --paper-2: #efe9dd;
  --card: #fbf9f4;
  --ink: #1b1915;
  --ink-2: #4a453d;
  --muted: #7a7368;
  --rule: #ddd5c6;
  --accent: #8a3a1e;      /* oxblood: used sparingly for actions */
  --accent-ink: #fff8f0;
  --focus: #b5552f;

  --serif: "Newsreader", "Noto Serif SC", Georgia, serif;
  --sans: "Instrument Sans", "Noto Sans SC", system-ui, sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px;
  --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px; --s20: 80px; --s24: 96px;

  --t-xs: 0.75rem; --t-sm: 0.875rem; --t-base: 1.0625rem; --t-lg: 1.25rem;
  --t-xl: 1.5rem; --t-2xl: 2rem; --t-3xl: 2.75rem; --t-4xl: 3.5rem;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(27,25,21,.05), 0 8px 24px -12px rgba(27,25,21,.18);
  --measure: 40rem;
  --wide: 72rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-width: thin; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: var(--t-base); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
img { max-width: 100%; display: block; }

.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 var(--s5); }
.narrow { max-width: var(--measure); margin: 0 auto; padding: 0 var(--s5); }

/* Header */
.site-head { border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: var(--s4); }
.brand { font-family: var(--serif); font-size: var(--t-lg); text-decoration: none; letter-spacing: -0.01em; }
.brand small { font-family: var(--sans); font-size: var(--t-xs); color: var(--muted); margin-left: var(--s2); letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; gap: var(--s5); align-items: center; font-size: var(--t-sm); }
.nav a { text-decoration: none; color: var(--ink-2); }
.nav a:hover { color: var(--ink); }
.nav .hide-sm { display: none; }
.lang { border: 1px solid var(--rule); border-radius: 999px; padding: 2px var(--s3); }
@media (min-width: 768px) { .nav .hide-sm { display: inline; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: var(--s2); font: 500 var(--t-sm)/1 var(--sans); padding: 14px 22px; border-radius: 999px; border: 1px solid transparent; text-decoration: none; cursor: pointer; transition: transform .15s ease, background .15s ease, border-color .15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--rule); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-small { padding: 8px 14px; font-size: var(--t-xs); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Hero */
.hero { padding: var(--s16) 0 var(--s12); }
.eyebrow { font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 var(--s5); }
.hero h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.5rem, 7vw, 5rem); line-height: 1.02; letter-spacing: -0.025em; margin: 0 0 var(--s6); max-width: 14ch; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p.lede { font-size: var(--t-lg); color: var(--ink-2); max-width: 34rem; margin: 0 0 var(--s8); }
.hero .actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
.hero .proof { margin-top: var(--s8); font-size: var(--t-sm); color: var(--muted); display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.hero .proof span::before { content: "✓"; color: var(--accent); margin-right: 6px; }

/* Section */
.section { padding: var(--s16) 0; border-top: 1px solid var(--rule); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); margin-bottom: var(--s8); }
.section h2 { font-family: var(--serif); font-weight: 400; font-size: var(--t-2xl); letter-spacing: -0.015em; margin: 0; }
.section .sub { color: var(--muted); font-size: var(--t-sm); margin: var(--s2) 0 0; }

/* Topic picker */
.groups { display: grid; gap: var(--s8); }
@media (min-width: 768px) { .groups { grid-template-columns: repeat(2, 1fr); gap: var(--s10) var(--s12); } }
.group h3 { font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 0 0 var(--s3); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { font-size: var(--t-sm); padding: 9px 15px; border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; background: var(--card); transition: border-color .15s, transform .15s; }
.chip:hover { border-color: var(--ink); transform: translateY(-1px); }
.chip.is-live { border-color: var(--ink); }
.chip.is-live::after { content: " →"; color: var(--accent); }

/* Lesson card */
.lesson { display: grid; gap: var(--s8); background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s8); box-shadow: var(--shadow); }
@media (min-width: 900px) { .lesson { grid-template-columns: 1.3fr 1fr; padding: var(--s12); } }
.quote { font-family: var(--serif); font-size: clamp(1.5rem, 3.2vw, 2.1rem); line-height: 1.25; letter-spacing: -0.01em; margin: 0; }
.quote::before { content: "\201C"; color: var(--accent); }
.quote::after { content: "\201D"; color: var(--accent); }
.cite { margin-top: var(--s4); font-size: var(--t-sm); color: var(--muted); }
.cite a { color: var(--ink-2); }
.lesson .plain h4, .steps h3 { font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 0 0 var(--s2); }
.lesson .plain p { margin: 0 0 var(--s5); color: var(--ink-2); }

/* Steps */
.steps { display: grid; gap: var(--s6); counter-reset: step; }
@media (min-width: 768px) { .steps { grid-template-columns: repeat(3, 1fr); gap: var(--s10); } }
.steps li { list-style: none; counter-increment: step; }
.steps li::before { content: counter(step, decimal-leading-zero); font-family: var(--serif); font-size: var(--t-3xl); color: var(--rule); display: block; line-height: 1; margin-bottom: var(--s3); }
.steps p { margin: 0; color: var(--ink-2); }
.steps ol { padding: 0; margin: 0; display: contents; }

/* Footer */
.site-foot { border-top: 1px solid var(--rule); padding: var(--s10) 0 var(--s16); font-size: var(--t-sm); color: var(--muted); }
.site-foot .wrap { display: grid; gap: var(--s4); }
.memorial { font-family: var(--serif); font-size: var(--t-lg); color: var(--ink); }

/* ---------- Topic page ---------- */
.crumbs { font-size: var(--t-sm); color: var(--muted); padding-top: var(--s10); }
.crumbs a { color: var(--muted); }
.topic-head { padding: var(--s6) 0 var(--s8); }
.topic-head h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.25rem, 5.5vw, 3.5rem); line-height: 1.05; letter-spacing: -0.02em; margin: 0 0 var(--s6); }
.answer { border-left: 3px solid var(--accent); padding: var(--s2) 0 var(--s2) var(--s5); font-family: var(--serif); font-size: var(--t-xl); line-height: 1.35; margin: 0; }
.answer-label { font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 var(--s2); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s4) 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); position: sticky; top: 60px; background: var(--paper); z-index: 10; }
.player { display: flex; align-items: center; gap: var(--s3); flex: 1; min-width: 220px; }
.play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); cursor: pointer; display: grid; place-items: center; flex: none; }
.play:hover { background: var(--accent); }
.bar { flex: 1; height: 3px; background: var(--rule); border-radius: 2px; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 2px; transition: width .3s linear; }
.player small { color: var(--muted); font-size: var(--t-xs); white-space: nowrap; }
.depth { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; background: var(--card); }
.depth button { border: 0; background: transparent; font: 500 var(--t-xs) var(--sans); padding: 7px 12px; border-radius: 999px; cursor: pointer; color: var(--ink-2); }
.depth button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.block { padding: var(--s12) 0 0; }
.block > h2 { font-family: var(--serif); font-weight: 400; font-size: var(--t-2xl); margin: 0 0 var(--s2); letter-spacing: -0.015em; }
.block > .sub { color: var(--muted); font-size: var(--t-sm); margin: 0 0 var(--s6); }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--rule); }
.moment { position: relative; padding: 0 0 var(--s10) var(--s8); }
.moment::before { content: ""; position: absolute; left: -5px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 2px solid var(--accent); }
.moment .year { font-family: var(--serif); font-size: var(--t-xl); color: var(--accent); line-height: 1; }
.moment .src { font-size: var(--t-xs); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-left: var(--s2); }
.moment blockquote { margin: var(--s3) 0 var(--s3); font-family: var(--serif); font-size: var(--t-xl); line-height: 1.4; }
.moment .why { color: var(--ink-2); margin: 0 0 var(--s4); font-size: var(--t-base); }
.moment .row { display: flex; flex-wrap: wrap; gap: var(--s2); }

.video { aspect-ratio: 16/9; background: var(--ink); border-radius: var(--radius); display: grid; place-items: center; color: var(--paper); text-align: center; padding: var(--s6); margin: var(--s3) 0 var(--s4); }
.video p { margin: 0; opacity: .75; font-size: var(--t-sm); max-width: 28rem; }

.explain p { margin: 0 0 var(--s4); font-size: var(--t-lg); line-height: 1.65; }
.explain [data-depth] { display: none; }
.explain[data-show="simple"] [data-depth="simple"],
.explain[data-show="standard"] [data-depth="standard"],
.explain[data-show="deep"] [data-depth="deep"] { display: block; }

.use { background: var(--ink); color: var(--paper); border-radius: var(--radius); padding: var(--s8); }
.use h2 { color: var(--paper); }
.use .sub { color: #b9b1a3; }
.use ol { margin: 0; padding-left: var(--s5); display: grid; gap: var(--s4); }
.use li { font-size: var(--t-lg); }
.use label { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer; }
.use input { margin-top: 7px; accent-color: #e08a5f; width: 18px; height: 18px; flex: none; }
.use .done { margin-top: var(--s6); font-family: var(--serif); font-size: var(--t-lg); color: #f2c9a8; min-height: 1.6em; }

.related { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* Card modal */
dialog { border: 0; padding: 0; background: transparent; max-width: min(92vw, 440px); }
dialog::backdrop { background: rgba(27,25,21,.6); backdrop-filter: blur(3px); }
.card-sheet { background: var(--card); border-radius: var(--radius); padding: var(--s5); display: grid; gap: var(--s4); }
.card-sheet canvas { width: 100%; height: auto; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.card-sheet .row { display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: wrap; }
.themes { display: flex; gap: var(--s2); }
.themes button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--rule); cursor: pointer; }
.themes button[aria-pressed="true"] { border-color: var(--ink); }

.draft-note { background: #fff3cd; color: #5c4400; font-size: var(--t-xs); padding: 6px var(--s5); text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===================== App shell with left sidebar ===================== */
:root { --side-w: 264px; --top-h: 56px; }
.shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 0 var(--s4); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--rule); background: var(--card); border-radius: 10px; cursor: pointer; color: var(--ink); }
.icon-btn:hover { border-color: var(--ink); }

.side { position: fixed; inset: 0 auto 0 0; width: min(86vw, var(--side-w)); background: var(--paper-2); border-right: 1px solid var(--rule); z-index: 50; display: flex; flex-direction: column; transform: translateX(-102%); transition: transform .22s ease; }
.side.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.25); }
.scrim { position: fixed; inset: 0; background: rgba(27,25,21,.45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.side-top { padding: var(--s5) var(--s5) var(--s3); }
.side-top .brand { display: block; font-size: 1.35rem; line-height: 1.1; }
.side-top .tag { display: block; font-size: var(--t-xs); color: var(--muted); margin-top: 4px; }
.search { margin: var(--s3) var(--s4) var(--s2); position: relative; }
.search input { width: 100%; font: var(--t-sm) var(--sans); padding: 10px 12px 10px 34px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); color: var(--ink); }
.search input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.side-scroll { flex: 1; overflow-y: auto; padding: var(--s2) var(--s3) var(--s6); scrollbar-width: none; }
.side-scroll::-webkit-scrollbar { display: none; }
.side-label { font-size: 0.6875rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: var(--s5) var(--s3) var(--s2); }
.side-link { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 7px var(--s3); border-radius: 8px; text-decoration: none; font-size: var(--t-sm); color: var(--ink-2); }
.side-link:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.side-link[aria-current="page"] { background: var(--ink); color: var(--paper); }
.side-link .soon { font-size: 0.625rem; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--rule); border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.side-link.is-disabled { color: var(--muted); cursor: default; }
.side-link.is-disabled:hover { background: transparent; }
details.side-group > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 7px var(--s3); border-radius: 8px; font-size: var(--t-sm); font-weight: 500; color: var(--ink); }
details.side-group > summary::-webkit-details-marker { display: none; }
details.side-group > summary::after { content: "+"; color: var(--muted); }
details.side-group[open] > summary::after { content: "–"; }
details.side-group > summary:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
details.side-group .side-link { padding-left: var(--s6); }
.side-foot { border-top: 1px solid var(--rule); padding: var(--s3) var(--s4); display: flex; justify-content: space-between; align-items: center; font-size: var(--t-sm); }
.side-foot a { color: var(--ink-2); text-decoration: none; }
.no-results { font-size: var(--t-sm); color: var(--muted); padding: var(--s2) var(--s3); display: none; }

.main { min-width: 0; }
.main .wrap { max-width: 60rem; }
.toolbar { top: var(--top-h); }

@media (min-width: 1024px) {
  .topbar { display: none; }
  .side { transform: none; width: var(--side-w); box-shadow: none !important; }
  .scrim { display: none; }
  .main { margin-left: var(--side-w); }
  .toolbar { top: 0; }
  .hero { padding-top: var(--s20); }
}
body.lock { overflow: hidden; }

/* Topic index */
.topic-grid { display: grid; gap: var(--s3); }
@media (min-width: 640px) { .topic-grid { grid-template-columns: repeat(2, 1fr); } }
.topic-card { display: block; text-decoration: none; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s5); transition: border-color .15s, transform .15s; }
.topic-card:hover { border-color: var(--ink); transform: translateY(-1px); }
.topic-card h3 { font-family: var(--serif); font-weight: 400; font-size: var(--t-xl); margin: 0 0 var(--s2); }
.topic-card p { margin: 0; color: var(--ink-2); font-size: var(--t-sm); }
.topic-card .n { font-size: var(--t-xs); color: var(--muted); margin-top: var(--s3); }
.prose { padding-bottom: var(--s16); }
.prose h1 { font-family: var(--serif); font-weight: 400; font-size: var(--t-3xl); margin: var(--s10) 0 var(--s6); }
.prose h2 { font-family: var(--serif); font-weight: 400; font-size: var(--t-xl); margin: var(--s8) 0 var(--s3); }
.prose p, .prose li { color: var(--ink-2); }
.badge { font-size: 0.625rem; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--rule); border-radius: 999px; padding: 1px 7px; color: var(--muted); margin-left: var(--s2); vertical-align: middle; }
