/* ═══════════════════════════════════════════════════════════
   NOMINA NATURAE · 万物之名
   Design language: dark natural-history archive —
   ink & parchment, brass gold, editorial serif, film grain.
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0c0f0d;
  --bg-2: #111512;
  --panel: #161b17;
  --panel-2: #1c221d;
  --ink: #ece4d3;
  --ink-soft: #b9b1a0;
  --ink-faint: #8a8271;
  --gold: #c9a45b;
  --gold-soft: #d9bd82;
  --gold-deep: #a8843f;
  --line: rgba(236, 228, 211, 0.10);
  --line-strong: rgba(236, 228, 211, 0.22);
  --danger: #c96b5b;
  --good: #7fa37a;
  --hard: #c9a45b;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --latin: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Noto Sans SC", "PingFang SC", sans-serif;
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.65);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="light"] {
  --bg: #efe9dc;
  --bg-2: #f6f1e6;
  --panel: #faf6ec;
  --panel-2: #f1ebdd;
  --ink: #26231c;
  --ink-soft: #5b554a;
  --ink-faint: #8a8271;
  --gold: #a8843f;
  --gold-soft: #8a6c31;
  --gold-deep: #8a6c31;
  --line: rgba(38, 35, 28, 0.12);
  --line-strong: rgba(38, 35, 28, 0.28);
  --danger: #b3553f;
  --good: #4c7a4a;
  --hard: #a8843f;
  --shadow-lg: 0 30px 80px -20px rgba(60, 50, 30, 0.35);
}

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

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.75;
  letter-spacing: 0.02em;
  overflow-x: hidden;
  transition: background 0.6s var(--ease), color 0.6s var(--ease);
}

::selection { background: var(--gold); color: #14100a; }

/* film grain */
.grain {
  position: fixed; inset: -100px;
  pointer-events: none; z-index: 2000;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
html[data-theme="light"] .grain { opacity: 0.035; }

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
kbd {
  font-family: var(--sans); font-size: 0.65em;
  border: 1px solid var(--line-strong); border-radius: 4px;
  padding: 1px 6px; color: var(--ink-faint);
}

/* ══════════ HEADER ══════════ */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 18px clamp(20px, 4vw, 56px);
  transition: background 0.4s, border-color 0.4s, padding 0.4s;
  border-bottom: 1px solid transparent;
}
.site-header.scrolled {
  padding: 10px clamp(20px, 4vw, 56px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--gold); color: var(--gold);
  border-radius: 50%; font-size: 15px;
  box-shadow: inset 0 0 12px color-mix(in srgb, var(--gold) 22%, transparent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-zh { font-family: var(--serif); font-weight: 600; font-size: 16px; letter-spacing: 0.28em; }
.brand-la { font-family: var(--latin); font-style: italic; font-size: 11.5px; color: var(--gold-soft); letter-spacing: 0.14em; }

.main-nav { display: flex; gap: 4px; }
.main-nav a {
  position: relative; padding: 8px 14px; font-size: 14px;
  color: var(--ink-soft); letter-spacing: 0.22em;
  transition: color 0.3s;
}
.main-nav a::after {
  content: ""; position: absolute; left: 50%; bottom: 2px;
  width: 0; height: 1px; background: var(--gold);
  transition: width 0.35s var(--ease), left 0.35s var(--ease);
}
.main-nav a:hover, .main-nav a.active { color: var(--ink); }
.main-nav a:hover::after, .main-nav a.active::after { width: 55%; left: 22.5%; }

.header-actions { display: flex; align-items: center; gap: 12px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 100px;
  padding: 7px 14px; color: var(--ink-faint);
  background: color-mix(in srgb, var(--panel) 60%, transparent);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.search-box:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 15%, transparent); }
.search-box svg { width: 15px; height: 15px; flex: none; }
.search-box input {
  background: none; border: none; outline: none;
  color: var(--ink); font-family: var(--sans); font-size: 13.5px;
  width: 150px; transition: width 0.4s var(--ease);
}
.search-box input::placeholder { color: var(--ink-faint); }
.search-box:focus-within input { width: 210px; }

.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: none; color: var(--ink-soft);
  transition: border-color 0.3s, color 0.3s, transform 0.3s;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold); transform: rotate(15deg); }
