:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #1c1d21;
  --muted: #5f6270;
  --line: #e2ded4;
  --accent: #1f4fd8;
  --accent-soft: #e6ecfd;
  --highlight: #fff1b8;
  --good: #1d7a46;
  --good-soft: #e3f4ea;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --world: #1f6fd8;
  --football: #1d8a4e;
  --basketball: #d4651a;
  --tech: #7b3fd6;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 6px 24px rgba(20, 20, 30, .06);
  --radius: 16px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Fraunces", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121317;
    --surface: #1b1d23;
    --surface-2: #23262e;
    --text: #ecebe7;
    --muted: #a3a6b1;
    --line: #2f323b;
    --accent: #7c9cff;
    --accent-soft: #23305a;
    --highlight: #4a3f12;
    --good: #5fd08f;
    --good-soft: #17352a;
    --bad: #ff8a80;
    --bad-soft: #3d1d1b;
    --world: #6ea6ff;
    --football: #5fd08f;
    --basketball: #ffa45c;
    --tech: #b58cff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 90px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  padding-bottom: 96px;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 1em; height: 1em; fill: currentColor; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

/* Masthead */
.masthead {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.masthead-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-family: var(--font-head); font-weight: 700; font-size: 22px;
}
.brand-name { display: block; font-family: var(--font-head); font-weight: 700; font-size: 20px; line-height: 1.1; }
.brand-tag { display: block; font-size: 12.5px; color: var(--muted); }
.archive select, .speed select {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 10px; max-width: 46vw;
}

/* Edition intro */
.edition-intro { padding: 32px 0 8px; }
.edition-date { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.edition-intro h1 { font-family: var(--font-head); font-weight: 700; font-size: clamp(30px, 6vw, 44px); line-height: 1.12; margin: 8px 0 10px; text-wrap: balance; }
.edition-meta { margin: 0; color: var(--muted); font-size: 15px; }
.dot { margin: 0 6px; }
.edition-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 20px 0 16px; }
.speed { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 11px 18px; font-weight: 600; font-size: 15px; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); padding: 8px 14px; font-size: 14px; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost.is-done { color: var(--good); border-color: var(--good); background: var(--good-soft); }

.progress-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.progress-text { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.progress-text strong { color: var(--text); }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--good); border-radius: 99px; transition: width .4s ease; }

/* Filters */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 20px 0 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 500; }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.tip { font-size: 14px; color: var(--muted); margin: 12px 0 20px; }
.term-demo { border-bottom: 2px dotted var(--accent); }

/* Story */
.stories { display: grid; gap: 20px; }
.story { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 22px 18px; border-top: 4px solid var(--cat, var(--accent)); }
.story[data-cat="world"] { --cat: var(--world); }
.story[data-cat="football"] { --cat: var(--football); }
.story[data-cat="basketball"] { --cat: var(--basketball); }
.story[data-cat="tech"] { --cat: var(--tech); }
.story.is-read { opacity: .92; }
.story-head { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.tag { font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--cat); }
.minutes { color: var(--muted); }
.read-badge { margin-left: auto; color: var(--good); font-weight: 600; }
.story-title { font-family: var(--font-head); font-weight: 700; font-size: clamp(23px, 4.5vw, 28px); line-height: 1.2; margin: 6px 0 6px; text-wrap: balance; border-radius: 6px; transition: background-color .2s; }
.story-summary { margin: 0 0 16px; color: var(--muted); font-size: 16px; }

.player { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 999px; padding: 6px 14px 6px 6px; margin-bottom: 18px; }
.play-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--cat); color: #fff; display: grid; place-items: center; font-size: 20px; }
.play-btn:disabled { opacity: .45; cursor: not-allowed; }
.back-btn { flex: none; border: 0; background: none; color: var(--muted); font-size: 20px; display: grid; place-items: center; padding: 4px; }
.i-pause { display: none; }
.is-playing .i-play { display: none; }
.is-playing .i-pause { display: block; }
.seek { flex: 1; min-width: 0; accent-color: var(--cat); }
.time { flex: none; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 76px; text-align: right; }

.story-body p { margin: 0 0 14px; font-size: 18px; line-height: 1.75; }
.s { border-radius: 4px; cursor: pointer; transition: background-color .2s; padding: 1px 0; }
.s:hover { background: var(--surface-2); }
.s.is-speaking, .story-title.is-speaking { background: var(--highlight); }

.term { border-bottom: 2px dotted var(--cat); position: relative; cursor: help; font-weight: 500; }
.term:focus { outline: none; background: var(--accent-soft); }
.term::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: min(260px, 80vw);
  background: var(--text); color: var(--bg);
  font-size: 13.5px; font-weight: 400; line-height: 1.4; padding: 8px 10px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 5; white-space: normal;
}
.term:hover::after, .term:focus::after { opacity: 1; }

.panel { border-top: 1px solid var(--line); padding: 4px 0; }
.panel summary { cursor: pointer; font-weight: 600; font-size: 15px; padding: 10px 0; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: "+"; font-size: 20px; color: var(--muted); font-weight: 400; }
.panel[open] summary::after { content: "–"; }

.vocab-list { margin: 0 0 10px; display: grid; gap: 10px; }
.vocab-item { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; gap: 4px 14px; font-size: 15px; }
.vocab-item dt { font-weight: 600; }
.vocab-item dd { margin: 0; }
.vocab-item .fr { color: var(--cat); font-weight: 500; }
.vocab-item .en { display: block; color: var(--muted); font-size: 14px; }

.quiz-body { display: grid; gap: 14px; padding-bottom: 6px; }
.q-text { margin: 0 0 8px; font-weight: 500; font-size: 15.5px; }
.q-options { display: grid; gap: 6px; }
.q-option { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; font-size: 15px; }
.q-option:hover:not(:disabled) { border-color: var(--cat); }
.q-option:disabled { cursor: default; }
.q-option.is-correct { border-color: var(--good); background: var(--good-soft); color: var(--good); font-weight: 600; }
.q-option.is-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.quiz-score { margin: 4px 0 10px; font-weight: 600; }

.story-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; font-size: 14px; color: var(--muted); }

/* Footer */
.site-footer { margin-top: 40px; color: var(--muted); font-size: 14px; text-align: center; }

/* Mini player */
.mini-player {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  display: flex; align-items: center; gap: 12px;
  background: var(--text); color: var(--bg);
  border-radius: 999px; padding: 8px 10px 8px 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 20;
}
.mini-player[hidden] { display: none; }
.mini-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bg); color: var(--text); display: grid; place-items: center; font-size: 18px; }
.mini-next { background: transparent; color: var(--bg); }
.mini-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mini-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.mini-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .brand-tag { display: none; }
  .story { padding: 18px 16px 14px; }
  .story-body p { font-size: 17px; }
  .vocab-item { grid-template-columns: 1fr; }
  .time { min-width: 0; }
  .back-btn { display: none; }
}
