:root {
  --bg: #faf6ed;
  --bg-elev: #fffdf7;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --ink-faint: #78716c;
  --line: #e7e2d4;
  --line-soft: #efe9da;

  --op: #b45309;        /* Operations - terracotta */
  --op-bg: #fef3c7;
  --gt: #166534;        /* General Things - forest */
  --gt-bg: #dcfce7;
  --pt: #a16207;        /* Picturable - amber */
  --pt-bg: #fef9c3;
  --qg: #1e40af;        /* Qualities General - blue */
  --qg-bg: #dbeafe;
  --qo: #7c3aed;        /* Opposites - plum */
  --qo-bg: #ede9fe;

  --serif: 'Cormorant Garamond', 'Noto Serif SC', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --zh-serif: 'Noto Serif SC', 'Songti SC', 'Source Han Serif SC', serif;
}

/* ====== THEME: LEAF (teal + gold, inspired by v1.html) ====== */
html.theme-leaf {
  --bg: #ffffff;
  --bg-elev: #F7F7F5;
  --ink: #222;
  --ink-soft: #666;
  --ink-faint: #999;
  --line: #ecece8;
  --line-soft: #f2f2ee;

  --op: #12C48D;
  --op-bg: #dff7ef;
  --gt: #6366f1;
  --gt-bg: #eef2ff;
  --pt: #f43f5e;
  --pt-bg: #fff1f2;
  --qg: #3b82f6;
  --qg-bg: #e8f0fe;
  --qo: #8b5cf6;
  --qo-bg: #efe8fe;
}
html.theme-leaf .hero {
  background: linear-gradient(180deg, #dff7ef 0%, var(--bg) 100%);
}
html.theme-leaf .nav {
  background: rgba(255, 255, 255, 0.92);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  transition: background-color .25s, color .25s;
  line-height: 1.6;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

/* ====== HEADER ====== */
.hero {
  background: linear-gradient(180deg, #f5efe0 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  padding: 64px 32px 40px;
  text-align: center;
  transition: background .25s, border-color .25s;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 56px;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 8px;
}
.hero h1 em {
  font-style: italic;
  color: var(--op);
}
.hero .subtitle {
  font-family: var(--zh-serif);
  font-size: 18px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.hero .meta {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 12px;
}
.hero-author {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 8px;
}
.hero-author a {
  color: var(--op);
  text-decoration: none;
  font-weight: 500;
}
.hero-author a:hover {
  text-decoration: underline;
}

/* ====== STICKY NAV ====== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 246, 237, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  transition: background .25s, border-color .25s;
}
.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.search {
  flex: 1;
  min-width: 220px;
  position: relative;
}
.search input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px 10px 40px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus {
  border-color: var(--op);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.12);
}
button:focus-visible, .pill:focus-visible, .syn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
button.pill {
  appearance: none;
  -webkit-appearance: none;
}
.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
}
.search kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-faint);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
  line-height: 1;
}
.search kbd svg { display: block; }

.pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pill {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  white-space: nowrap;
}
.pill:hover { background: #fff; border-color: var(--ink-faint); }
.pill.active[data-cat="op"] { background: var(--op); color: #fff; border-color: var(--op); }
.pill.active[data-cat="gt"] { background: var(--gt); color: #fff; border-color: var(--gt); }
.pill.active[data-cat="pt"] { background: var(--pt); color: #fff; border-color: var(--pt); }
.pill.active[data-cat="qg"] { background: var(--qg); color: #fff; border-color: var(--qg); }
.pill.active[data-cat="qo"] { background: var(--qo); color: #fff; border-color: var(--qo); }
.pill.active[data-cat="all"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill .count {
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}

/* ====== CONTENT ====== */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
}

.section {
  margin-top: 56px;
  scroll-margin-top: 80px;
}
.section:first-child { margin-top: 32px; }

.section-header {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  transition: background-color .2s, border-color .2s;
}
.section-header h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 36px;
  letter-spacing: -0.01em;
}
.section-header .zh {
  font-family: var(--zh-serif);
  font-size: 18px;
  color: var(--ink-soft);
}
.section-header .count {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 16px;
  transition: background-color .2s, border-color .15s, transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.card:hover {
  border-color: var(--ink-faint);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(28, 25, 23, 0.06);
}
.card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}
.card[data-cat="op"]::before { background: var(--op); }
.card[data-cat="gt"]::before { background: var(--gt); }
.card[data-cat="pt"]::before { background: var(--pt); }
.card[data-cat="qg"]::before { background: var(--qg); }
.card[data-cat="qo"]::before { background: var(--qo); }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.word {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.1;
}
button.word, button.sp-word, button.sp-main, button.flash-back-syn {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: 0;
}
button.word:hover, button.sp-word:hover, button.sp-main:hover {
  color: var(--op);
}
.tag {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background-color .2s, color .2s;
}
.card[data-cat="op"] .tag { background: var(--op-bg); color: var(--op); }
.card[data-cat="gt"] .tag { background: var(--gt-bg); color: var(--gt); }
.card[data-cat="pt"] .tag { background: var(--pt-bg); color: var(--pt); }
.card[data-cat="qg"] .tag { background: var(--qg-bg); color: var(--qg); }
.card[data-cat="qo"] .tag { background: var(--qo-bg); color: var(--qo); }

.def-zh {
  font-family: var(--zh-serif);
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 4px;
  font-weight: 500;
}
.def-en {
  margin-bottom: 12px;
}
.def-en-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  line-height: 1.2;
  margin-bottom: 3px;
}
.def-en-label em {
  font-style: italic;
  font-weight: 400;
  opacity: 0.72;
  margin-left: 4px;
}
.def-en-body {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-faint);
  font-style: italic;
  line-height: 1.4;
}