.icon-btn svg { width: 16px; height: 16px; }
html[data-theme="light"] .icon-btn .sun { display: none; }
html[data-theme="dark"] .icon-btn .moon { display: none; }

/* ══════════ HERO ══════════ */
.hero {
  position: relative; min-height: 100vh;
  display: flex; align-items: center;
  overflow: hidden;
}
.hero-bg {
  position: absolute; inset: -8%;
  background-size: cover; background-position: center 30%;
  filter: saturate(0.85) contrast(1.04);
  animation: heroZoom 24s ease-in-out infinite alternate;
}
@keyframes heroZoom { from { transform: scale(1); } to { transform: scale(1.07); } }
.hero-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(to top, var(--bg) 0%, transparent 38%),
    linear-gradient(to right, color-mix(in srgb, var(--bg) 92%, transparent) 0%, color-mix(in srgb, var(--bg) 45%, transparent) 52%, color-mix(in srgb, var(--bg) 15%, transparent) 100%),
    radial-gradient(120% 90% at 30% 40%, transparent 40%, color-mix(in srgb, var(--bg) 60%, transparent) 100%);
}
.hero-inner {
  position: relative; z-index: 2;
  max-width: 720px; margin-left: clamp(20px, 9vw, 130px);
  padding: 120px 0 90px;
}
.eyebrow {
  font-family: var(--latin); font-style: italic;
  color: var(--gold-soft); letter-spacing: 0.3em;
  font-size: 13px; text-transform: uppercase;
  margin-bottom: 18px;
}
.hero-title { margin-bottom: 26px; }
.hero-zh {
  display: block; font-family: var(--serif); font-weight: 900;
  font-size: clamp(52px, 8.5vw, 108px); line-height: 1.1;
  letter-spacing: 0.06em;
}
.hero-zh .em { color: var(--gold); position: relative; }
.hero-zh .em::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 6px;
  height: 1px; background: var(--gold);
  transform: scaleX(0); transform-origin: left;
  animation: ruleIn 1.1s var(--ease) 0.7s forwards;
}
@keyframes ruleIn { to { transform: scaleX(1); } }
.hero-la {
  display: block; font-family: var(--latin); font-style: italic;
  font-weight: 500; font-size: clamp(24px, 3.4vw, 44px);
  color: var(--ink-soft); letter-spacing: 0.22em; margin-top: 10px;
}
.hero-sub { color: var(--ink-soft); font-size: clamp(15px, 1.6vw, 18px); max-width: 560px; margin-bottom: 40px; }

.hero-cta { display: flex; gap: 16px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--sans); font-size: 14.5px; letter-spacing: 0.2em;
  padding: 14px 30px; border-radius: 100px; border: 1px solid var(--line-strong);
  color: var(--ink); background: transparent;
  transition: all 0.35s var(--ease);
}
.btn i { font-style: normal; transition: transform 0.35s var(--ease); }
.btn:hover i { transform: translateX(5px); }
.btn-gold {
  background: linear-gradient(120deg, var(--gold-deep), var(--gold) 55%, var(--gold-soft));
  border: none; color: #171208;
  font-weight: 500;
  box-shadow: 0 12px 34px -10px color-mix(in srgb, var(--gold) 60%, transparent);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 18px 44px -10px color-mix(in srgb, var(--gold) 75%, transparent); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); transform: translateY(-2px); }
