/* Pinyin Starter · styles */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --text: #1c1c1e;
  --muted: #64646b;
  --border: #e1dfd8;
  --accent: #2f6fe4;
  --accent-ink: #ffffff;
  --ring: #2f6fe4;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);

  /* Four tones: 1 red · 2 orange · 3 green · 4 blue · neutral grey */
  --t1: #d42a2a;  --t1-bg: #fdeded;
  --t2: #c46200;  --t2-bg: #fff1e1;
  --t3: #15834a;  --t3-bg: #e5f5ec;
  --t4: #2160d4;  --t4-bg: #e8effd;
  --t5: #85858c;

  /* Unaspirated / aspirated pairs (initials) */
  --p-bp: #efe6fb;   --p-bp-ink: #6b3fb3;
  --p-dt: #dff3f3;   --p-dt-ink: #1d7272;
  --p-gk: #fbe6f0;   --p-gk-ink: #a8326b;
  --p-jq: #f8f0d3;   --p-jq-ink: #85640b;
  --p-zhch: #e5e9f8; --p-zhch-ink: #3c4fa3;
  --p-zc: #ebf2da;   --p-zc-ink: #4f6a14;

  --radius: 18px;
  --maxw: 1040px;
  --gutter-l: max(calc(16px + env(safe-area-inset-left)), calc((100% - var(--maxw)) / 2));
  --gutter-r: max(calc(16px + env(safe-area-inset-right)), calc((100% - var(--maxw)) / 2));
  --gap: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-zh: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC",
             "Microsoft YaHei", sans-serif;
}

/* Dark palette: used for “Auto” when the system is dark, and for “Dark”. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141416; --surface: #1f1f22; --surface-2: #2a2a2e; --text: #f2f2f4;
    --muted: #a3a3ab; --border: #36363c; --accent: #5b8ff0; --ring: #7ea8f6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
    --t1: #ff6d6d; --t1-bg: #3a1c1e; --t2: #ffab5e; --t2-bg: #3a2818;
    --t3: #4fd18b; --t3-bg: #163426; --t4: #78a9ff; --t4-bg: #1b2944; --t5: #9b9ba3;
    --p-bp: #2c2340; --p-bp-ink: #c6a8f5; --p-dt: #173535; --p-dt-ink: #84d6d6;
    --p-gk: #3b1e2c; --p-gk-ink: #f3a0c6; --p-jq: #362e16; --p-jq-ink: #e8c766;
    --p-zhch: #20263f; --p-zhch-ink: #a6b4f2; --p-zc: #262f17; --p-zc-ink: #b8d77a;
  }
}
:root[data-theme="dark"] {
  --bg: #141416; --surface: #1f1f22; --surface-2: #2a2a2e; --text: #f2f2f4;
  --muted: #a3a3ab; --border: #36363c; --accent: #5b8ff0; --ring: #7ea8f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  --t1: #ff6d6d; --t1-bg: #3a1c1e; --t2: #ffab5e; --t2-bg: #3a2818;
  --t3: #4fd18b; --t3-bg: #163426; --t4: #78a9ff; --t4-bg: #1b2944; --t5: #9b9ba3;
  --p-bp: #2c2340; --p-bp-ink: #c6a8f5; --p-dt: #173535; --p-dt-ink: #84d6d6;
  --p-gk: #3b1e2c; --p-gk-ink: #f3a0c6; --p-jq: #362e16; --p-jq-ink: #e8c766;
  --p-zhch: #20263f; --p-zhch-ink: #a6b4f2; --p-zc: #262f17; --p-zc-ink: #b8d77a;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button, select { font: inherit; color: inherit; touch-action: manipulation; }

a { color: var(--accent); }

.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;
}

/* Tone colours, usable on any element */
.t1 { color: var(--t1); }
.t2 { color: var(--t2); }
.t3 { color: var(--t3); }
.t4 { color: var(--t4); }
.t5 { color: var(--t5); }
.tone-1 { --tone: var(--t1); --tone-bg: var(--t1-bg); }
.tone-2 { --tone: var(--t2); --tone-bg: var(--t2-bg); }
.tone-3 { --tone: var(--t3); --tone-bg: var(--t3-bg); }
.tone-4 { --tone: var(--t4); --tone-bg: var(--t4-bg); }

.zh { font-family: var(--font-zh); }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter-r) 10px var(--gutter-l);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; color: inherit; text-decoration: none; min-height: 44px; align-items: center; }
.brand-zh { font-family: var(--font-zh); font-size: 20px; font-weight: 700; }
.brand-py { font-size: 15px; font-weight: 700; }

.tabs {
  display: flex;
  flex: 1;
  gap: 4px;
  padding: 4px;
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface-2);
  border-radius: 12px;
}

