/* 读阶 Reading Ladder — Apple-minimal, self-contained (shares the site's
   token values from app-style.css; tools with their own style.css do not
   get the shared sheet, so the tokens are duplicated here). */
:root {
  color-scheme: light;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  --canvas: #f5f5f7;
  --surface: #fff;
  --recessed: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #65656b;
  --line: rgb(0 0 0 / .06);
  --control-line: rgb(0 0 0 / .14);
  --selected: rgb(0 0 0 / .075);
  --accent: #0071e3;
  --accent-hover: #0065cc;
  --accent-ink: #fff;
  --good: #1eaa50;
  --bad: #e02028;
  --orange: #d97a06;
  --purple: #8e44ad;
  --motion: .2s cubic-bezier(.16, 1, .3, 1);
  color: var(--ink);
  background: var(--canvas);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #161618;
  --surface: #1e1e20;
  --recessed: #242426;
  --ink: #f5f5f7;
  --muted: #ababaf;
  --line: rgb(255 255 255 / .08);
  --control-line: rgb(255 255 255 / .19);
  --selected: rgb(255 255 255 / .10);
  --accent: #5aaaf9;
  --accent-hover: #7bbaff;
  --accent-ink: #101820;
  --good: #4cc38a;
  --bad: #ff6b6b;
  --orange: #ff9f0a;
  --purple: #c678f0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; transition: background-color var(--motion), color var(--motion); }
main { width: min(896px, calc(100% - 32px)); margin: clamp(32px, 7vw, 80px) auto; }
h1 { font-size: clamp(2.25rem, 5vw, 4rem); font-weight: 600; line-height: 1.12; letter-spacing: -.045em; margin: 16px 0 8px; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; margin: 0 0 12px; }
h3 { font-size: 1rem; font-weight: 600; margin: 20px 0 8px; }
p { color: var(--muted); margin: 0; }
a { color: var(--ink); text-underline-offset: .2em; }
#back { display: inline-block; font-size: 14px; color: var(--muted); text-decoration: none; margin-bottom: 8px; }
.subtitle { font-size: 1.05rem; color: var(--muted); }
.lede { margin-top: 12px; font-size: 1.05rem; }
.badges { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 16px; font-size: 14px; color: var(--muted); }
.panel { display: grid; gap: 16px; margin-block-start: 32px; border: 1px solid var(--line); border-radius: 24px; padding: clamp(16px, 4vw, 32px); background: var(--surface); }
.of-url-note { font-size: 13px; color: var(--muted); line-height: 1.6; }
.fineprint { font-size: 13px; line-height: 1.6; }
button { display: inline-flex; justify-content: center; align-items: center; background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: 8px; min-height: 44px; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 16px; cursor: pointer; transition: background-color var(--motion), transform var(--motion); }
button:not(:disabled):hover { background: var(--accent-hover); }
button:not(:disabled):active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: wait; }
.secondary { color: var(--ink); background: var(--recessed); }
.secondary:not(:disabled):hover { background: var(--selected); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
textarea { width: 100%; min-height: 168px; resize: vertical; font: inherit; font-size: 15px; line-height: 1.6; color: var(--ink); background: var(--recessed); border: 1px solid var(--control-line); border-radius: 12px; padding: 12px 14px; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#status:empty { display: none; }
#status { font-size: 14px; color: var(--bad); }
.brand-line { text-align: center; color: var(--muted); font-size: 12.5px; letter-spacing: .14em; padding: 20px 0 28px; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend .sw-M { background: var(--good); }
.legend .sw-4 { background: var(--accent); }
.legend .sw-6 { background: var(--orange); }
.legend .sw-T { background: var(--purple); }
.legend .sw-B { background: var(--muted); }
.legend .sw-U { background: transparent; border: 1px dashed var(--muted); }

/* Article: word tokens keep the original text exactly; only the colour
   changes. Level colours: M green, CET-4 blue, CET-6 orange, TOEFL
   purple; function words and unlisted words stay grey. */
.rl-article { font-size: 1.12rem; line-height: 1.9; color: var(--ink); white-space: pre-wrap; overflow-wrap: break-word; }
.rl-article .w { cursor: pointer; border-radius: 4px; padding: 0 1px; }
.rl-article .w:hover { background: var(--selected); }
.rl-article .w.sel { background: var(--selected); outline: 1px solid var(--control-line); }
.rl-article .lv-M { color: var(--good); }
.rl-article .lv-4 { color: var(--accent); }
.rl-article .lv-6 { color: var(--orange); font-weight: 500; }
.rl-article .lv-T { color: var(--purple); font-weight: 500; }
.rl-article .lv-B { color: var(--muted); }
.rl-article .lv-U { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 3px; }

/* Definition card */
.rl-card { border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px; background: var(--recessed); display: grid; gap: 8px; }
.rl-card-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; }
.rl-card-word { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; color: var(--ink); }
.rl-badge { font-size: 11px; line-height: 1; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--control-line); color: var(--muted); white-space: nowrap; }
.rl-badge.lv-M { color: var(--good); border-color: var(--good); }
.rl-badge.lv-4 { color: var(--accent); border-color: var(--accent); }
.rl-badge.lv-6 { color: var(--orange); border-color: var(--orange); }
.rl-badge.lv-T { color: var(--purple); border-color: var(--purple); }
.rl-card-ph { font-size: 14px; color: var(--muted); }
.rl-card-senses { font-size: 1.05rem; color: var(--ink); }

/* Stats */
.rl-stats { display: grid; gap: 12px; }
.rl-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.rl-stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); }
.rl-stat .num { font-size: 1.4rem; font-weight: 600; color: var(--ink); letter-spacing: -.02em; }
.rl-stat .lbl { font-size: 12px; color: var(--muted); }
.rl-level-bars { display: grid; gap: 8px; }
.rl-bar-row { display: grid; grid-template-columns: 96px 1fr 64px; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.rl-bar-track { height: 8px; border-radius: 999px; background: var(--recessed); overflow: hidden; }
.rl-bar-fill { height: 100%; border-radius: 999px; }
.rl-bar-fill.lv-M { background: var(--good); }
.rl-bar-fill.lv-4 { background: var(--accent); }
.rl-bar-fill.lv-6 { background: var(--orange); }
.rl-bar-fill.lv-T { background: var(--purple); }
.rl-bar-fill.lv-B { background: var(--muted); }
.rl-bar-fill.lv-U { background: var(--muted); opacity: .45; }
.rl-bar-row .pct { text-align: right; font-variant-numeric: tabular-nums; }

/* Vocab book */
.rl-book-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); display: grid; gap: 4px; margin-bottom: 8px; }
.rl-book-item .rl-book-head { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: baseline; }
.rl-book-item .rl-book-word { font-weight: 600; color: var(--ink); }
.rl-book-item .rl-book-senses { font-size: 14px; color: var(--ink); }
.rl-book-item .rl-book-sent { font-size: 13px; color: var(--muted); font-style: italic; }
.rl-book-item .rl-book-meta { display: flex; gap: 8px; align-items: center; }
.rl-book-item .rl-book-meta button { min-height: 32px; padding: 4px 10px; font-size: 12px; }