.btn-danger { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.hero-stats {
  display: flex; gap: clamp(24px, 5vw, 64px);
  margin-top: 64px; list-style: none;
  border-top: 1px solid var(--line);
  padding-top: 26px; max-width: 640px;
}
.hero-stats li { display: flex; flex-direction: column; }
.hero-stats b {
  font-family: var(--serif); font-weight: 700; font-size: clamp(22px, 2.6vw, 32px);
  color: var(--gold-soft); font-variant-numeric: tabular-nums;
}
.hero-stats span { font-size: 12px; color: var(--ink-faint); letter-spacing: 0.18em; }

.hero-scroll {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  width: 1px; height: 56px; overflow: hidden; background: var(--line-strong);
}
.hero-scroll span {
  position: absolute; left: 0; top: -100%; width: 100%; height: 50%;
  background: var(--gold); animation: scrollDrop 2.2s var(--ease) infinite;
}
@keyframes scrollDrop { to { top: 100%; } }

/* ══════════ SECTIONS ══════════ */
.section { padding: clamp(80px, 10vw, 140px) clamp(20px, 4.5vw, 64px); max-width: 1440px; margin: 0 auto; }
.section-head { text-align: center; margin-bottom: clamp(44px, 6vw, 76px); }
.section-head h2 {
  font-family: var(--serif); font-weight: 700; font-size: clamp(30px, 4vw, 46px);
  letter-spacing: 0.14em;
}
.section-note { color: var(--ink-faint); font-size: 14.5px; margin-top: 10px; }
.head-count {
  font-family: var(--latin); font-style: italic; font-weight: 500;
  font-size: 0.42em; color: var(--gold-soft); letter-spacing: 0.06em;
  vertical-align: middle; margin-left: 12px; white-space: nowrap;
}

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ══════════ CATEGORIES ══════════ */
.cat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.cat-card {
  position: relative; border-radius: 6px; overflow: hidden;
  aspect-ratio: 3/4; border: 1px solid var(--line);
  background: var(--panel);
  transition: transform 0.5s var(--ease), border-color 0.4s, box-shadow 0.5s;
  cursor: pointer;
}
.cat-card:hover { transform: translateY(-6px); border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.cat-card img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: saturate(0.9) brightness(0.92);
  transition: transform 1.1s var(--ease), filter 0.6s;
}
.cat-card:hover img { transform: scale(1.06); filter: saturate(1) brightness(0.85); }
.cat-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8, 10, 8, 0.92) 0%, rgba(8, 10, 8, 0.25) 55%, transparent 100%);
}
.cat-card-body {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 22px 20px;
  transform: translateY(0);
  transition: transform 0.5s var(--ease);
}
.cat-card:hover .cat-card-body { transform: translateY(-4px); }
.cat-card-zh { font-family: var(--serif); font-weight: 600; font-size: 21px; letter-spacing: 0.16em; color: #f3ecdc; }
.cat-card-la { font-family: var(--latin); font-style: italic; font-size: 14px; color: var(--gold-soft); letter-spacing: 0.1em; }
.cat-card-n { font-size: 11px; color: rgba(243, 236, 220, 0.55); letter-spacing: 0.2em; margin-top: 4px; }
.cat-card-num {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  font-family: var(--latin); font-style: italic; font-size: 15px; color: rgba(243, 236, 220, 0.8);
}

/* ══════════ FILTER BAR ══════════ */
.filter-bar {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 8px;
  margin-bottom: 40px;
}
.chip {
  border: 1px solid var(--line); background: none;
  color: var(--ink-soft); border-radius: 100px;
  padding: 8px 18px; font-size: 13px; letter-spacing: 0.14em;
  transition: all 0.3s;
}
.chip:hover { border-color: var(--gold); color: var(--ink); }
.chip.active {
  background: linear-gradient(120deg, var(--gold-deep), var(--gold));
  color: #171208; border-color: transparent; font-weight: 500;
}

/* ══════════ COLLECTION GRID ══════════ */
.coll-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 18px;
}
.spec-card {
  position: relative; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--line); background: var(--panel);
  cursor: pointer;
  transition: transform 0.5s var(--ease), border-color 0.4s, box-shadow 0.5s;
}
.spec-card:hover { transform: translateY(-6px); border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.spec-media { position: relative; aspect-ratio: 4/3; overflow: hidden; }
.spec-media img {
  width: 100%; height: 100%; object-fit: cover;
  filter: saturate(0.92);
  transition: transform 1.2s var(--ease);
}
.spec-card:hover .spec-media img { transform: scale(1.07); }
.spec-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8, 10, 8, 0.55), transparent 45%);
}
.spec-la-tag {
  position: absolute; left: 14px; bottom: 10px; z-index: 2;
  font-family: var(--latin); font-style: italic; font-size: 15px;
  color: #f0e9d8; letter-spacing: 0.06em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
}
.spec-body { padding: 16px 18px 18px; }
.spec-name-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.spec-zh { font-family: var(--serif); font-weight: 600; font-size: 19px; letter-spacing: 0.1em; }
.spec-badge {
  font-size: 10.5px; letter-spacing: 0.1em; color: var(--ink-faint);
  border: 1px solid var(--line); padding: 2px 8px; border-radius: 100px;
  white-space: nowrap;
}
.spec-fam { margin-top: 4px; font-size: 12.5px; color: var(--ink-faint); }
.spec-progress { margin-top: 12px; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.spec-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width 0.6s var(--ease); }
.empty-hint { text-align: center; color: var(--ink-faint); padding: 30px; }