.tab {
  flex: 1;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible,
.play-btn:focus-visible, .group-title:focus-visible, .cell:focus-visible,
.syl-btn:focus-visible, .phrase-play:focus-visible, .close-btn:focus-visible,
.tone-btn:focus-visible, .select:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.settings { position: relative; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: min(300px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: calc(100vh - 90px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.popover[hidden], .lang-row[hidden] { display: none; }

.pop-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.seg + .pop-label, .seg + .lang-row { margin-top: 14px; }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 10px; }

.seg button {
  flex: 1;
  min-height: 44px;
  line-height: 1.2;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }

.select {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

/* ---------- Main ---------- */

main {
  padding: 8px max(calc(16px + env(safe-area-inset-right)), calc((100% - var(--maxw)) / 2))
           24px max(calc(16px + env(safe-area-inset-left)), calc((100% - var(--maxw)) / 2));
}

/* The chart is wide: let it use more of a large screen. */
main.wide { --maxw: 1500px; }

.panel[hidden] { display: none; }

.sec-title { margin: 26px 0 4px; font-size: 24px; font-weight: 750; letter-spacing: -.01em; }
.sec-intro { margin: 0 0 16px; font-size: 16px; color: var(--muted); max-width: 70ch; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 16px; }

.grid { display: grid; gap: var(--gap); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* ---------- Buttons ---------- */

.play-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}

.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 5px 18px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.play-btn.active, .group-title.active { outline: 3px solid var(--ring); outline-offset: 2px; }

/* ---------- Flip cards ---------- */

.card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 140px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 1000px;
  -webkit-user-select: none;
  user-select: none;
  border-radius: var(--radius);
}

.card:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }

.card-inner {
  position: absolute;
  inset: 0;
  transition: transform .5s cubic-bezier(.3, .7, .3, 1);
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.card.flipped .card-inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg, var(--surface));
  box-shadow: var(--shadow);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  overflow: hidden;
  text-align: center;
}

/* Safari needs a 3D transform on the front too for backface-visibility to stick. */
.front { transform: rotateY(0deg); }
.back { transform: rotateY(180deg); }

.card.playing .face { outline: 3px solid var(--ring); outline-offset: 2px; }
.card.playing { z-index: 1; }
.card.playing .card-inner { transform: scale(1.04); }
.card.playing.flipped .card-inner { transform: rotateY(180deg) scale(1.04); }

.big-py {
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -.01em;
}

.mid-py { font-size: clamp(32px, 5vw, 54px); font-weight: 650; line-height: 1.1; }

.card-sub { font-size: 15px; font-weight: 650; color: var(--muted); }
.card-tip { font-size: 15px; line-height: 1.3; color: var(--text); max-width: 22ch; }

/* ---------- Tones ---------- */

.tone-card { aspect-ratio: 3 / 4; min-height: 220px; }
.tone-card .face { --card-bg: var(--tone-bg); }
.tone-card .big-py { color: var(--tone); }
.tone-card .card-sub { color: var(--tone); }

.tone-hint { font-size: clamp(17px, 2vw, 22px); font-weight: 700; line-height: 1.25; color: var(--text); }
.tone-meaning { font-size: 15px; color: var(--muted); }
.tone-meaning .zh { font-size: 20px; color: var(--text); margin-right: 4px; }

.contour { width: 100%; max-width: 180px; height: auto; overflow: visible; }
.contour .grid-line { stroke: var(--border); stroke-width: 1.2; }
.contour .level { fill: var(--muted); font-size: 9px; font-family: var(--font); }
.contour .line {
  fill: none;
  stroke: var(--tone);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.contour .dot { fill: var(--tone); }
.contour.draw .line { animation: draw .9s cubic-bezier(.4, .1, .4, 1) both; }
.contour.draw .dot { animation: dot .9s step-end both; }
.contour-mini { max-width: 90px; }
.contour-mini .line { stroke-width: 9; }

@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes dot { from { opacity: 0; } to { opacity: 1; } }

.chao { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.note-box {
  margin: 18px 0 0;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.note-box h3 { margin: 0 0 6px; font-size: 18px; }
.note-box h3.with-label { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.note-label { padding: 0 10px; border-radius: 10px; background: var(--surface-2); font-size: 26px; font-weight: 700; line-height: 1.3; }
.note-box p { margin: 0 0 8px; font-size: 16px; }
.note-box .muted { color: var(--muted); font-size: 14px; }

.examples { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px; padding: 0; list-style: none; }
.examples li {
  display: flex; flex-direction: column; align-items: center;
  min-width: 96px; padding: 8px 12px;
  background: var(--surface-2); border-radius: 12px;
}
.examples .zh { font-size: 24px; line-height: 1.2; }
.examples .py { font-size: 20px; font-weight: 650; }
.examples .gloss { font-size: 13px; color: var(--muted); }

/* ---------- Finals ---------- */

.letter-card.large .big-py { color: var(--text); }
.letter-card.large .back .mid-py { margin-bottom: 4px; }
.tip-flag {
  display: inline-block; margin-top: 2px; padding: 1px 10px;
  border-radius: 999px; background: var(--surface-2);
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.tips-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.tips-grid .note-box { margin: 0; }

/* ---------- Initials ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 750; line-height: 1.5;
  border: 1.5px solid var(--pair-ink, var(--muted));
  color: var(--pair-ink, var(--muted));
  background: var(--surface);
}
.badge.asp { background: var(--pair-ink, var(--muted)); color: var(--surface); }

.pair-bp { --pair: var(--p-bp); --pair-ink: var(--p-bp-ink); }
.pair-dt { --pair: var(--p-dt); --pair-ink: var(--p-dt-ink); }
.pair-gk { --pair: var(--p-gk); --pair-ink: var(--p-gk-ink); }
.pair-jq { --pair: var(--p-jq); --pair-ink: var(--p-jq-ink); }
.pair-zhch { --pair: var(--p-zhch); --pair-ink: var(--p-zhch-ink); }
.pair-zc { --pair: var(--p-zc); --pair-ink: var(--p-zc-ink); }

.igroups { display: grid; gap: var(--gap); }

.igroup {
  display: grid;
  grid-template-columns: minmax(96px, 150px) repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.group-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.letter-card .face { --card-bg: var(--pair, var(--surface)); }
.letter-card .big-py { color: var(--pair-ink, var(--text)); font-weight: 650; }
.letter-card .card-tip { font-size: 14px; }

/* ---------- Chart ---------- */

.chart-wrap {
  position: relative;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 150px - env(safe-area-inset-top));
  max-height: calc(100dvh - 150px - env(safe-area-inset-top));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overscroll-behavior: contain;
}

.chart { border-collapse: separate; border-spacing: 0; font-size: 16px; }

.chart th, .chart td {
  padding: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.chart thead th {
  position: sticky;
  z-index: 2;
  background: var(--surface-2);
  font-weight: 750;
}
.chart thead tr:first-child th { top: 0; height: 30px; font-size: 13px; color: var(--muted); }
.chart thead tr:nth-child(2) th { top: 30px; height: 36px; padding: 0 6px; }

.chart tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 52px;
  padding: 0 8px;
  background: var(--surface-2);
  font-weight: 750;
}

.chart thead th.corner { left: 0; z-index: 3; }

.chart .gstart { border-left: 2px solid var(--muted); }

.cell {
  display: block;
  width: 100%;
  min-width: 54px;
  min-height: 44px;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.cell:hover { background: var(--surface-2); }
.cell.active { background: var(--accent); color: var(--accent-ink); }
td.empty { background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--surface-2) 70%, transparent) 6px 7px); }

/* Dialog / bottom sheet with the four tones */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .35);
}
.sheet-backdrop[hidden] { display: none; }

.sheet {
  width: min(560px, 100%);
  padding: 18px 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-title { margin: 0; font-size: 20px; }

.close-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: var(--surface-2); cursor: pointer;
}

.sheet-tones { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }

.tone-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 110px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--tone-bg);
  cursor: pointer;
}
.tone-btn .py { font-size: clamp(30px, 6vw, 44px); font-weight: 650; color: var(--tone); line-height: 1.1; }
.tone-btn .n { font-size: 13px; font-weight: 700; color: var(--muted); }
.tone-btn.playing { outline: 3px solid var(--ring); outline-offset: 2px; }

.sheet-all { width: 100%; justify-content: center; }

/* ---------- Phrases ---------- */

.phrases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }

.phrase {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.phrase.playing { outline: 3px solid var(--ring); outline-offset: 2px; }

.phrase-play {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.phrase-hanzi { font-family: var(--font-zh); font-size: clamp(36px, 5.4vw, 56px); font-weight: 600; line-height: 1.15; }

.phrase-py { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: clamp(22px, 3vw, 30px); font-weight: 650; }
.phrase-py .word { display: inline-flex; }

.syl-btn {
  min-height: 44px;
  padding: 0 1px;
  border: 0;
  border-bottom: 2px dotted transparent;
  background: none;
  font-weight: inherit;
  cursor: pointer;
}
.syl-btn:hover { border-bottom-color: currentColor; }
.syl-btn.playing { border-bottom: 2px solid currentColor; }
.syl-plain { display: inline-flex; align-items: center; min-height: 44px; }

.phrase-say { font-size: 16px; color: var(--muted); }
.phrase-say .py { font-weight: 700; font-size: 20px; }
.phrase-meaning { font-size: 19px; font-weight: 650; }
.phrase-note { margin: 2px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 15px; }

.phrase-meaning-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge-ai {
  flex: none;
  padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; font-weight: 700; color: var(--muted);
}

/* ---------- Footer & notice ---------- */

.foot {
  padding: 16px var(--gutter-r) calc(28px + env(safe-area-inset-bottom)) var(--gutter-l);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
}
.foot p { margin: 4px auto; max-width: 80ch; }

.notice {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: min(340px, calc(100vw - 24px));
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.notice[hidden] { display: none; }

.noscript { text-align: center; padding: 40px 16px; }

/* ---------- Responsive ---------- */

/* iPad portrait and small laptops */
@media (max-width: 900px) {
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .letter-card.large { aspect-ratio: 5 / 4; }
}

/* Phones */
@media (max-width: 600px) {
  :root { --gap: 10px; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; max-width: none; }
  .tab { font-size: 14px; padding: 6px 2px; }
  .settings { margin-left: auto; }
  .sec-title { font-size: 21px; margin-top: 20px; }
  .sec-intro { font-size: 15px; }

  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tone-card { aspect-ratio: 4 / 5; min-height: 0; }
  .contour:not(.contour-mini) { max-width: 140px; }
  .contour-mini { max-width: 60px; }
  .big-py { font-size: clamp(44px, 14vw, 64px); }
  .mid-py { font-size: clamp(28px, 9vw, 40px); }
  .card-tip, .letter-card .card-tip { font-size: 13px; }
  .card-sub { font-size: 13px; }
  .face { padding: 6px; }

  .letter-card.large { aspect-ratio: 4 / 5; min-height: 0; }
  .tips-grid { grid-template-columns: 1fr; }

  /* Initials: group title spans the row, cards three or four across */
  .igroup { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .group-title {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-start;
    min-height: 48px;
    margin-top: 6px;
    padding: 4px 14px 4px 6px;
    box-shadow: none;
  }
  .letter-card { aspect-ratio: 3 / 4; min-height: 0; }
  .letter-card .big-py { font-size: clamp(36px, 11vw, 50px); }
  .letter-card .mid-py { font-size: clamp(24px, 7vw, 30px); }
  .letter-card .card-tip { font-size: 11.5px; }
  .letter-card .badge { font-size: 10.5px; padding: 0 6px; }

  .phrases { grid-template-columns: 1fr; }

  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 22px 22px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .tone-btn { min-height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .card-inner { transition: none; }
  .contour.draw .line, .contour.draw .dot { animation: none; }
}

/* =====================================================================
   Platform: navigation, home, level pages
   ===================================================================== */

.unitbar {
  position: sticky; top: calc(65px + env(safe-area-inset-top)); z-index: 15;
  background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.unitbar[hidden] { display: none; }
.unit-tabs {
  display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  padding: 6px max(calc(16px + env(safe-area-inset-right)), calc((100% - 1040px) / 2)) 6px max(calc(16px + env(safe-area-inset-left)), calc((100% - 1040px) / 2));
}
.unit-tabs::-webkit-scrollbar { display: none; }
.unit-tab {
  flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 4px 14px;
  border-radius: 999px; color: var(--muted); font-weight: 650; text-decoration: none; white-space: nowrap;
}
.unit-tab:hover { background: var(--surface-2); }
.unit-tab[aria-current="page"] { background: var(--text); color: var(--bg); }

.page-head { margin: 20px 0 6px; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.page-title { margin: 2px 0 10px; font-size: clamp(26px, 3.4vw, 34px); font-weight: 780; letter-spacing: -.015em; line-height: 1.15; }

.module-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.module-tab {
  display: inline-flex; align-items: center; min-height: 44px; padding: 4px 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text); font-weight: 650; text-decoration: none;
}
.module-tab[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.block { margin: 8px 0 22px; }
.block > .sec-title { margin-top: 18px; }
.loading, .error { padding: 40px 0; color: var(--muted); text-align: center; }
.error { color: var(--t1); }
.footnote { margin-top: 14px; }
.muted { color: var(--muted); }


.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--gap); margin: 14px 0; }
.unit-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.unit-card-link { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px 12px; color: var(--text); text-decoration: none; flex: 1; }
.unit-card-link:hover .unit-title { color: var(--accent); }
.unit-num { font-size: 12.5px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.unit-title { font-size: 20px; font-weight: 760; }
.unit-summary { font-size: 14.5px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 16px; }
.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 2px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
  color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.chip.toggle { min-height: 44px; }
.chip.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.pager { display: flex; justify-content: space-between; gap: 12px; margin: 34px 0 6px; padding-top: 16px; border-top: 1px solid var(--border); }
.pager-link {
  display: flex; flex-direction: column; gap: 2px; max-width: 48%; min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-decoration: none; font-weight: 650;
}
.pager-link.next { text-align: right; margin-left: auto; }
.pager-dir { font-size: 13px; color: var(--accent); font-weight: 750; }

.access-view { text-align: center; padding: 50px 0; }
.access-icon { font-size: 44px; }
.access-view .sec-intro { margin: 0 auto 18px; }
.access-note { max-width: 34em; margin: -6px auto 18px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-weight: 600; }
.access-form {
  display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: 100%; max-width: 360px;
  margin: 0 auto 26px; padding: 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); text-align: left;
}
.access-label { font-weight: 700; }
.access-input {
  min-height: 52px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  color: var(--text); font: 600 20px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase;
}
.access-input::placeholder { text-transform: none; letter-spacing: normal; font: 400 16px/1.2 system-ui, sans-serif; color: var(--muted); }
.access-input:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.access-remember { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.access-remember input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.access-hint { margin: -8px 0 4px 30px; font-size: 13px; color: var(--muted); }
.access-submit { justify-content: center; min-height: 48px; font-size: 16px; }
.access-submit:disabled { opacity: .6; cursor: wait; transform: none; }
.access-msg { min-height: 1.4em; margin: 0; font-size: 14px; color: var(--muted); }
.access-msg.is-bad { color: var(--t1); font-weight: 600; }
.access-signout {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer;
}

/* ---------- buttons ---------- */

.play-btn { color: var(--text); text-decoration: none; }
.play-btn.small { min-height: 40px; font-size: 14px; padding: 3px 14px 3px 4px; box-shadow: none; }
.play-btn.small .play-icon { width: 30px; height: 30px; }
.play-btn.big { min-height: 64px; font-size: 20px; padding: 8px 26px 8px 10px; }
.play-btn.big .play-icon { width: 46px; height: 46px; }
.play-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); padding-left: 18px; }
.play-btn.primary .play-icon { background: var(--accent-ink); color: var(--accent); }
.play-btn.primary:has(.play-icon) { padding-left: 6px; }
.play-btn.plain { padding-left: 18px; box-shadow: none; background: transparent; }
.play-btn[disabled] { opacity: .45; cursor: not-allowed; }
.play-icon.small { width: 26px; height: 26px; }
.mini-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 3px 14px 3px 6px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-weight: 650; cursor: pointer;
}
.mini-btn.test-btn { padding: 0; width: 44px; justify-content: center; font-size: 20px; font-weight: 800; color: var(--accent); }
.mini-btn.active { outline: 3px solid var(--ring); outline-offset: 2px; }

/* ---------- cards block ---------- */

.cgroups { display: grid; gap: 18px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 10px; }
.group-name { margin: 0; font-size: 18px; }
.card-grid { grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); }
.letter-card { aspect-ratio: 1 / 1; min-height: 130px; }
.letter-card .face { --card-bg: var(--pair, var(--surface)); }
.letter-card .big-py { color: var(--pair-ink, var(--text)); }
.letter-card .card-sub { font-size: 15px; }
/* four-letter labels (yuan, ying) shrink with the card so they never overflow it */
.letter-card { container-type: inline-size; }
.letter-card .big-py.long { font-size: min(30cqi, 72px); }

/* ---------- words block ---------- */

.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--gap); }
.phrase.compact { padding: 12px 14px 14px; gap: 4px; }
.phrase.compact .phrase-hanzi { font-size: clamp(28px, 3.6vw, 36px); }
.phrase.compact .phrase-py { font-size: 20px; }
.phrase.compact .phrase-meaning { font-size: 15.5px; }
.phrase.compact .play-icon { width: 30px; height: 30px; }
.tag-badge { flex: none; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 750; border: 1.5px solid currentColor; }
.tag-badge.changes { color: var(--t2); }
.tag-badge.stays { color: var(--muted); }
.phrase-meaning-row .badge-ai { margin-left: auto; }
.tag-badge + .badge-ai { margin-left: 0; }

