:root {
  color-scheme: light;
  --bg: #f7f7f0;
  --surface: #fffef9;
  --text: #233b33;
  --muted: #65736b;
  --accent: #176451;
  --soft: #e8eee5;
  --border: #dde2d7;
  --warm: #f2e5c9;
  --shadow: 0 8px 28px #233b3307;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14221d;
  --surface: #1d2e26;
  --text: #edf2e7;
  --muted: #adbcaf;
  --accent: #9ad6bc;
  --soft: #2b4235;
  --border: #3a4b40;
  --warm: #45412b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.6; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; touch-action: manipulation; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
button { border: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: -100px; left: 16px; padding: 12px; background: var(--surface); z-index: 10; color: var(--accent); }
.skip-link:focus { top: 12px; }
.site-header, main, footer { width: min(1120px, calc(100% - 64px)); margin: auto; }
.site-header { display: flex; justify-content: space-between; align-items: center; padding: 28px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.brand { text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 12px; font-size: 19px; font-weight: 750; letter-spacing: -.5px; }
.brand-mark { display: grid; place-items: center; background: var(--accent); color: var(--bg); width: 45px; height: 48px; border-radius: 13px 13px 13px 3px; font-size: 29px; font-weight: 500; }
.brand-subtitle { display: block; font-size: 11px; font-weight: 400; color: var(--muted); letter-spacing: .1px; }
.quiet-button { background: transparent; border: 1px solid var(--border); border-radius: 24px; min-height: 44px; padding: 8px 15px; font-size: 14px; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 40px; padding: 56px 0 48px; }
.eyebrow { font-size: 11px; letter-spacing: 2px; font-weight: 750; color: var(--accent); margin: 0 0 16px; }
h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(42px, 5.3vw, 66px); line-height: 1.08; letter-spacing: -2px; margin: 0 0 20px; }
h1 em { color: var(--accent); }
.intro-copy { font-size: 15px; color: var(--muted); margin: 0; }
.hello-card { width: 260px; flex-shrink: 0; background: var(--warm); padding: 26px; border-radius: 24px 24px 24px 5px; display: flex; align-items: center; flex-direction: column; transform: rotate(3deg); }
.hello-label { font-size: 9px; letter-spacing: 2px; opacity: .8; }
.hello-chinese { font-size: 70px; line-height: 1.5; letter-spacing: 8px; }
.hello-pinyin { font-size: 19px; }
.hello-english { font-size: 12px; margin-top: 17px; }
.book-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.language-label { font-size: 9px; font-weight: 700; letter-spacing: 1.3px; display: flex; flex-direction: column; gap: 3px; color: var(--muted); }
select { border: 0; background: transparent; color: var(--text); font-size: 17px; font-weight: 650; padding: 3px 24px 3px 0; max-width: 100%; }
option { background: var(--surface); color: var(--text); }
.offline-status { font-size: 11px; color: var(--accent); padding: 5px 11px; border: 1px solid var(--border); border-radius: 20px; text-align: center; }
.offline-status::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; }
.search-row { display: flex; gap: 12px; }
.search-box { display: flex; align-items: center; gap: 12px; padding: 0 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); flex: 1; min-width: 0; }
.search-box svg, .speak-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; flex-shrink: 0; }
.search-box svg { color: var(--muted); }
.search-box input { width: 100%; padding: 17px 0; border: 0; color: var(--text); background: transparent; font-size: 15px; min-width: 0; }
.search-box input::placeholder { color: var(--muted); opacity: 1; }
.favorites-filter { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 0 17px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.count-badge { border-radius: 6px; background: var(--soft); font-size: 11px; padding: 1px 6px; }
.favorites-filter[aria-pressed="true"] { border-color: var(--accent); background: var(--soft); color: var(--accent); }
.categories { display: flex; gap: 8px; overflow-x: auto; padding: 20px 3px 14px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.category-chip { white-space: nowrap; background: transparent; border: 1px solid var(--border); border-radius: 24px; padding: 10px 16px; font-size: 12px; min-height: 44px; }
.category-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.results-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 20px; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: -.6px; margin: 0; }
#result-count { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.help-text { font-size: 12px; color: var(--muted); margin: 3px 0 20px; }
.phrase-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.phrase-card { padding: 20px; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.card-topline { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px; }
.phrase-category { font-size: 9px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.save-button { background: transparent; color: var(--muted); font-size: 24px; width: 44px; height: 44px; margin: -10px -10px -4px 0; flex-shrink: 0; }
.save-button[aria-pressed="true"] { color: var(--accent); }
.phrase-english { font-size: 16px; font-weight: 550; margin: 9px 0 8px; }
.show-button { background: transparent; padding: 0; margin: 0 0 18px; text-align: left; width: 100%; }
.phrase-chinese { display: block; font-size: 29px; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; }
.phrase-pinyin { display: block; color: var(--accent); font-size: 14px; margin-top: 4px; overflow-wrap: anywhere; }
.speak-button { margin-top: auto; display: flex; align-items: center; gap: 7px; min-height: 44px; padding: 8px 12px; border-radius: 8px; color: var(--accent); background: var(--soft); font-size: 12px; }
.speak-button.speaking { background: var(--accent); color: var(--bg); }
.empty-state { text-align: center; padding: 50px 16px; color: var(--muted); }
.empty-state > span { font-size: 48px; }
.empty-state h3 { color: var(--text); margin: 0; }
.primary-button { background: var(--accent); color: var(--bg); border-radius: 10px; padding: 12px 20px; min-height: 48px; }
.notice { background: var(--soft); padding: 16px; font-size: 14px; border-radius: 10px; }
footer { padding: 40px 0 28px; margin-top: 40px; border-top: 1px solid var(--border); text-align: center; font-size: 11px; color: var(--muted); }
.footer-brand { font-family: Georgia, serif; font-style: italic; font-size: 23px; color: var(--text); }
footer p { margin: 8px 0; }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 24px; padding: 24px; width: min(850px, calc(100% - 24px)); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: #0c231bd9; }
.dialog-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.dialog-toolbar .eyebrow { margin: 0; }
.dialog-content { text-align: center; padding: 20px 8px; }
#dialog-chinese { font-size: clamp(42px, 8vw, 88px); line-height: 1.5; margin: 12px 0; overflow-wrap: anywhere; }
#dialog-pinyin { font-size: 23px; color: var(--accent); overflow-wrap: anywhere; }
#dialog-english { font-size: 22px; font-weight: 400; }
#dialog-speak { margin-top: 30px; }
@media (max-width: 850px) {
  .phrase-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hello-card { width: 210px; padding: 20px; }
}
@media (max-width: 580px) {
  .site-header, main, footer { width: calc(100% - 32px); }
  .site-header { padding: 18px 0; }
  .brand { font-size: 17px; gap: 9px; }
  .brand-subtitle { font-size: 9px; }
  .brand-mark { width: 38px; height: 42px; font-size: 25px; }
  #theme-toggle span { display: none; }
  .intro { padding: 34px 0; gap: 12px; }
  h1 { font-size: 42px; letter-spacing: -1.5px; }
  .intro-copy { font-size: 13px; }
  .hello-card { display: none; }
  .book-toolbar { gap: 8px; align-items: flex-end; }
  .language-label { font-size: 8px; letter-spacing: .7px; }
  select { font-size: 15px; }
  .offline-status { max-width: 125px; font-size: 10px; padding: 5px 8px; margin: 0 0 4px; }
  .search-row { gap: 8px; }
  .search-box { padding: 0 12px; gap: 8px; }
  .search-box input { font-size: 16px; }
  .favorites-filter { padding: 0 12px; font-size: 22px; gap: 4px; }
  .favorites-filter > span:not(.count-badge) { display: none; }
  .categories { margin-right: -16px; padding-right: 16px; }
  .results-heading { margin-top: 14px; }
  h2 { font-size: 20px; }
  .phrase-grid { grid-template-columns: 1fr; gap: 12px; }
  .phrase-card { padding: 18px 20px; }
  .phrase-chinese { font-size: 32px; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color .15s, color .15s; }
}