/* ══════════ FLASH INTRO ══════════ */
.flash-intro {
  display: grid; grid-template-columns: 1.15fr 1fr;
  gap: clamp(30px, 5vw, 70px); align-items: center;
}
.flash-preview {
  position: relative; border-radius: 8px; overflow: hidden;
  aspect-ratio: 16/10; border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
}
.flash-preview img { width: 100%; height: 100%; object-fit: cover; }
.flash-preview .pv-cap {
  position: absolute; left: 22px; bottom: 18px; z-index: 2;
  font-family: var(--latin); font-style: italic; font-size: 21px; color: #f3ecdc;
  text-shadow: 0 2px 14px rgba(0,0,0,0.75);
}
.flash-preview::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8,10,8,0.75), transparent 55%);
}
.flash-side h3 { font-family: var(--serif); font-size: 27px; letter-spacing: 0.1em; margin-bottom: 14px; }
.flash-side > p { color: var(--ink-soft); font-size: 14.5px; margin-bottom: 26px; }
.flash-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.flash-opt {
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 6px; padding: 14px 16px; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
  transition: all 0.3s;
}
.flash-opt:hover { border-color: var(--gold); transform: translateY(-2px); }
.flash-opt b { font-family: var(--serif); font-weight: 600; font-size: 15.5px; letter-spacing: 0.06em; }
.flash-opt span { font-size: 11.5px; color: var(--ink-faint); }
.flash-meta { color: var(--ink-faint); font-size: 13px; }
.flash-meta span { color: var(--gold-soft); font-weight: 500; }

/* ══════════ QUIZ INTRO ══════════ */
.quiz-intro {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 26px; align-items: stretch;
}
.quiz-panel {
  border: 1px solid var(--line); border-radius: 8px;
  background: linear-gradient(150deg, var(--panel), var(--bg-2));
  padding: clamp(26px, 3.4vw, 44px);
}
.quiz-panel h3 { font-family: var(--serif); font-size: 24px; letter-spacing: 0.1em; margin-bottom: 18px; }
.quiz-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 24px; }
.quiz-opt {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 6px; padding: 16px; text-align: left;
  display: flex; flex-direction: column; gap: 3px;
  transition: all 0.3s;
}
.quiz-opt:hover { border-color: var(--gold); transform: translateY(-2px); }
.quiz-opt b { font-family: var(--serif); font-weight: 600; font-size: 16px; letter-spacing: 0.05em; }
.quiz-opt span { font-size: 12px; color: var(--ink-faint); }
.quiz-rules { list-style: none; color: var(--ink-faint); font-size: 13px; }
.quiz-rules li { padding-left: 18px; position: relative; }
.quiz-rules li::before { content: "—"; position: absolute; left: 0; color: var(--gold); }
.quiz-best {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); padding: clamp(26px, 3.4vw, 40px);
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.quiz-best h4 { font-family: var(--serif); font-size: 17px; letter-spacing: 0.14em; color: var(--ink-faint); font-weight: 500; }
.quiz-best-score { font-family: var(--latin); font-size: clamp(56px, 6vw, 84px); line-height: 1; color: var(--gold); font-weight: 500; }
.quiz-best-score small { font-size: 24px; color: var(--ink-faint); }
.quiz-best-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 12px; }
.quiz-best-row b { color: var(--gold-soft); font-weight: 500; }