/* ---------- tone grid (20 tone pairs) ---------- */

.tone-grid { display: grid; gap: 10px; }
.tg-row { display: grid; grid-template-columns: 112px repeat(5, minmax(0, 1fr)); gap: 10px; }
.tg-head span { font-size: 13px; font-weight: 750; text-align: center; align-self: end; }
.tg-corner { color: var(--muted); text-align: left !important; font-weight: 600 !important; font-size: 12px !important; }
.tg-rowhead { font-size: 17px; }
.tg-item {
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 150px; padding: 10px 6px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
}
.tg-item.playing { outline: 3px solid var(--ring); outline-offset: 2px; }
.tg-tones { font-size: 13px; font-weight: 800; }
.tg-hanzi { font-family: var(--font-zh); font-size: clamp(24px, 2.6vw, 32px); line-height: 1.2; }
.tg-py { font-size: 17px; font-weight: 700; }
.tg-said { font-size: 13px; color: var(--muted); }
.tg-gloss { font-size: 13px; color: var(--muted); }
.pair-contour { display: flex; gap: 2px; margin: 2px 0; }
.pair-contour > span { width: 34px; }
.pair-contour .contour-mini { width: 100%; }
.pair-contour .contour-mini .line { stroke-width: 11; }
.pair-contour .neutral .neutral-dot { fill: var(--t5); }

/* ---------- spelling rules ---------- */

.rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.rule { padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.rule-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rule-title { margin: 0; font-size: 18px; }
.rule-body { margin: 6px 0 10px; font-size: 15px; color: var(--muted); }
.rule-examples { display: flex; flex-wrap: wrap; gap: 8px; }
.rule-ex {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 44px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer;
}
.rule-ex.playing { outline: 3px solid var(--ring); outline-offset: 2px; }
.rule-from { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; color: var(--muted); }
.rule-arrow { color: var(--muted); font-size: 14px; }
.rule-to { font-size: 22px; font-weight: 700; }
.rule-pair { display: inline-flex; gap: 4px; }

/* ---------- minimal pairs ---------- */

.pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.pair-row { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.pair-row.right { border-color: var(--t3); }
.pair-row.wrong { border-color: var(--t1); }
.pair-label { font-size: 13px; font-weight: 750; color: var(--muted); }
.pair-sides { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 6px; }
.pair-vs { align-self: center; color: var(--muted); font-size: 22px; }
.pair-side {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 120px; padding: 8px 4px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); cursor: pointer;
}
.pair-side.playing { outline: 3px solid var(--ring); outline-offset: 2px; }
.pair-row.testing .pair-side { border: 2px dashed var(--accent); }
.pair-side.was-it { outline: 3px solid var(--t3); outline-offset: 2px; }
.pair-hanzi { font-family: var(--font-zh); font-size: clamp(30px, 4vw, 42px); line-height: 1.15; }
.pair-py { font-size: 20px; font-weight: 700; }
.pair-said { font-size: 13px; color: var(--muted); }
.pair-gloss { font-size: 13.5px; color: var(--muted); }
.pair-actions { display: flex; gap: 8px; justify-content: center; }
.pair-feedback { margin: 0; min-height: 1.4em; text-align: center; font-size: 15px; font-weight: 650; }
.pair-row.right .pair-feedback { color: var(--t3); }
.pair-row.wrong .pair-feedback { color: var(--t1); }

/* ---------- quiz ---------- */

.quiz { padding: 4px 0; }
.quiz-h { margin: 18px 0 8px; font-size: 18px; }
.quiz-modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quiz-mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 108px; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: 16px; background: var(--surface); text-align: left; cursor: pointer;
}
.quiz-mode[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.quiz-mode-title { font-size: 18px; font-weight: 760; }
.quiz-mode-desc { font-size: 14px; color: var(--muted); flex: 1; }
.quiz-mode-stats { font-size: 12.5px; font-weight: 650; color: var(--accent); }
.quiz-scope-label { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quiz-pool { margin: 14px 0 0; font-weight: 650; }
.quiz-pool.bad { color: var(--t1); }

.quiz-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 700; }
.quiz-mode-name { color: var(--muted); font-size: 14px; }
.quiz-bar { height: 8px; margin: 8px 0 18px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.quiz-bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.quiz-stage { display: flex; justify-content: center; margin: 6px 0 20px; }
.quiz-opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quiz-opt {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 112px; padding: 10px 6px; border: 1.5px solid var(--border); border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
}
.quiz-opt.tone-1, .quiz-opt.tone-2, .quiz-opt.tone-3, .quiz-opt.tone-4 { background: var(--tone-bg); }
.quiz-opt .opt-key { position: absolute; top: 6px; left: 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.quiz-opt .opt-main { font-size: clamp(30px, 5vw, 44px); font-weight: 680; line-height: 1.1; }
.quiz-opt .opt-sub { font-size: 13px; font-weight: 650; color: var(--muted); }
.quiz-opt .opt-contour { width: 46px; }
.quiz-opt .opt-contour .contour-mini { width: 100%; }
.quiz-opt[disabled] { cursor: default; opacity: .55; }
.quiz-opt.is-answer { opacity: 1; outline: 3px solid var(--t3); outline-offset: 2px; }
.quiz-opt.is-wrong { opacity: 1; outline: 3px solid var(--t1); outline-offset: 2px; }
.quiz-feedback { min-height: 2.2em; margin: 16px 0 4px; font-size: 18px; text-align: center; }
.quiz-feedback.right strong { color: var(--t3); }
.quiz-feedback.wrong strong { color: var(--t1); }
.quiz-feedback .you { color: var(--muted); font-size: 15px; }
.quiz .toolbar { justify-content: center; }
.keys-hint { text-align: center; font-size: 13px; }

.dict { max-width: 520px; margin: 0 auto; }
.dict-row { display: flex; gap: 8px; }
.dict-input {
  flex: 1; min-width: 0; min-height: 56px; padding: 0 16px; border: 1.5px solid var(--border); border-radius: 14px;
  background: var(--surface); font: inherit; font-size: 26px; color: var(--text);
}
.dict-input:focus { outline: 3px solid var(--ring); outline-offset: 1px; }
.dict-preview { display: block; min-height: 1.5em; margin: 8px 0; font-size: 30px; font-weight: 700; }
.dict-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dict-keys .key {
  min-width: 48px; min-height: 48px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); font-size: 20px; font-weight: 800; cursor: pointer;
}

.quiz-score { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.quiz-percent { font-size: 56px; font-weight: 820; line-height: 1.05; color: var(--accent); }
.quiz-result { font-size: 18px; font-weight: 700; }
.quiz-perfect { text-align: center; font-weight: 650; color: var(--t3); }
.mistakes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mistake {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 6px 14px 6px 8px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); text-align: left; cursor: pointer;
}
.mistake.playing { outline: 3px solid var(--ring); outline-offset: 2px; }
.mistake-py { font-size: 24px; font-weight: 750; min-width: 3.2em; }
.mistake-detail { font-size: 14.5px; color: var(--muted); }

/* ---------- platform responsive ---------- */

@media (max-width: 900px) {
  .card-grid { grid-template-columns: repeat(min(var(--cols, 5), 4), minmax(0, 1fr)); }
  .tg-row { grid-template-columns: 96px repeat(5, minmax(0, 1fr)); gap: 8px; }
  .tg-item { min-height: 140px; }
  .rules, .pairs { grid-template-columns: 1fr; }
  .quiz-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .topbar { flex-wrap: nowrap; }
  .unitbar { top: calc(65px + env(safe-area-inset-top)); }
  .page-title { font-size: 26px; }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .letter-card { aspect-ratio: 4 / 5; min-height: 0; }
  .letter-card.large { aspect-ratio: 4 / 5; }
  .tg-head { display: none; }
  .tg-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tg-rowhead { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; min-height: 48px; padding: 4px 14px 4px 6px; box-shadow: none; }
  .tg-item { min-height: 132px; padding: 8px 4px; }
  .word-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .phrase.compact { padding: 10px; }
  .phrase.compact .phrase-hanzi { font-size: 26px; }
  .phrase.compact .phrase-py { font-size: 17px; gap: 0 6px; }
  .phrase.compact .phrase-play { gap: 8px; }
  .phrase.compact .play-icon { width: 26px; height: 26px; }
  .phrase.compact .phrase-meaning-row { flex-wrap: wrap; gap: 4px 6px; }
  .rule-to { font-size: 20px; }
  .pair-side { min-height: 104px; }
  .quiz-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quiz-opt { min-height: 96px; }
  .pager-link { font-size: 14px; }
}

/* small fixes after visual review */
.pair-feedback:empty { display: none; }
@media (max-width: 600px) {
  .module-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 4px; margin-right: -16px; padding-right: 16px; }
  .module-tabs::-webkit-scrollbar { display: none; }
  .module-tab { flex: none; padding: 4px 13px; font-size: 15px; }
}

/* =====================================================================
   Brand site: fonts, top navigation, home page, course placeholders
   ===================================================================== */

/* Noto Serif SC, subset to the characters used in headings (scripts/build-fonts.py, OFL 1.1).
   Characters outside the subset fall back to the system serif. */
@font-face {
  font-family: "Jiayi Serif";
  src: url("../fonts/noto-serif-sc-600.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --nav-h: 64px;
  --nav-total: calc(var(--nav-h) + env(safe-area-inset-top));
  --serif: "Jiayi Serif", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --brand: #a8322a;
  --brand-ink: #ffffff;
  --site-max: 1160px;
  --gut: max(calc(20px + env(safe-area-inset-left)), calc((100% - var(--site-max)) / 2));
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --brand: #d9574c; } }
:root[data-theme="dark"] { --brand: #d9574c; }

html { scroll-padding-top: calc(var(--nav-total) + 8px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

.serif { font-family: var(--serif); }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--surface); color: var(--text); }
.skip-link:focus { top: 10px; }

/* old header pieces no longer used */
.topbar, .crumbs { display: none; }

/* ---------- top navigation ---------- */

.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}
.topnav.over-hero:not(.solid) {
  background: linear-gradient(rgba(0, 0, 0, .38), rgba(0, 0, 0, 0));
  -webkit-backdrop-filter: none; backdrop-filter: none;
  border-color: transparent;
  color: #fff;
}
body.nav-open .topnav, body.nav-open .topnav.over-hero:not(.solid) {
  background: var(--bg); color: var(--text); border-color: var(--border); -webkit-backdrop-filter: none; backdrop-filter: none;
}
.nav-spacer { height: var(--nav-total); }
body.is-home .nav-spacer { display: none; }

.nav-inner {
  display: flex; align-items: center; gap: 18px; height: var(--nav-h);
  padding: 0 max(calc(16px + env(safe-area-inset-right)), calc((100% - var(--site-max)) / 2)) 0 var(--gut);
}
.topnav .brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: inherit; text-decoration: none; white-space: nowrap; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; padding: 3px 6px 4px;
  border-radius: 6px; background: var(--brand); color: #fff;
  font-family: var(--serif); font-size: 15px; font-weight: 600; line-height: 1; letter-spacing: .04em;
}
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: .01em; }

.nav-main { flex: 1; min-width: 0; }
.nav-list { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 10px; background: none; color: inherit;
  font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.nav-link:hover, .nav-link[aria-expanded="true"] { background: rgba(127, 127, 127, .14); }
.nav-list > li.is-active > .nav-link { box-shadow: inset 0 -2px 0 currentColor; border-radius: 10px 10px 0 0; }
.chev { display: inline-flex; transition: transform .2s; }
.nav-menu-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.soon-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .45; }

.has-menu { position: relative; }
.nav-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 2; min-width: 350px; padding: 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .16);
}
.nav-menu[hidden] { display: none; }
.nav-menu-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none; }
.nav-menu-item:hover, .nav-menu-item:focus-visible { background: var(--surface-2); outline: none; }
.nav-menu-label { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15.5px; }
.nav-menu-desc { font-size: 13.5px; color: var(--muted); }
.nav-menu-item.is-soon .nav-menu-label { color: var(--muted); }
.soon-badge { flex: none; white-space: nowrap; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .02em; }