.core-sense {
  margin: 8px 0 11px;
  padding: 7px 0 8px;
  border-top: 1px dashed var(--line-soft);
  border-bottom: 1px dashed var(--line-soft);
}
.core-sense-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  line-height: 1.2;
  margin-bottom: 3px;
}
.core-sense-label em {
  font-style: italic;
  font-weight: 400;
  opacity: 0.72;
  margin-left: 4px;
}
.core-sense-text {
  font-family: var(--zh-serif);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.example {
  background: rgba(180, 83, 9, 0.04);
  border-left: 2px solid var(--line);
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 10px;
  transition: background-color .2s, border-color .2s;
}
.card[data-cat="op"] .example { border-left-color: var(--op); background: rgba(180, 83, 9, 0.04); }
.card[data-cat="gt"] .example { border-left-color: var(--gt); background: rgba(22, 101, 52, 0.04); }
.card[data-cat="pt"] .example { border-left-color: var(--pt); background: rgba(161, 98, 7, 0.04); }
.card[data-cat="qg"] .example { border-left-color: var(--qg); background: rgba(30, 64, 175, 0.04); }
.card[data-cat="qo"] .example { border-left-color: var(--qo); background: rgba(124, 58, 237, 0.04); }

.example .en {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.4;
}
.example .zh {
  font-family: var(--zh-serif);
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
  line-height: 1.4;
}

.syns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.syn {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  font-weight: 500;
}
.syn:hover {
  background: #fff;
  border-color: var(--ink-faint);
  color: var(--ink);
}
.card[data-cat="op"] .syn.active { background: var(--op); color: #fff; border-color: var(--op); }
.card[data-cat="gt"] .syn.active { background: var(--gt); color: #fff; border-color: var(--gt); }
.card[data-cat="pt"] .syn.active { background: var(--pt); color: #fff; border-color: var(--pt); }
.card[data-cat="qg"] .syn.active { background: var(--qg); color: #fff; border-color: var(--qg); }
.card[data-cat="qo"] .syn.active { background: var(--qo); color: #fff; border-color: var(--qo); }

.syn-panel {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  animation: fadeIn .18s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}
.syn-panel-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}
.sp-word {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}
.sp-main {
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  color: var(--ink-soft);
}
.sp-vs {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.sp-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12.5px;
  line-height: 1.45;
}
.sp-row:last-child { margin-bottom: 0; }
.sp-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  flex-shrink: 0;
  width: 28px;
  padding-top: 2px;
}
.card[data-cat="op"] .sp-label { color: var(--op); }
.card[data-cat="gt"] .sp-label { color: var(--gt); }
.card[data-cat="pt"] .sp-label { color: var(--pt); }
.card[data-cat="qg"] .sp-label { color: var(--qg); }
.card[data-cat="qo"] .sp-label { color: var(--qo); }
.sp-val {
  font-family: var(--zh-serif);
  color: var(--ink);
  flex: 1;
}
.sp-empty {
  font-family: var(--zh-serif);
  font-size: 12px;
  color: var(--ink-faint);
  font-style: italic;
}

/* ====== SPEAK BUTTONS ====== */
.speak {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  transition: all .15s;
  vertical-align: middle;
  flex-shrink: 0;
}
.speak:hover { background: var(--bg); color: var(--ink); }
.card[data-cat="op"] .speak:hover { color: var(--op); }
.card[data-cat="gt"] .speak:hover { color: var(--gt); }
.card[data-cat="pt"] .speak:hover { color: var(--pt); }
.card[data-cat="qg"] .speak:hover { color: var(--qg); }
.card[data-cat="qo"] .speak:hover { color: var(--qo); }
.speak svg { width: 14px; height: 14px; pointer-events: none; }
.speak.playing { animation: pulse 1.2s ease-in-out infinite; }
.card[data-cat="op"] .speak.playing { color: var(--op); background: var(--op-bg); }
.card[data-cat="gt"] .speak.playing { color: var(--gt); background: var(--gt-bg); }
.card[data-cat="pt"] .speak.playing { color: var(--pt); background: var(--pt-bg); }
.card[data-cat="qg"] .speak.playing { color: var(--qg); background: var(--qg-bg); }
.card[data-cat="qo"] .speak.playing { color: var(--qo); background: var(--qo-bg); }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.18); opacity: 0.7; }
}
.example { position: relative; padding-right: 32px; }
.example .speak {
  position: absolute;
  top: 6px;
  right: 4px;
  background: rgba(255,255,255,0.6);
}
.word-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.flag-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px;
  color: var(--ink-faint);
  transition: color .15s;
  flex-shrink: 0;
}
.flag-btn:hover { color: var(--ink); }

