:root {
  color-scheme: light;
  --paper: oklch(97% 0.012 58);
  --canvas: oklch(94% 0.016 58);
  --ink: oklch(25% 0.025 48);
  --muted: oklch(54% 0.023 55);
  --line: oklch(88% 0.026 45);
  --coral: oklch(62% 0.13 21);
  --coral-soft: oklch(93% 0.045 21);
  --rose: oklch(82% 0.07 22);
  --blue: oklch(62% 0.1 230);
  --green: oklch(59% 0.095 145);
  --violet: oklch(58% 0.075 290);
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 26px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans SC", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link:focus { position: fixed; top: 12px; left: 12px; z-index: 10; padding: 10px 14px; background: var(--paper); border-radius: var(--radius-sm); }

.app-shell { width: min(100%, 480px); min-height: 100dvh; margin: 0 auto; padding-bottom: max(20px, env(safe-area-inset-bottom)); background: var(--paper); box-shadow: 0 12px 50px rgba(59, 41, 33, .11); }
.site-header { display: flex; align-items: center; gap: 12px; padding: max(20px, env(safe-area-inset-top)) 22px 18px; }
.brand-mark { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 14px; background: var(--coral); color: white; font-family: ui-rounded, "Arial Rounded MT Bold", sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -.05em; transform: rotate(-7deg); }
.header-copy { flex: 1; min-width: 0; }
.eyebrow, .section-kicker, .field-label { margin: 0; color: var(--coral); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.header-copy h1 { margin: 1px 0 0; font-size: 20px; line-height: 1.15; letter-spacing: -.012em; }
.book-count { display: flex; align-items: baseline; gap: 3px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.book-count strong { color: var(--ink); font-size: 17px; font-variant-numeric: tabular-nums; }

.unit-nav { position: sticky; top: 0; z-index: 5; background: var(--paper); box-shadow: 0 1px 0 var(--line); }
.unit-tabs { display: flex; gap: 7px; overflow-x: auto; padding: 9px 22px 12px; scrollbar-width: none; }
.unit-tabs::-webkit-scrollbar { display: none; }
.unit-tab { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 700; white-space: nowrap; transition: background-color .16s ease, color .16s ease, transform .16s ease; }
.unit-tab[aria-selected="true"] { color: white; background: var(--coral); box-shadow: 0 3px 0 oklch(47% 0.105 21); }
.unit-tab:active { transform: scale(.96); }

.controls { display: flex; gap: 9px; padding: 18px 22px 0; }
.search-field { display: flex; align-items: center; flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: var(--radius-sm); background: white; box-shadow: inset 0 0 0 1px var(--line); }
.search-icon { margin: -5px 8px 0 1px; color: var(--muted); font-size: 28px; line-height: 1; }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.search-field input::placeholder { color: oklch(69% 0.015 50); }
.filter-button { min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: var(--coral-soft); color: var(--coral); font-size: 12px; font-weight: 800; white-space: nowrap; transition: transform .16s ease, background-color .16s ease; }
.filter-button[aria-pressed="true"] { background: var(--coral); color: white; }
.filter-button:active { transform: scale(.96); }

main { padding: 0 22px; }
.section-heading, .index-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.section-heading { margin: 24px 0 13px; }
.section-heading h2, .index-heading h2 { margin: 3px 0 0; font-size: 22px; line-height: 1.2; letter-spacing: -.012em; }
.result-count { margin-bottom: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.word-card { position: relative; overflow: hidden; padding: 22px; border-radius: var(--radius-lg); background: white; box-shadow: 0 3px 0 rgba(90, 58, 43, .06), 0 14px 32px rgba(90, 58, 43, .08); }
.word-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 7px; background: repeating-linear-gradient(90deg, var(--coral) 0 32px, var(--rose) 32px 64px, oklch(79% .057 225) 64px 96px, oklch(81% .065 145) 96px 128px); }
.card-topline { display: flex; align-items: center; justify-content: space-between; margin-top: 3px; }
.word-number { color: var(--coral); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.bold-badge { display: inline-flex; align-items: center; min-height: 27px; padding: 0 10px; border-radius: 999px; background: var(--coral-soft); color: oklch(47% .12 21); font-size: 11px; font-weight: 800; }
.bold-badge[hidden] { display: none; }
.word-main { padding: 25px 0 18px; }
.word-display { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 .24em; margin: 7px 0 10px; font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: clamp(38px, 10.8vw, 56px); font-weight: 800; line-height: 1.05; letter-spacing: -.045em; }
.word-token { display: inline-flex; white-space: nowrap; }
.word-display.long { font-size: clamp(28px, 8vw, 42px); }
.word-display.very-long { font-size: clamp(24px, 6.6vw, 34px); }
.word-token .letter.segment-0 { color: var(--blue); }
.word-token .letter.segment-1 { color: var(--green); }
.word-token .letter.segment-2 { color: var(--violet); }
.word-token .letter.segment-3 { color: var(--coral); }
.word-token .letter.punctuation { color: var(--ink); }
.ipa { margin: 0; color: oklch(39% .02 55); font-family: "Charis SIL", "Noto Sans", -apple-system, sans-serif; font-size: 20px; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; }
.ipa.compact { font-size: 17px; }
.ipa-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ipa-row .ipa { flex: 1; min-width: 0; }
.accent-actions { display: flex; flex: 0 0 auto; gap: 6px; }
.accent-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: oklch(92% .03 230); font-size: 21px; line-height: 1; transition: transform .16s ease, background-color .16s ease; }
.accent-button:last-child { background: oklch(94% .04 21); }
.accent-button:active { transform: scale(.96); }
.accent-button[data-playing="true"] { outline: 2px solid var(--blue); outline-offset: 2px; }
.accent-button:last-child[data-playing="true"] { outline-color: var(--coral); }
.accent-button:disabled { cursor: not-allowed; opacity: .45; }
.speak-button { flex: 0 0 auto; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; color: oklch(43% .1 230); background: oklch(91% .04 230); font-size: 12px; font-weight: 800; white-space: nowrap; transition: transform .16s ease, background-color .16s ease; }
.speak-button span { display: inline-block; margin-right: 2px; font-size: 10px; transform: translateY(-1px); }
.speak-button:active { transform: scale(.96); }
.speak-button[data-playing="true"] { color: white; background: var(--blue); }
.speak-button:disabled { cursor: not-allowed; opacity: .45; }
.phonics-section { padding: 17px 0 18px; border-top: 1px solid var(--line); }
.section-label-row { display: flex; align-items: center; gap: 8px; }
.section-label-row h4 { margin: 0; font-size: 13px; font-weight: 800; }
.section-label-row .example-speak { margin-left: auto; color: oklch(47% .12 21); background: oklch(91% .055 21); }
.section-label-row .example-speak[data-playing="true"] { color: white; background: var(--coral); }
.section-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: oklch(90% .04 230); color: oklch(45% .11 230); font-size: 14px; font-weight: 800; }
.section-icon.coral { background: var(--coral-soft); color: var(--coral); }
.spelling-parts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.part-chip { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 42px; min-height: 57px; padding: 6px 10px; border-radius: 9px; font-family: ui-rounded, "Arial Rounded MT Bold", sans-serif; line-height: 1; }
.part-chip.segment-0 { color: oklch(45% .11 230); background: oklch(92% .037 230); }
.part-chip.segment-1 { color: oklch(42% .1 145); background: oklch(92% .04 145); }
.part-chip.segment-2 { color: oklch(47% .085 290); background: oklch(93% .035 290); }
.part-chip.segment-3 { color: oklch(48% .12 21); background: var(--coral-soft); }
.part-letters { font-size: 21px; font-weight: 800; white-space: nowrap; }
.part-sound { margin-top: 5px; font-family: "Charis SIL", "Noto Sans", sans-serif; font-size: 12px; font-weight: 650; white-space: nowrap; }
.phonics-note { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.meaning-section { display: flex; align-items: flex-start; gap: 12px; padding: 15px 0 18px; border-top: 1px solid var(--line); }
.part-of-speech { display: inline-grid; place-items: center; flex: 0 0 auto; min-width: 47px; min-height: 27px; padding: 0 7px; border-radius: 7px; background: oklch(91% .015 55); color: oklch(44% .025 55); font-family: Georgia, serif; font-size: 13px; font-style: italic; font-weight: 700; }
.meaning { margin: -3px 0 0; font-size: 20px; font-weight: 700; line-height: 1.65; text-wrap: pretty; }
.example-section { margin: 0 -5px -4px; padding: 16px 16px 17px; border-radius: var(--radius-md); background: oklch(97% .025 21); }
.example-en { margin: 13px 0 3px; font-size: 20px; font-weight: 650; line-height: 1.45; text-wrap: pretty; }
.example-en mark { padding: 0; color: var(--coral); background: transparent; }
.example-zh { margin: 0; color: oklch(48% .025 48); font-size: 15px; line-height: 1.65; text-wrap: pretty; }
.speech-status { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.pager { display: flex; align-items: center; gap: 14px; margin: 18px 0 34px; }
.pager-button { display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px; border: 0; border-radius: 15px; color: var(--ink); background: white; box-shadow: 0 2px 0 var(--line); font-size: 34px; line-height: 1; transition: transform .16s ease, opacity .16s ease; }
.pager-button.next { color: white; background: var(--coral); box-shadow: 0 3px 0 oklch(47% .105 21); }
.pager-button:active { transform: scale(.96); }
.pager-button:disabled { cursor: not-allowed; opacity: .35; }
.pager-progress { flex: 1; text-align: center; }
.pager-progress span { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.progress-track { height: 5px; margin-top: 7px; overflow: hidden; border-radius: 999px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--coral); transition: width .2s ease; }

.word-index { padding-bottom: 24px; }
.index-heading { margin-bottom: 12px; }
.word-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.index-item { min-height: 48px; display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: white; color: var(--ink); text-align: left; font-size: 13px; font-weight: 700; transition: background-color .16s ease, transform .16s ease; }
.index-item[aria-current="true"] { background: var(--coral-soft); color: oklch(43% .11 21); }
.index-item:active { transform: scale(.98); }
.index-item .index-word { min-width: 0; overflow-wrap: anywhere; }
.key-dot { flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--coral); }
.empty-state { padding: 40px 16px 48px; text-align: center; }
.empty-state > span { color: var(--coral); font-size: 48px; }
.empty-state h3 { margin: 10px 0 5px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.site-footer { margin: 12px 22px 0; padding: 16px 0 max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.site-footer p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }

@media (min-width: 720px) {
  body { padding: 28px 0; }
  .app-shell { min-height: calc(100dvh - 56px); border-radius: 30px; overflow: clip; }
  .unit-nav { top: 0; }
}
@media (max-width: 359px) {
  .site-header { padding-inline: 16px; }
  .controls, main { padding-inline: 16px; }
  .unit-tabs { padding-inline: 16px; }
  .word-card { padding: 18px; }
  .word-display { font-size: clamp(34px, 10vw, 45px); }
  .meaning { font-size: 18px; }
  .speak-button { padding-inline: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media (hover: hover) {
  .unit-tab:not([aria-selected="true"]):hover, .index-item:not([aria-current="true"]):hover { background: var(--coral-soft); }
  .filter-button:hover { background: oklch(90% .055 21); }
  .filter-button[aria-pressed="true"]:hover { background: oklch(58% .13 21); }
}