/* ══════════ ROOTS ══════════ */
.roots-board {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px;
}
.root-card {
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); padding: 18px 20px;
  transition: all 0.3s;
}
.root-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.root-la { font-family: var(--latin); font-style: italic; font-size: 21px; color: var(--gold-soft); }
.root-meaning { font-size: 13.5px; color: var(--ink); margin: 4px 0 8px; }
.root-egs { font-size: 12px; color: var(--ink-faint); line-height: 1.7; }
.root-egs em { font-style: italic; font-family: var(--latin); color: var(--ink-soft); }

/* ══════════ PROGRESS ══════════ */
.progress-board {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 26px; align-items: stretch;
}
.prog-main {
  border: 1px solid var(--line); border-radius: 8px;
  background: linear-gradient(150deg, var(--panel), var(--bg-2));
  padding: clamp(26px, 3.4vw, 44px);
}
.prog-ring-row { display: flex; align-items: center; gap: 34px; flex-wrap: wrap; }
.ring-wrap { position: relative; width: 148px; height: 148px; flex: none; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-wrap .ring-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 30px; color: var(--gold-soft);
}
.ring-wrap .ring-num small { font-size: 12px; color: var(--ink-faint); font-weight: 400; }
.prog-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; flex: 1; min-width: 240px; }
.kpi { border: 1px solid var(--line); border-radius: 6px; padding: 14px 18px; }
.kpi b { font-family: var(--serif); font-size: 24px; color: var(--gold-soft); display: block; }
.kpi span { font-size: 12px; color: var(--ink-faint); letter-spacing: 0.1em; }
.prog-side { display: grid; grid-template-rows: 1fr auto; gap: 26px; }
.prog-panel {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); padding: clamp(22px, 2.6vw, 32px);
}
.prog-panel h4 { font-family: var(--serif); font-size: 17px; letter-spacing: 0.12em; margin-bottom: 16px; }
.mastered-list { display: flex; flex-wrap: wrap; gap: 8px; }
.mastered-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
  color: var(--good); border-radius: 100px;
  padding: 4px 12px; font-size: 12.5px;
}
.mastered-chip::before { content: "✓"; font-size: 10px; }
.prog-actions .muted { margin-bottom: 16px; }
.muted { color: var(--ink-faint); font-size: 13px; }

/* ══════════ FOOTER ══════════ */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 54px clamp(20px, 4.5vw, 64px);
  background: var(--bg-2);
}
.footer-inner { max-width: 1440px; margin: 0 auto; display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.footer-brand { font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: 0.2em; }
.footer-la { font-family: var(--latin); font-style: italic; color: var(--gold-soft); letter-spacing: 0.12em; }
.footer-quote { font-family: var(--latin); font-style: italic; font-size: 15px; color: var(--ink-soft); text-align: right; line-height: 2; }

/* ══════════ MODAL ══════════ */
.modal, .overlay {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s var(--ease);
}
.modal.open, .overlay.open { opacity: 1; pointer-events: auto; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 7, 6, 0.78); backdrop-filter: blur(10px);
}
.modal-card {
  position: relative; z-index: 2;
  width: min(880px, calc(100vw - 32px));
  max-height: min(86vh, 900px); overflow: auto;
  border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--panel);
  transform: translateY(28px) scale(0.97);
  transition: transform 0.45s var(--ease);
  box-shadow: var(--shadow-lg);
}
.modal.open .modal-card { transform: none; }
.modal-close {
  position: sticky; top: 14px; z-index: 5; float: right; margin: 14px 14px 0 0;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--panel) 80%, transparent);
  backdrop-filter: blur(6px); color: var(--ink-soft); font-size: 14px;
  transition: all 0.3s;
}
.modal-close:hover { color: var(--gold); border-color: var(--gold); transform: rotate(90deg); }