.nav-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.lang-toggle {
  min-width: 48px; min-height: 40px; padding: 0 12px; border: 1px solid rgba(127, 127, 127, .45); border-radius: 999px;
  background: transparent; color: inherit; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.lang-toggle:hover { background: rgba(127, 127, 127, .14); }
.topnav .icon-btn { background: transparent; color: inherit; border-color: rgba(127, 127, 127, .45); min-height: 40px; }
.topnav .popover { color: var(--text); }
#settings-value { display: none; }
@media (min-width: 1180px) { body.is-learning #settings-value { display: inline; } }
.nav-burger { display: none; }
.lang-toggle:focus-visible, .nav-link:focus-visible, .nav-burger:focus-visible, .topnav .brand:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.unitbar { top: var(--nav-total); }
.unit-tabs { padding-left: var(--gut); padding-right: var(--gut); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 26px;
  border: 1.5px solid transparent; border-radius: 999px; font-size: 16.5px; font-weight: 700; text-decoration: none;
  cursor: pointer; transition: transform .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 30%, transparent); }
.btn-light { background: #fff; color: #161616; }
.btn-ghost-light { border-color: rgba(255, 255, 255, .7); color: #fff; background: rgba(0, 0, 0, .12); }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--surface); }
.ext-icon { display: inline-flex; }

/* ---------- home: hero ---------- */

#view.view-home { padding: 0; }
#view.view-home > * { max-width: none; }

.hero {
  position: relative; height: 100vh; height: 100svh; min-height: 560px; overflow: hidden;
  background: #111; color: #fff; isolation: isolate;
}
.hero-slides, .hero-slide { position: absolute; inset: 0; margin: 0; }
.hero-slide { opacity: 0; transition: opacity 1.6s ease; }
/* no z-index here: the caption inside the active slide must sit above .hero-shade */
.hero-slide.is-active { opacity: 1; }
.hero-media { position: absolute; inset: 0; overflow: hidden; background: #1a1a1a; transform-origin: 50% 50%; }
.hero-media::before {
  content: ""; position: absolute; inset: -30px; background: var(--lqip) center / cover no-repeat;
  filter: blur(22px); transform: scale(1.05);
}
.hero-media picture, .hero-img { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-img { object-fit: cover; opacity: 0; transition: opacity .9s ease; }
.hero-img.loaded { opacity: 1; }
.hero-ph { background: linear-gradient(135deg, var(--g1), var(--g2)); }
.hero-ph::before { display: none; }
.hero-ph-name {
  position: absolute; right: 6%; bottom: 14%; font-family: var(--serif); font-weight: 600;
  font-size: clamp(64px, 14vw, 200px); line-height: 1; color: rgba(255, 255, 255, .16); letter-spacing: .08em;
}

/* Ken Burns: slow zoom / pan, four variants */
.hero-media.kb-run { animation: var(--kb) var(--kb-duration, 9s) linear both; }
.kb-0 { --kb: kb0; } .kb-1 { --kb: kb1; } .kb-2 { --kb: kb2; } .kb-3 { --kb: kb3; }
@keyframes kb0 { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.13) translate(-2%, -1.2%); } }
@keyframes kb1 { from { transform: scale(1.14) translate(2%, 1%); } to { transform: scale(1.03) translate(0, 0); } }
@keyframes kb2 { from { transform: scale(1.04) translate(1.8%, 0); } to { transform: scale(1.14) translate(-1.6%, -1%); } }
@keyframes kb3 { from { transform: scale(1.12) translate(-2%, 1%); } to { transform: scale(1.02) translate(1%, 0); } }

.hero-shade {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .62) 0%, rgba(0, 0, 0, .34) 45%, rgba(0, 0, 0, .08) 75%, rgba(0, 0, 0, 0) 90%),
    linear-gradient(0deg, rgba(0, 0, 0, .6) 0%, rgba(0, 0, 0, 0) 50%);
}
.hero-content {
  position: absolute; z-index: 3; left: var(--gut); right: var(--gut); bottom: max(16vh, 120px);
  max-width: 820px;
}
.hero-title { margin: 0; font-family: var(--serif); font-weight: 600; text-shadow: 0 2px 30px rgba(0, 0, 0, .25); }
.hero-title .tl { display: inline-block; }
.hero-title-main { display: block; font-size: clamp(42px, 7.2vw, 96px); line-height: 1.04; letter-spacing: -.01em; }
.hero-title-main:lang(zh-Hans) { letter-spacing: .04em; }
.hero-title-sub { display: block; margin-top: 12px; font-size: clamp(19px, 2.5vw, 32px); font-weight: 600; opacity: .88; letter-spacing: .02em; }
.hero-sub { text-shadow: 0 1px 12px rgba(0, 0, 0, .45); margin: 22px 0 30px; max-width: 46ch; font-size: clamp(16px, 1.5vw, 19px); line-height: 1.6; opacity: .92; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.hero-place {
  position: absolute; z-index: 3; left: var(--gut); bottom: calc(26px + env(safe-area-inset-bottom));
  font-size: 13px; letter-spacing: .06em; color: rgba(255, 255, 255, .86); text-shadow: 0 1px 8px rgba(0, 0, 0, .4);
}
.hero-place-zh { font-family: var(--serif); font-weight: 600; letter-spacing: .12em; }
.hero-place-en { text-transform: uppercase; font-size: 11.5px; letter-spacing: .14em; }

.hero-controls {
  position: absolute; z-index: 4; right: max(calc(16px + env(safe-area-inset-right)), calc((100% - var(--site-max)) / 2));
  bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 6px;
}
.hero-dots { display: flex; }
.hero-dot { width: 32px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.hero-dot::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: rgba(255, 255, 255, .5); transition: width .3s, background-color .3s; }
.hero-dot[aria-current="true"]::before { width: 22px; background: #fff; }
.hero-pause {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  border: 1px solid rgba(255, 255, 255, .5); border-radius: 50%; background: rgba(0, 0, 0, .18); color: #fff; cursor: pointer;
}
.hero-dot:focus-visible, .hero-pause:focus-visible, .hero-scroll:focus-visible { outline: 3px solid #fff; outline-offset: 2px; border-radius: 999px; }
.hero-scroll {
  position: absolute; z-index: 4; left: 50%; bottom: calc(8px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: 44px; height: 44px; border: 0; background: none; cursor: pointer;
}
.hero-scroll span {
  display: block; width: 12px; height: 12px; margin: 0 auto; border-right: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(45deg); animation: cue 2.4s ease-in-out infinite; opacity: .85;
}
@keyframes cue { 0%, 100% { transform: translateY(-3px) rotate(45deg); } 50% { transform: translateY(4px) rotate(45deg); } }

/* ---------- home: sections ---------- */

.home-section { padding: clamp(76px, 11vw, 150px) 0; }
.section-inner { max-width: var(--site-max); margin: 0 auto; padding: 0 var(--gut); }
@supports (width: max(1px, 2px)) { .section-inner { max-width: none; } }
.section-head { max-width: 760px; margin-bottom: 18px; }
.eyebrow-lg { margin: 0 0 14px; font-size: 13px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; color: var(--brand); }
.pair-title { margin: 0; font-family: var(--serif); font-weight: 600; }
.pt-main { display: block; font-size: clamp(36px, 5.2vw, 64px); line-height: 1.08; letter-spacing: -.01em; }
.pt-main:lang(zh-Hans) { letter-spacing: .03em; }
.pt-sub { display: block; margin-top: 10px; font-size: clamp(18px, 2.2vw, 26px); color: var(--muted); }
.section-intro { margin: 24px 0 0; max-width: 62ch; font-size: clamp(17px, 1.5vw, 19.5px); line-height: 1.7; color: var(--muted); }

.doors { background: var(--surface); }
.doors-group { margin-top: clamp(48px, 6vw, 80px); }
.group-heading { margin: 0 0 22px; font-family: var(--serif); font-size: clamp(22px, 2.4vw, 28px); font-weight: 600; }
.org-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 clamp(24px, 3vw, 44px); margin: 0; padding: 0; list-style: none; }
.org-card { padding: 26px 0 30px; border-top: 1px solid var(--border); }
.org-zh { display: block; font-family: var(--serif); font-size: clamp(26px, 2.6vw, 32px); font-weight: 600; line-height: 1.2; }
.org-en { display: block; margin-top: 6px; font-size: 16px; font-weight: 700; }
.org-place { display: block; margin-top: 6px; font-size: 12px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.org-text { margin: 12px 0 0; font-size: 15.5px; line-height: 1.65; color: var(--muted); }
.group-note { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.disclaimer { margin: clamp(40px, 5vw, 64px) 0 0; padding-top: 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

.jiayi-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(36px, 6vw, 96px); align-items: start; }
.portrait { position: relative; aspect-ratio: 4 / 5; border-radius: 26px; overflow: hidden; background: var(--surface-2); box-shadow: 0 30px 60px rgba(0, 0, 0, .12); }
.portrait-pic { position: absolute; inset: 0; background: var(--lqip) center / cover; }
.portrait-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait-ph {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(160deg, #efe7da 0%, #d8c8ad 100%); color: rgba(70, 48, 22, .55);
}
.portrait-ph-mark { font-family: var(--serif); font-size: clamp(90px, 12vw, 150px); font-weight: 600; line-height: 1; }
.portrait-ph-note { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.jiayi-text { padding-top: 8px; }
.tagline { margin: 16px 0 22px; font-family: var(--serif); font-size: clamp(19px, 2vw, 24px); font-weight: 600; }
.bio { margin: 0 0 16px; max-width: 62ch; font-size: 17.5px; line-height: 1.75; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0 18px; padding: 0; list-style: none; }
.facts li { padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 650; }
.edu { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; margin: 0 0 30px; color: var(--muted); font-size: 15px; }
.edu-label { font-size: 12px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.edu ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.jiayi-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 28px; }
.cta-col { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.cta-note { font-size: 13px; color: var(--muted); }
.qr { display: flex; align-items: center; gap: 12px; margin: 0; }
.qr img { width: 112px; height: 112px; padding: 6px; border: 1px solid var(--border); border-radius: 14px; background: #fff; image-rendering: crisp-edges; }
.qr figcaption { max-width: 9em; font-size: 13px; font-weight: 650; color: var(--muted); }
@media (max-width: 600px) { .qr { display: none; } }   /* on a phone, the button is the QR code */

/* ---------- course placeholder ---------- */

.course-page { max-width: 760px; padding: clamp(40px, 7vw, 90px) 0 30px; }
.course-page .page-title { font-size: clamp(36px, 5vw, 56px); font-weight: 600; margin-bottom: 14px; }
.soon-pill { display: inline-block; padding: 4px 14px; border-radius: 999px; background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); font-size: 13px; font-weight: 750; letter-spacing: .04em; }
.course-topics { margin: 34px 0 24px; }
.course-topics ul { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.course-topics li { padding: 14px 0; border-bottom: 1px solid var(--border); font-size: 17px; font-weight: 600; }
.course-page .hero-actions { margin-top: 26px; }

.foot .copy { margin-top: 10px; }

/* ---------- reveal on scroll ---------- */

html.js-reveal .reveal { opacity: 0; transform: translateY(26px); transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .2, 1); transition-delay: calc(var(--d, 0) * 90ms); }
html.js-reveal .reveal.in { opacity: 1; transform: none; }

/* ---------- responsive ---------- */

@media (max-width: 1060px) {
  .nav-burger {
    display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
    border: 1px solid rgba(127, 127, 127, .45); border-radius: 12px; background: transparent; color: inherit; cursor: pointer;
  }
  .nav-burger span, .nav-burger span::before, .nav-burger span::after { display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; transition: transform .25s, opacity .25s; }
  .nav-burger span { position: relative; }
  .nav-burger span::before, .nav-burger span::after { content: ""; position: absolute; left: 0; }
  .nav-burger span::before { top: -6px; }
  .nav-burger span::after { top: 6px; }
  body.nav-open .nav-burger span { background: transparent; }
  body.nav-open .nav-burger span::before { transform: translateY(6px) rotate(45deg); }
  body.nav-open .nav-burger span::after { transform: translateY(-6px) rotate(-45deg); }

  .nav-main {
    position: fixed; top: var(--nav-total); left: 0; right: 0; z-index: 39;
    max-height: calc(100vh - var(--nav-total)); max-height: calc(100dvh - var(--nav-total)); overflow-y: auto;
    padding: 10px var(--gut) calc(26px + env(safe-area-inset-bottom));
    background: var(--bg); color: var(--text); border-bottom: 1px solid var(--border); box-shadow: 0 24px 40px rgba(0, 0, 0, .12);
    opacity: 0; visibility: hidden; transform: translateY(-8px); transition: opacity .2s, transform .2s, visibility 0s .2s;
  }
  body.nav-open .nav-main { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .2s; }
  .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
  .nav-list > li { border-bottom: 1px solid var(--border); }
  .nav-link { width: 100%; justify-content: space-between; min-height: 56px; padding: 0 4px; font-size: 18px; border-radius: 0; }
  .nav-link:hover, .nav-link[aria-expanded="true"] { background: none; }
  .nav-list > li.is-active > .nav-link { box-shadow: none; color: var(--brand); }
  .nav-menu { position: static; min-width: 0; padding: 0 0 10px; border: 0; box-shadow: none; background: none; }
  .nav-menu-item { padding: 10px 12px; }
}

@media (max-width: 900px) {
  .org-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jiayi-grid { grid-template-columns: 1fr; }
  .portrait { max-width: 420px; }
}

@media (max-width: 600px) {
  :root { --nav-h: 58px; }
  .brand-name { font-size: 17px; }
  .lang-toggle { min-width: 44px; padding: 0 10px; }
  .topnav .settings { display: none; }
  body.is-learning .topnav .settings { display: block; }
  .hero { min-height: 520px; }
  .hero-content { bottom: max(14vh, 104px); }
  .hero-title-main { font-size: clamp(38px, 11vw, 52px); }
  .hero-sub { margin: 16px 0 24px; font-size: 16px; }
  .hero-actions .btn { min-height: 50px; padding: 0 22px; font-size: 16px; }
  .hero-place { bottom: calc(66px + env(safe-area-inset-bottom)); }
  .hero-controls { left: var(--gut); right: auto; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .hero-scroll { display: none; }
  .hero-media::before { background-image: var(--lqip-m, var(--lqip)); }
  .org-grid { grid-template-columns: 1fr; }
  .org-card { padding: 22px 0 24px; }
  .bio { font-size: 16.5px; }
  .portrait { max-width: none; aspect-ratio: 1 / 1; }
  .portrait-pic img { object-position: 50% 22%; }   /* square frame: keep the top of the head */
}

@media (prefers-reduced-motion: reduce) {
  .hero-slide, .hero-img { transition: none; }
  .hero-media.kb-run { animation: none; }
  .hero-scroll span { animation: none; }
  html.js-reveal .reveal { opacity: 1; transform: none; transition: none; }
  .btn { transition: none; }
  .btn:hover { transform: none; }
}

/* =====================================================================
   Practice: #/practice, practice sections on level pages, #/a1/listening (js/site/practice.js)
   ===================================================================== */

.nav-menu-sep {
  margin: 6px 12px 2px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.nav-menu-item[aria-current="page"] .nav-menu-label { color: var(--accent); }

.practice-page { padding-top: 6px; }
.pr-filters { display: flex; flex-wrap: wrap; gap: 12px 28px; margin: 18px 0 8px; }
.pr-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.pr-filter-label { font-size: 13px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pr-filter .chip { gap: 8px; }
.chip .soon-badge { background: var(--surface); }
.chip[aria-pressed="true"] .soon-badge { background: rgba(255, 255, 255, .22); color: inherit; }
.pr-count { margin: 6px 0 12px; color: var(--muted); font-size: 14.5px; font-variant-numeric: tabular-nums; }

.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--gap); margin: 12px 0; }
.pr-card {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 16px 18px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.pr-card:hover { border-color: var(--accent); }
.pr-card:hover .pr-title { color: var(--accent); }
.pr-card:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.pr-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pr-level {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 12.5px; font-weight: 800; letter-spacing: .03em;
}
.pr-type { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.pr-icon { display: inline-flex; flex: none; }
.pr-title { font-size: 19px; font-weight: 760; line-height: 1.25; overflow-wrap: anywhere; }
.pr-title-zh { margin-top: -4px; font-family: var(--font-zh); font-size: 16px; color: var(--muted); }
.pr-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: auto; padding-top: 6px; }
.pr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--muted); font-size: 13.5px; }
.pr-dur { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.pr-status {
  display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pr-status.is-done { background: var(--t3-bg); color: var(--t3); }
.pr-status.is-started { background: var(--t2-bg); color: var(--t2); }

.pr-empty { padding: 28px 20px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; color: var(--muted); }
.pr-empty p { margin: 0 0 14px; }
.pr-empty p:last-child { margin: 0; }

.pr-section { margin: 26px 0 8px; }
.pr-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; }
.pr-section-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 22px; font-weight: 780; }
.pr-section-title a { color: inherit; text-decoration: none; }
.pr-section-title a:hover { color: var(--accent); }
.pr-section-title .pr-icon svg { width: 20px; height: 20px; }
.pr-section-intro { margin: 4px 0 0; color: var(--muted); }
.pr-more { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; color: var(--accent); font-weight: 700; text-decoration: none; }
.pr-more:hover { text-decoration: underline; }
.pr-foot { margin: 8px 0 0; }

@media (max-width: 600px) {
  .pr-filters { gap: 12px; flex-direction: column; }
  .pr-filter-label { flex-basis: 100%; }
  .pr-card { padding: 14px 16px 12px; }
}
@media (prefers-reduced-motion: reduce) { .pr-card { transition: none; } }