/* ====== AUDIO SOURCE TOGGLE ====== */
.engine-toggle,
.audio-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  font-family: var(--sans);
  font-size: 11px;
  gap: 2px;
}
.engine-toggle button,
.audio-toggle button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 500;
  transition: all .15s;
  font-family: inherit;
  white-space: nowrap;
}
.engine-toggle button:hover,
.audio-toggle button:hover { color: var(--ink); }
.engine-toggle button.active,
.audio-toggle button.active {
  background: var(--ink);
  color: #fff;
}

/* ====== EMPTY / FOOTER ====== */
.empty {
  text-align: center;
  padding: 80px 32px;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  display: none;
}
.empty.show { display: block; }

footer {
  max-width: 1280px;
  margin: 64px auto 0;
  padding: 32px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
  font-family: var(--sans);
  letter-spacing: 0.05em;
}
footer a { color: var(--op); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ====== PRINT ====== */
@media print {
  .nav, .hero .meta { display: none; }
  body { background: white; }
  .card { break-inside: avoid; border: 1px solid #ddd; box-shadow: none; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .hero { padding: 48px 20px 32px; }
  .hero h1 { font-size: 38px; }
  main { padding: 20px; }
  .nav { padding: 12px 16px; }
  .nav-inner { gap: 10px; }
  .search { min-width: 100%; order: -1; }
  .pills { overflow-x: auto; flex-wrap: nowrap; width: 100%; padding-bottom: 2px; }
  .pill { min-height: 36px; display: inline-flex; align-items: center; }
  .section-header h2 { font-size: 26px; }
  .grid { grid-template-columns: 1fr; }
  .hans-toggle button,
  .engine-toggle button,
  .audio-toggle button { min-height: 34px; min-width:35px}
  .flash-topbar { padding: 10px 14px; }
  .flash-topbar-btns button { min-height: 40px; padding: 7px 12px; }
  .flash-cat-nav { padding: 8px 14px; }
  .flash-cat-pills .pill { min-height: 34px; }
  .flash-stage { padding: 12px 16px; align-items: stretch; }
  .flash-card-wrap {
    max-width: 100%;
    height: min(430px, calc(100dvh - 224px));
    min-height: 310px;
    align-self: center;
  }
  .flash-face { padding: 22px; border-radius: 14px; }
  .flash-word-big { font-size: clamp(44px, 18vw, 70px); }
  .flash-nav { max-width: none; padding: 0 16px 14px; }
  .flash-nav-btn { min-height: 44px; padding: 9px 14px; }
  .flash-hint-key { display: none; }
}

@media (pointer: coarse) {
  .speak { width: 34px; height: 34px; margin-left: 0; }
  .speak-inline { width: 30px; height: 30px; }
  .syn { min-height: 34px; display: inline-flex; align-items: center; }
  button.word, button.sp-word, button.sp-main, button.flash-back-syn { min-height: 34px; }
}

/* ====== INLINE SPEAK BUTTON ====== */
.speak-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink-faint);
  opacity: 0.55;
  transition: opacity .15s, color .15s;
  vertical-align: middle;
  margin-right: 3px;
  padding: 0;
  border-radius: 3px;
  flex-shrink: 0;
}
.speak-inline:hover { opacity: 1; color: var(--ink); }
.speak-inline.playing { opacity: 1; animation: pulse 1.2s ease-in-out infinite; }
.speak-inline svg { width: 11px; height: 11px; pointer-events: none; }
/* ====== SYNS HEADER ====== */
.syns-header {
  font-size: 10px;
  font-family: var(--sans);
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 8px 0 4px;
}
.syns-header em { font-style: italic; font-weight: 400; opacity: 0.7; margin-left: 4px; text-transform: none; }