.modal-hero { position: relative; height: min(46vh, 420px); overflow: hidden; }
.modal-hero img { width: 100%; height: 100%; object-fit: cover; }
.modal-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--panel) 2%, transparent 60%);
}
.modal-hero .mh-la {
  position: absolute; left: 34px; bottom: 16px; z-index: 2;
  font-family: var(--latin); font-style: italic;
  font-size: clamp(26px, 3.4vw, 40px); color: #f3ecdc;
  text-shadow: 0 2px 20px rgba(0,0,0,0.8);
}
.modal-body { padding: 4px 34px 40px; }
.mh-zh {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(26px, 3vw, 36px); letter-spacing: 0.08em;
}
.mh-zh .mh-genus { font-family: var(--latin); font-style: italic; font-weight: 500; font-size: 19px; color: var(--gold-soft); letter-spacing: 0.05em; }
.taxo-ladder {
  margin: 22px 0; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: var(--bg-2);
}
.taxo-row {
  display: grid; grid-template-columns: 84px 1fr;
  align-items: center; gap: 10px;
  padding: 11px 18px; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.taxo-row:last-child { border-bottom: none; }
.taxo-row.hl { background: color-mix(in srgb, var(--gold) 10%, transparent); }
.taxo-k { color: var(--ink-faint); font-size: 12px; letter-spacing: 0.24em; }
.taxo-v { font-family: var(--latin); font-style: italic; font-size: 17px; }
.taxo-v .zh { font-family: var(--sans); font-style: normal; font-size: 13px; color: var(--ink-faint); margin-left: 8px; letter-spacing: 0.08em; }
.modal-desc { color: var(--ink-soft); font-size: 15px; margin-bottom: 22px; }
.modal-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini-card {
  border: 1px solid var(--line); border-radius: 6px;
  padding: 18px 20px; background: var(--bg-2);
}
.mini-card h4 { font-family: var(--serif); font-size: 14px; letter-spacing: 0.2em; color: var(--gold-soft); margin-bottom: 8px; font-weight: 500; }
.mini-card p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.8; }
.modal-actions { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.mini-btn {
  border: 1px solid var(--line); border-radius: 100px; background: none;
  color: var(--ink-soft); padding: 9px 20px; font-size: 13px; letter-spacing: 0.12em;
  transition: all 0.3s;
}
.mini-btn:hover { border-color: var(--gold); color: var(--gold); }
.mini-btn.on { border-color: var(--good); color: var(--good); }

/* ══════════ FLASH OVERLAY ══════════ */
.overlay {
  background: radial-gradient(90% 70% at 50% 30%, var(--bg-2), var(--bg) 80%);
  grid-template-rows: auto 1fr auto auto; padding: 20px;
  overflow-y: auto;
}
.overlay-top {
  width: min(1000px, 100%); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.overlay-title { font-family: var(--serif); font-size: 17px; letter-spacing: 0.24em; }
.overlay-count { font-family: var(--latin); font-style: italic; color: var(--gold-soft); font-size: 17px; }
.flash-stage { width: min(1000px, 100%); margin: 24px auto; display: grid; place-items: center; perspective: 1600px; }
.flash-card {
  position: relative; width: min(660px, 100%); height: min(440px, 58vh);
  transform-style: preserve-3d; cursor: pointer; outline: none;
  transition: transform 0.7s var(--ease);
}
.flash-card.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line-strong); background: var(--panel);
  box-shadow: var(--shadow-lg);
}
.flash-front img { width: 100%; height: 100%; object-fit: cover; }
.flash-front::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8,10,8,0.88) 0%, transparent 52%);
}
.flash-front-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px; z-index: 2; text-align: center; }
.flash-cat {
  display: inline-block; font-size: 11px; letter-spacing: 0.3em;
  color: var(--gold-soft); text-transform: uppercase;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: 100px; padding: 3px 14px; margin-bottom: 12px;
}
.flash-front-info h3 { font-family: var(--serif); font-weight: 700; font-size: clamp(30px, 4vw, 44px); color: #f3ecdc; letter-spacing: 0.12em; }
.flash-hint { margin-top: 8px; font-size: 12px; color: rgba(243, 236, 220, 0.55); letter-spacing: 0.2em; }
.flash-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--gold) 9%, transparent), transparent 60%),
    var(--panel);
}
.flash-back-inner {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 36px 40px; gap: 12px;
}
.flash-la {
  font-family: var(--latin); font-style: italic; font-weight: 600;
  font-size: clamp(34px, 4.6vw, 52px); color: var(--gold-soft);
  letter-spacing: 0.04em; line-height: 1.15;
}
.flash-ipa { font-size: 13.5px; color: var(--ink-faint); letter-spacing: 0.06em; }
.flash-eth { font-size: 14px; color: var(--ink-soft); max-width: 480px; line-height: 1.9; }
.flash-tip {
  font-family: var(--serif); font-size: 13.5px; color: var(--gold);
  border: 1px dashed color-mix(in srgb, var(--gold) 40%, transparent);
  border-radius: 6px; padding: 8px 18px; max-width: 480px;
}
.flash-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-again { border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.btn-again:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn-hard { border-color: color-mix(in srgb, var(--hard) 40%, transparent); color: var(--hard); }
.btn-hard:hover:not(:disabled) { background: color-mix(in srgb, var(--hard) 12%, transparent); }
.btn-good { border-color: color-mix(in srgb, var(--good) 40%, transparent); color: var(--good); }
.btn-good:hover:not(:disabled) { background: color-mix(in srgb, var(--good) 12%, transparent); }
.flash-keys { text-align: center; margin-top: 14px; letter-spacing: 0.12em; }

/* ══════════ QUIZ OVERLAY ══════════ */
.quiz-stage {
  width: min(680px, 100%); margin: 6vh auto 0; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.quiz-progress { width: 100%; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.quiz-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width 0.5s var(--ease); }
.quiz-q { font-family: var(--serif); font-size: clamp(20px, 2.6vw, 27px); letter-spacing: 0.06em; line-height: 1.6; }
.quiz-q .q-la { font-family: var(--latin); font-style: italic; color: var(--gold-soft); }
.quiz-q img {
  margin: 14px auto 6px; border-radius: 8px; max-height: 300px;
  object-fit: cover; border: 1px solid var(--line-strong);
}
.quiz-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.qa {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  color: var(--ink); padding: 18px 22px; font-size: 16px;
  font-family: var(--serif); letter-spacing: 0.06em;
  transition: all 0.3s var(--ease);
}
.qa:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-2px); }
.qa.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.qa.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); animation: shake 0.4s; }
.qa:disabled { cursor: default; opacity: 0.75; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.quiz-feedback {
  font-size: 14px; color: var(--ink-soft); line-height: 1.9;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 22px; background: var(--bg-2); text-align: left;
}
.quiz-feedback b { color: var(--gold-soft); }
.quiz-next { margin-top: 4px; }
.quiz-result { text-align: center; }
.quiz-result .qr-score { font-family: var(--latin); font-style: italic; font-size: clamp(70px, 10vw, 120px); color: var(--gold); line-height: 1; }
.quiz-result .qr-title { font-family: var(--serif); font-size: 24px; letter-spacing: 0.16em; margin: 8px 0 4px; }
.quiz-result .qr-sub { color: var(--ink-faint); font-size: 14px; margin-bottom: 26px; }
.quiz-result .qr-list { text-align: left; margin-bottom: 26px; }
.qr-item { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding: 9px 4px; font-size: 13.5px; }
.qr-item .qr-zh { font-family: var(--serif); font-weight: 500; }
.qr-item .qr-la { font-family: var(--latin); font-style: italic; color: var(--ink-soft); }
.qr-item .ok { color: var(--good); }
.qr-item .no { color: var(--danger); }

/* ══════════ TOAST ══════════ */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 100px;
  padding: 12px 26px; font-size: 13.5px; letter-spacing: 0.08em;
  opacity: 0; pointer-events: none; z-index: 900;
  transition: all 0.4s var(--ease);
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ══════════ SPEAK BUTTONS (latin pronunciation) ══════════ */
.speak-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.3s var(--ease);
  vertical-align: middle;
}
.speak-btn svg { width: 15px; height: 15px; }
.speak-btn:hover {
  border-color: var(--gold); color: var(--gold); background: var(--panel-2);
  transform: scale(1.08);
}
.speak-btn:active { transform: scale(0.94); }

/* on species card media (photo): legible over image */
.spec-media .speak-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  width: 30px; height: 30px;
  background: rgba(10, 12, 10, 0.55); backdrop-filter: blur(4px);
  border-color: rgba(243, 236, 220, 0.35);
  color: #f3ecdc;
}
.spec-media .speak-btn:hover { border-color: var(--gold-soft); color: var(--gold-soft); background: rgba(10, 12, 10, 0.75); }

/* in modal title */
.mh-zh .speak-btn { margin-left: 8px; width: 34px; height: 34px; }
.mh-zh .speak-btn svg { width: 17px; height: 17px; }

/* on flashcard back — larger, centered under the latin name */
.flash-back-inner .speak-btn-lg {
  width: 44px; height: 44px; margin: 2px auto 0;
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--gold-soft);
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}
.flash-back-inner .speak-btn-lg svg { width: 20px; height: 20px; }
.flash-back-inner .speak-btn-lg:hover {
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  transform: scale(1.12);
}

/* ══════════ RESPONSIVE ══════════ */
@media (max-width: 1080px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .main-nav { display: none; }
  .flash-intro, .quiz-intro, .progress-board { grid-template-columns: 1fr; }
  .hero-inner { margin-left: clamp(20px, 6vw, 60px); }
}
@media (max-width: 640px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .search-box input { width: 90px; }
  .search-box:focus-within input { width: 130px; }
  .hero-stats { gap: 22px; }
  .modal-cards { grid-template-columns: 1fr; }
  .quiz-answers { grid-template-columns: 1fr; }
  .flash-actions .btn { flex: 1; justify-content: center; padding: 14px 12px; }
  .flash-options { grid-template-columns: 1fr; }
  .quiz-options { grid-template-columns: 1fr; }
  .site-header { padding: 14px 16px; gap: 10px; }
  .brand-zh { font-size: 14px; letter-spacing: 0.18em; white-space: nowrap; }
  .brand-la { display: none; }
  .brand-mark { width: 32px; height: 32px; font-size: 13px; }
  .search-box input { width: 0; padding: 0; }
  .search-box input:focus { width: 120px; padding: 0 2px; }
  .search-box { padding: 7px 10px; }
  .search-box kbd { display: none; }
  .hero-inner { margin-left: 20px; padding: 110px 0 80px; }
  .hero-cta .btn { padding: 13px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* ══════════ PWA STANDALONE / iOS SAFE AREA ══════════ */
@supports (padding: env(safe-area-inset-top)) {
  .site-header {
    padding-left: max(clamp(20px, 4vw, 56px), env(safe-area-inset-left));
    padding-right: max(clamp(20px, 4vw, 56px), env(safe-area-inset-right));
  }
  .hero-inner { padding-top: calc(120px + env(safe-area-inset-top)); }
  .section {
    padding-left: max(clamp(20px, 4.5vw, 64px), env(safe-area-inset-left));
    padding-right: max(clamp(20px, 4.5vw, 64px), env(safe-area-inset-right));
  }
  .site-footer {
    padding-left: max(clamp(20px, 4.5vw, 64px), env(safe-area-inset-left));
    padding-right: max(clamp(20px, 4.5vw, 64px), env(safe-area-inset-right));
  }
  .overlay {
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .toast { bottom: calc(34px + env(safe-area-inset-bottom)); }
}

/* standalone (added to home screen): adjust for browser chrome removal */
html.standalone .site-header {
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}
html.standalone {
  -webkit-tap-highlight-color: rgba(201, 164, 91, 0.25);
}
html.standalone body {
  overscroll-behavior-y: none;
}