/* ====== SYN PANEL BADGE ====== */
.sp-badge {
  font-size: 10px;
  font-family: var(--sans);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.sp-label { min-width: 52px; font-size: 10px; letter-spacing: 0.04em; }
.sp-label em { font-style: normal; display: block; font-size: 9px; opacity: 0.6; margin-top: 1px; }

/* ====== IPA PHONETICS ====== */
.ipa {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  min-height: 14px;
  margin-top: 1px;
  font-style: italic;
}

/* ====== TOOLBAR EXTRA BUTTONS ====== */
.hans-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  font-family: var(--sans);
  font-size: 11px;
  gap: 2px;
}
.hans-toggle button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 500;
  transition: all .15s;
  font-family: inherit;
  white-space: nowrap;
}
.hans-toggle button:hover { color: var(--ink); }
.hans-toggle button.active { background: var(--ink); color: #fff; }
.flash-btn {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: var(--sans);
  transition: all .15s;
  white-space: nowrap;
  line-height: 1.6;
}
.flash-btn:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.flash-btn svg {
  width: 12px;
  height: 12px;
  margin-right: 5px;
  vertical-align: -2px;
}

/* ====== FLASH CARD OVERLAY ====== */
.flash-overlay {
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.flash-overlay[hidden] { display: none; }
.flash-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.flash-progress { font-size: 13px; color: var(--ink-faint); font-family: var(--sans); font-variant-numeric: tabular-nums; }
.flash-topbar-btns { display: flex; gap: 8px; }
.flash-topbar-btns button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--sans);
  transition: all .15s;
}
.flash-topbar-btns button:hover { color: var(--ink); border-color: var(--ink-faint); }
.flash-topbar-btns button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.flash-topbar-btns svg { width: 13px; height: 13px; margin-right: 5px; vertical-align: -2px; }
.flash-close-btn { color: #f87171 !important; border-color: #f87171 !important; }
.flash-close-btn:hover { background: #ef4444 !important; color: #fff !important; }

.flash-cat-nav {
  width: 100%;
  border-bottom: 1px solid var(--line);
  padding: 10px 20px 11px;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.flash-cat-pills {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: max-content;
}
.flash-cat-pills .pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
  position: relative;
  overflow: hidden;
}
.flash-cat-pills .pill::before {
  content: '';
  position: absolute;
  inset: 0;
  width: calc(var(--pct, 0) * 1%);
  background: currentColor;
  opacity: 0.1;
  border-radius: inherit;
  pointer-events: none;
  transition: width .3s;
}
.flash-cat-pills .pill.active::before {
  background: var(--bg);
  opacity: 0.12;
}
.flash-cat-pills .pill:hover {
  background: var(--bg-elev);
  color: var(--ink);
  border-color: var(--ink-faint);
}
.flash-cat-pills .pill.active[data-cat="all"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.flash-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 20px 24px;
  perspective: 1200px;
  min-height: 0;
}
.flash-card-wrap {
  width: 100%;
  max-width: 460px;
  height: 390px;
  position: relative;
}
.flash-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(.4,.2,.2,1);
}
.flash-card-wrap.flipped .flash-card-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  box-sizing: border-box;
}
.flash-front { background: var(--bg-elev); border: 1px solid var(--line); }
.flash-front { cursor: pointer; }
.flash-card-wrap:focus { outline: none; }
.flash-back {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  transform: rotateY(180deg);
  align-items: flex-start;
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  cursor: default;
}
.flash-word-big {
  font-family: var(--serif);
  font-size: clamp(36px,10vw,64px);
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  line-height: 1;
}
button.flash-word-big {
  border: 0;
  background: transparent;
  cursor: pointer;
}
button.flash-word-big:hover { color: var(--ink-soft); }
.flash-cat-badge { margin-top: 10px; font-size: 11px; color: var(--ink-faint); letter-spacing: 0.08em; text-transform: uppercase; font-family: var(--sans); }
.flash-tap-hint { position: absolute; bottom: 18px; font-size: 11px; color: var(--ink-faint); font-family: var(--sans); }
.flash-flip-btn, .flash-back-flip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-family: var(--sans);
  cursor: pointer;
  transition: all .15s;
}
.flash-flip-btn {
  position: absolute;
  bottom: 28px;
}
.flash-flip-btn:hover, .flash-back-flip:hover { color: var(--ink); border-color: var(--ink-faint); }
.flash-back-flip {
  color: var(--ink-soft);
  border-color: var(--line);
  margin-top: auto;
}
.flash-back-flip:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
  background: var(--bg);
}
.flash-back-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: auto;
}
.flash-back-star {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-faint);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  font-size: 14px;
  flex-shrink: 0;
}
.flash-back-star:hover { color: var(--ink); border-color: var(--ink-faint); }
.flash-back-star[aria-label="取消标记"] { color: #f59e0b; border-color: #f59e0b40; }
.flash-speak-front { position: absolute; top: 14px; right: 14px; background: transparent; border: 1px solid var(--line); color: var(--ink-faint); border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s; }
.flash-speak-front:hover { color: var(--ink); border-color: var(--ink-faint); }
.flash-speak-front svg { width: 13px; height: 13px; pointer-events: none; }
.flash-flag-btn { position: absolute; top: 14px; left: 14px; background: transparent; border: 1px solid var(--line); color: var(--ink-faint); border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s; font-size: 14px; }
.flash-flag-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.flash-flag-btn[aria-label="取消标记"] { color: #f59e0b; border-color: #f59e0b40; }

.flash-back-word { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--ink); margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.flash-back-ipa { font-size: 11px; color: var(--ink-faint); margin-bottom: 10px; font-style: italic; }
.flash-back-zh { font-size: 17px; color: var(--ink); font-family: var(--serif); margin-bottom: 4px; font-weight: 500; }
.flash-back-core {
  border-top: 1px dashed var(--line-soft);
  border-bottom: 1px dashed var(--line-soft);
  padding: 7px 0;
  margin-bottom: 9px;
  color: var(--ink-soft);
  font-family: var(--zh-serif);
  font-size: 12px;
  line-height: 1.45;
}
.flash-back-core span {
  display: block;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.flash-back-def { margin-bottom: 10px; }
.flash-back-def-label {
  display: block;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.flash-back-def-label em {
  font-style: italic;
  font-weight: 400;
  opacity: 0.72;
  margin-left: 4px;
}
.flash-back-en { font-size: 12px; color: var(--ink-soft); line-height: 1.5; display: flex; align-items: flex-start; gap: 2px; }
.flash-back-ex {
  font-size: 12px; color: var(--ink-soft);
  background: var(--bg); border-left: 3px solid var(--line);
  padding: 7px 10px; border-radius: 0 6px 6px 0;
  margin-bottom: 10px; line-height: 1.5; width: 100%; box-sizing: border-box;
}
.flash-back-syns { display: flex; gap: 5px; flex-wrap: wrap; }
.flash-back-syn { font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--ink-faint); }
button.flash-back-syn:hover { color: var(--ink); border-color: var(--ink-faint); background: var(--bg-elev); }

.flash-nav {
  width: 100%;
  max-width: 460px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
.flash-nav-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--sans);
  transition: all .15s;
  flex: 1;
}
.flash-nav-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.flash-nav-btn:disabled { opacity: 0.3; cursor: default; }
.flash-counter { font-size: 12px; color: var(--ink-faint); text-align: center; min-width: 64px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.flash-hint-key { font-size: 10px; color: var(--ink-faint); text-align: center; padding-bottom: 8px; font-family: var(--sans); }

/* ====== THEME FADE OVERLAY ====== */
.theme-fade {
  position: fixed;
  inset: 0;
  z-index: 10001;
  pointer-events: none;
  opacity: 0.82;
  background: #000;
  will-change: opacity;
  transform: translateZ(0);
}
.theme-fade.out {
  opacity: 0;
  transition: opacity .08s cubic-bezier(.22,.61,.36,1);
}
@media (prefers-reduced-motion: reduce) {
  .theme-fade.out { transition-duration: 1ms; }
}

/* ====== DARK MODE ====== */
html.dark {
  --bg: #100f0d;
  --bg-elev: #1c1917;
  --ink: #e7e2d4;
  --ink-soft: #a8a29e;
  --ink-faint: #57534e;
  --line: #3a3835;
  --line-soft: #2a2826;

  --op-bg: #2a1f0a;
  --gt-bg: #0a1f12;
  --pt-bg: #1f1a0a;
  --qg-bg: #0a142f;
  --qo-bg: #1a0a2f;
}
html.dark .hero {
  background: linear-gradient(180deg, #1c1917 0%, var(--bg) 100%);
}
html.dark .nav {
  background: rgba(16, 15, 13, 0.92);
}
html.dark .pill:hover { background: var(--bg-elev); border-color: var(--ink-faint); }
html.dark .search kbd { background: var(--bg-elev); }
html.dark .card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
html.dark .example {
  background: rgba(180, 83, 9, 0.08);
  border-left-color: var(--line);
}
html.dark .card[data-cat="op"] .example { background: rgba(180, 83, 9, 0.08); }
html.dark .card[data-cat="gt"] .example { background: rgba(22, 101, 52, 0.08); }
html.dark .card[data-cat="pt"] .example { background: rgba(161, 98, 7, 0.08); }
html.dark .card[data-cat="qg"] .example { background: rgba(30, 64, 175, 0.08); }
html.dark .card[data-cat="qo"] .example { background: rgba(124, 58, 237, 0.08); }
html.dark .syn { background: var(--bg-elev); }
html.dark .syn:hover { background: #2a2826; border-color: var(--ink-faint); }
html.dark .speak:hover { background: #2a2826; }
html.dark .speak-inline { opacity: 0.7; }
html.dark .example .speak { background: rgba(28, 25, 23, 0.6); }
html.dark .syn-panel { background: var(--bg-elev); }
html.dark .flash-btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
html.dark .engine-toggle button.active,
html.dark .audio-toggle button.active,
html.dark .hans-toggle button.active,
html.dark .pill.active[data-cat="all"] { color: #100f0d; }
html.dark .dark-toggle svg { transition: transform .3s; }
html.dark .dark-toggle .moon-icon { display: block; }
html.dark .dark-toggle .sun-icon { display: none; }

/* ====== THEME: LEAF DARK ====== */
html.theme-leaf.dark {
  --bg: #111;
  --bg-elev: #1a1a1a;
  --ink: #d4d0c5;
  --ink-soft: #999;
  --ink-faint: #555;
  --line: #2a2a2a;
  --line-soft: #222;

  --op-bg: #0a2a1e;
  --gt-bg: #062018;
  --pt-bg: #2a2210;
  --qg-bg: #0a1630;
  --qo-bg: #1a0a30;
}
html.theme-leaf.dark .hero {
  background: linear-gradient(180deg, #1a1a1a 0%, var(--bg) 100%);
}
html.theme-leaf.dark .nav {
  background: rgba(17, 17, 17, 0.92);
}
html.theme-leaf.dark .engine-toggle button.active,
html.theme-leaf.dark .audio-toggle button.active,
html.theme-leaf.dark .hans-toggle button.active,
html.theme-leaf.dark .pill.active[data-cat="all"] { color: #111; }
.dark-toggle,
.theme-toggle {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-faint);
  transition: all .15s;
  padding: 0;
  flex-shrink: 0;
}
.dark-toggle:hover,
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-faint); }
.dark-toggle svg,
.theme-toggle svg { width: 15px; height: 15px; pointer-events: none; }
.dark-toggle .moon-icon { display: none; }
.theme-toggle .leaf-icon { display: none; }
html.theme-leaf .theme-toggle .default-icon { display: none; }
html.theme-leaf .theme-toggle .leaf-icon { display: block; }

/* ====== DOWNLOAD PANEL ====== */
.dl-btn,
.dy-btn,
.xbt-btn,
.about-btn {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-faint);
  transition: all .15s;
  padding: 0;
  flex-shrink: 0;
}
.dl-btn:hover,
.dy-btn:hover,
.xbt-btn:hover,
.about-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.dl-btn svg,
.dy-btn svg,
.about-btn svg { width: 15px; height: 15px; pointer-events: none; }
html.dark .dl-btn:hover,
html.dark .dy-btn:hover,
html.dark .xbt-btn:hover,
html.dark .about-btn:hover { color: var(--bg); border-color: var(--ink-faint); }
.dl-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.dl-overlay[hidden] { display: none; }
.dl-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: 520px; max-width: 90vw;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
  overflow: hidden;
}
.dl-topbar {
  display: flex; align-items: baseline; gap: 10px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.dl-title { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--ink); }
.dl-subtitle { font-size: 12px; color: var(--ink-faint); font-family: var(--sans); flex: 1; }
.dl-close {
  background: none; border: none; font-size: 22px; color: var(--ink-faint);
  cursor: pointer; line-height: 1; padding: 0 4px;
}
.dl-close:hover { color: var(--ink); }
.dl-body {
  padding: 16px 24px 20px;
  overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 10px;
}
.dl-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  transition: all .15s;
}
.dl-card.unavail { opacity: .45; }
.dl-card.current { border-color: var(--op); background: var(--op-bg); }
.dl-card-icon { font-size: 28px; width: 40px; text-align: center; flex-shrink: 0; }
.dl-card-info { flex: 1; min-width: 0; }
.dl-card-name { font-size: 14px; font-weight: 600; color: var(--ink); font-family: var(--sans); }
.dl-card-name small { font-weight: 400; color: var(--ink-faint); font-size: 11px; margin-left: 6px; }
.dl-card-size { font-size: 11px; color: var(--ink-faint); font-family: var(--sans); margin-top: 2px; }
.dl-card-btn {
  flex-shrink: 0;
  padding: 6px 16px; border-radius: 999px; border: 1px solid var(--ink);
  background: transparent; color: var(--ink);
  font-size: 12px; font-family: var(--sans); font-weight: 500;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.dl-card-btn:hover { background: var(--ink); color: var(--bg); }
.dl-card-btn.disabled { opacity: .35; cursor: default; pointer-events: none; }
.dl-card-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.dl-card-btn-secondary {
  flex-shrink: 0;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--ink);
  background: transparent; color: var(--ink);
  font-size: 12px; font-family: var(--sans); font-weight: 500;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.dl-card-btn-secondary:hover { background: var(--ink); color: var(--bg); }
.dl-note {
  padding: 8px 24px 4px;
  font-size: 11px; color: var(--ink-faint); font-family: var(--sans); line-height: 1.5;
}
.dl-note strong { color: var(--ink-soft); }
.dl-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 24px; border-top: 1px solid var(--line);
  font-size: 11px; font-family: var(--sans); flex-shrink: 0;
}
.dl-footer a { color: var(--op); text-decoration: none; }
.dl-footer a:hover { text-decoration: underline; }
#dl-detected { color: var(--ink-faint); }

/* ====== DOUYIN QR POPUP ====== */
.dy-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.dy-overlay[hidden] { display: none; }
.dy-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  text-align: center;
  position: relative;
  max-width: 320px;
  width: 90vw;
  box-shadow: 0 24px 48px rgba(0,0,0,0.15);
}
.dy-close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; font-size: 24px;
  color: var(--ink-faint); cursor: pointer; line-height: 1;
}
.dy-close:hover { color: var(--ink); }
.dy-title {
  font-family: var(--serif);
  font-size: 18px; font-weight: 600; color: var(--ink);
  margin-bottom: 4px;
}
.dy-sub {
  font-size: 12px; color: var(--ink-faint);
  font-family: var(--sans); margin-bottom: 18px;
}
.dy-qr {
  display: block; margin: 0 auto 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  image-rendering: pixelated;
}
.dy-id {
  font-size: 12px; color: var(--ink-soft);
  font-family: var(--sans);
}

/* ====== ABOUT PANEL ====== */
.about-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.about-overlay[hidden] { display: none; }
.about-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px;
  position: relative;
  max-width: 640px;
  width: 90vw;
  max-height: 80vh;
  box-shadow: 0 24px 48px rgba(0,0,0,0.15);
}
.about-close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; font-size: 24px;
  color: var(--ink-faint); cursor: pointer; line-height: 1; z-index: 1;
}
.about-close:hover { color: var(--ink); }
.about-scroll {
  overflow-y: auto; max-height: calc(80vh - 72px);
  padding-right: 8px;
}
.about-scroll::-webkit-scrollbar { width: 4px; }
.about-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.about-zh {
  font-family: var(--sans); font-size: 14px; line-height: 1.8;
  color: var(--ink); margin-bottom: 2px;
}
.about-en {
  font-family: var(--sans); font-size: 13px; line-height: 1.7;
  color: var(--ink-faint); margin-bottom: 16px;
}
.about-list {
  margin: 8px 0 16px; padding: 0 0 0 18px;
  font-family: var(--sans); font-size: 13px; line-height: 1.8;
  color: var(--ink-soft);
}
.about-list li { margin-bottom: 2px; }
.about-list strong { color: var(--op); }
.about-list em { font-style: italic; }
.about-hl {
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  color: var(--ink); text-align: center; margin: 8px 0 2px;
}
.about-hl-en {
  text-align: center; margin-bottom: 0;
}

@media (max-width: 640px) {
  .dark-toggle,
  .theme-toggle,
  .dl-btn,
  .dy-btn,
  .xbt-btn,
  .about-btn { width: 36px; height: 36px; }
  .dark-toggle svg,
  .theme-toggle svg,
  .dl-btn svg,
  .dy-btn svg,
  .xbt-btn svg,
  .about-btn svg { width: 17px; height: 17px; }
  .dl-panel { width: 100vw; max-width: 100vw; max-height: 100vh; border-radius: 0; }
}
