/* ============================================================
   森谷英语 Sunny English — Design System
   Premium English-learning app UI · Light + Dark · WCAG AA
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Brand: Forest (primary) */
  --forest-50:  #f0faf3;
  --forest-100: #dcf2e3;
  --forest-200: #bbe4ca;
  --forest-300: #88cf9f;
  --forest-400: #4fae74;
  --forest-500: #2d8f54;
  --forest-600: #1f7042;
  --forest-700: #1a5936;
  --forest-800: #17482d;
  --forest-900: #0f2e1d;

  /* Accent: Sunny (secondary) */
  --sunny-50:  #fffaeb;
  --sunny-100: #fff0c6;
  --sunny-200: #ffe08a;
  --sunny-300: #ffc94d;
  --sunny-400: #ffb21f;
  --sunny-500: #f99007;
  --sunny-600: #dd6c02;

  /* Berry (tertiary accent) */
  --berry-400: #e25588;
  --berry-500: #cf3a6e;
  --berry-600: #b02756;

  /* Sky (info) */
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;

  /* Semantic */
  --ok: #16a34a;
  --ok-bg: #e8f7ee;
  --warn: #d97706;
  --warn-bg: #fff4e2;
  --err: #dc2626;
  --err-bg: #fdeaeb;
  --info: #2563eb;

  /* Neutral (light theme) */
  --bg: #f7f9f8;
  --bg-soft: #eef3f0;
  --surface: #ffffff;
  --surface-2: #f4f7f5;
  --surface-3: #e9efeb;
  --border: #dde6e1;
  --border-strong: #c7d3cc;
  --text: #15241b;
  --text-2: #41564a;
  --text-3: #6b8077;
  --text-inv: #ffffff;

  /* Gradients */
  --grad-hero: linear-gradient(135deg, #1a5936 0%, #2d8f54 45%, #4fae74 100%);
  --grad-sunny: linear-gradient(135deg, #ffb21f 0%, #f99007 100%);
  --grad-berry: linear-gradient(135deg, #e25588 0%, #cf3a6e 100%);
  --grad-sky: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
  --grad-card-billie: linear-gradient(135deg, #ff9a8b 0%, #ff6a88 100%);
  --grad-card-cpp: linear-gradient(135deg, #2d8f54 0%, #1a5936 100%);
  --grad-card-think: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
  --grad-card-1000: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);

  /* Typography */
  --font-sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Baloo 2", "PingFang SC", "Microsoft YaHei", var(--font-sans);
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem;
  --fs-4xl: 2.25rem;
  --fs-5xl: 3rem;

  /* Spacing (8pt-ish) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Radius */
  --r-sm: 0.5rem;
  --r-md: 0.75rem;
  --r-lg: 1rem;
  --r-xl: 1.25rem;
  --r-2xl: 1.75rem;
  --r-pill: 999px;

  /* Shadows */
  --sh-sm: 0 1px 2px rgba(15,46,29,.06), 0 1px 3px rgba(15,46,29,.05);
  --sh-md: 0 4px 12px -2px rgba(15,46,29,.10), 0 2px 6px -2px rgba(15,46,29,.06);
  --sh-lg: 0 16px 40px -8px rgba(15,46,29,.18), 0 6px 14px -6px rgba(15,46,29,.10);
  --sh-xl: 0 30px 70px -12px rgba(15,46,29,.28);
  --sh-glow: 0 8px 28px -6px rgba(45,143,84,.45);

  /* Motion */
  --t-fast: 150ms cubic-bezier(.4,0,.2,1);
  --t-base: 260ms cubic-bezier(.4,0,.2,1);
  --t-slow: 480ms cubic-bezier(.22,1,.36,1);
  --t-spring: 420ms cubic-bezier(.34,1.56,.64,1);

  --nav-h: 4.25rem;
  --maxw: 1180px;
}

[data-theme="dark"] {
  --bg: #0d1712;
  --bg-soft: #11201a;
  --surface: #152620;
  --surface-2: #1a2f27;
  --surface-3: #213a30;
  --border: #244035;
  --border-strong: #305446;
  --text: #e8f1ec;
  --text-2: #b3c6bc;
  --text-3: #7e9389;
  --text-inv: #0d1712;

  --ok-bg: #123020;
  --warn-bg: #2a210f;
  --err-bg: #2b1416;

  --sh-sm: 0 1px 2px rgba(0,0,0,.3);
  --sh-md: 0 6px 16px -4px rgba(0,0,0,.45);
  --sh-lg: 0 18px 44px -10px rgba(0,0,0,.55);
  --sh-glow: 0 8px 30px -6px rgba(77,174,116,.4);

  --grad-hero: linear-gradient(135deg, #0f2e1d 0%, #1a5936 50%, #1f7042 100%);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg, video, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ul, ol { list-style: none; padding: 0; }
:focus-visible { outline: 3px solid var(--forest-400); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 1000;
  background: var(--forest-600); color: #fff; padding: var(--sp-3) var(--sp-4);
  border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; }

/* Utility */
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--sp-4); }
.section { padding: var(--sp-16) 0; scroll-margin-top: var(--nav-h); }
.section--tight { padding: var(--sp-10) 0; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto var(--sp-10); }
.section-tag {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: .04em;
  color: var(--forest-600); background: var(--forest-50);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill);
  border: 1px solid var(--forest-200);
}
[data-theme="dark"] .section-tag { color: var(--forest-300); background: rgba(45,143,84,.12); border-color: var(--forest-700); }
.section-title { font-family: var(--font-display); font-size: var(--fs-4xl); font-weight: 800; line-height: 1.15; margin: var(--sp-3) 0; letter-spacing: -.01em; }
.section-desc { color: var(--text-2); font-size: var(--fs-lg); }

/* ---------- Top Nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--t-base), background var(--t-base);
}
.topbar.scrolled { box-shadow: var(--sh-md); }
.topbar-inner { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--sp-4); display: flex; align-items: center; gap: var(--sp-4); }
.logo { display: flex; align-items: center; gap: var(--sp-2); font-family: var(--font-display); font-weight: 800; font-size: var(--fs-xl); color: var(--forest-700); }
[data-theme="dark"] .logo { color: var(--forest-300); }
.logo-mark {
  width: 2.25rem; height: 2.25rem; border-radius: var(--r-md);
  background: var(--grad-hero); display: grid; place-items: center;
  font-size: 1.25rem; box-shadow: var(--sh-glow);
}
.logo-sub { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); letter-spacing: .12em; text-transform: uppercase; }
.nav-links { display: none; align-items: center; gap: var(--sp-1); margin-left: auto; }
.nav-link {
  position: relative; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  font-weight: 500; color: var(--text-2); font-size: var(--fs-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-link:hover { color: var(--forest-600); background: var(--forest-50); }
[data-theme="dark"] .nav-link:hover { background: rgba(45,143,84,.14); color: var(--forest-300); }
.nav-link.active { color: var(--forest-600); }
[data-theme="dark"] .nav-link.active { color: var(--forest-300); }
.nav-link.active::after {
  content: ""; position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  width: 18px; height: 3px; border-radius: 2px; background: var(--forest-500);
}
.nav-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.icon-btn {
  width: 2.5rem; height: 2.5rem; border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--text-2);
  border: 1px solid var(--border); background: var(--surface);
  transition: all var(--t-fast);
}
.icon-btn:hover { color: var(--forest-600); border-color: var(--forest-300); transform: translateY(-1px); }
.streak-chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill);
  background: var(--sunny-100); color: var(--sunny-600); font-weight: 700; font-size: var(--fs-sm);
  border: 1px solid var(--sunny-200);
}
[data-theme="dark"] .streak-chip { background: rgba(249,144,7,.14); color: var(--sunny-300); border-color: rgba(249,144,7,.3); }
.streak-chip.hidden { display: none; }
.menu-toggle { display: inline-grid; }

/* Mobile drawer */
.drawer {
  position: fixed; inset: var(--nav-h) 0 0 0; z-index: 90;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(8px);
  padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2);
  transform: translateY(-12px); opacity: 0; visibility: hidden;
  transition: var(--t-base);
}
.drawer.open { transform: none; opacity: 1; visibility: visible; }
.drawer .nav-link { font-size: var(--fs-lg); padding: var(--sp-3) var(--sp-4); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-weight: 600; font-size: var(--fs-base); line-height: 1;
  padding: .8rem 1.3rem; border-radius: var(--r-pill);
  border: 1px solid transparent; user-select: none; white-space: nowrap;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--forest-500); color: #fff; box-shadow: var(--sh-glow); }
.btn-primary:hover { background: var(--forest-600); transform: translateY(-2px); box-shadow: var(--sh-lg); }
.btn-sunny { background: var(--grad-sunny); color: #3d2400; box-shadow: 0 8px 24px -6px rgba(249,144,7,.5); }
.btn-sunny:hover { transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--forest-300); }
.btn-hero-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.55); }
.btn-hero-ghost:hover { background: rgba(255,255,255,.16); border-color: #fff; }
.btn-soft { background: var(--forest-50); color: var(--forest-700); }
[data-theme="dark"] .btn-soft { background: rgba(45,143,84,.16); color: var(--forest-200); }
.btn-soft:hover { background: var(--forest-100); }
.btn-lg { padding: 1rem 1.75rem; font-size: var(--fs-lg); }
.btn-sm { padding: .5rem .9rem; font-size: var(--fs-sm); }
.btn-round { width: 3rem; height: 3rem; padding: 0; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); }
.btn-round:hover { color: var(--forest-600); border-color: var(--forest-300); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-err { background: var(--err); color: #fff; border-color: var(--err); }
.btn-err:hover { background: var(--berry-600); transform: translateY(-2px); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding-top: var(--sp-12); padding-bottom: var(--sp-16); }
.hero-bg { position: absolute; inset: 0; background: var(--grad-hero); }
.hero-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,.10) 0, transparent 40%),
                    radial-gradient(circle at 80% 0%, rgba(255,178,31,.18) 0, transparent 45%);
}
.hero-blob { position: absolute; border-radius: 50%; filter: blur(40px); opacity: .5; }
.hero-inner { position: relative; z-index: 2; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--sp-4); display: grid; gap: var(--sp-8); align-items: center; }
.hero-text { color: #fff; }
.hero-badge {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill);
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25);
  font-weight: 600; font-size: var(--fs-sm); backdrop-filter: blur(6px);
}
.hero-title { font-family: var(--font-display); font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 800; line-height: 1.08; letter-spacing: -.02em; margin: var(--sp-5) 0 var(--sp-4); }
.hero-title em { font-style: normal; background: var(--grad-sunny); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-desc { font-size: var(--fs-lg); color: rgba(255,255,255,.9); max-width: 540px; margin-bottom: var(--sp-6); }
.hero-cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.hero-stats { display: flex; flex-wrap: wrap; gap: var(--sp-6); margin-top: var(--sp-8); }
.hero-stat { color: #fff; }
.hero-stat b { font-family: var(--font-display); font-size: var(--fs-3xl); display: block; line-height: 1; }
.hero-stat span { font-size: var(--fs-sm); opacity: .85; }

.hero-card {
  position: relative; border-radius: var(--r-2xl); padding: var(--sp-6);
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  backdrop-filter: blur(14px); box-shadow: var(--sh-xl);
}
.hero-card-head { display: flex; align-items: center; justify-content: space-between; color: #fff; margin-bottom: var(--sp-4); }
.hero-card-head h3 { font-family: var(--font-display); font-size: var(--fs-xl); }
.ring { --val: 0; --size: 92px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; position: relative; }
.ring::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--ring-c, var(--sunny-400)) calc(var(--val)*1%), rgba(255,255,255,.22) 0); }
.ring::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: rgba(255,255,255,.14); }
.ring span { position: relative; font-family: var(--font-display); font-weight: 800; color: #fff; font-size: var(--fs-lg); }
.hero-rings { display: flex; gap: var(--sp-4); justify-content: space-around; }

/* floating emoji deco */
.float-emoji { position: absolute; font-size: 2rem; opacity: .9; animation: bob 6s ease-in-out infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0) rotate(-4deg);} 50%{ transform: translateY(-14px) rotate(6deg);} }

/* ---------- Cards / Surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--sh-sm); transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.card:hover { box-shadow: var(--sh-md); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-6); }
.panel--soft { background: var(--surface-2); }

/* ---------- Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-5); }
.checkin-card { background: var(--grad-hero); color: #fff; border-radius: var(--r-xl); padding: var(--sp-6); position: relative; overflow: hidden; box-shadow: var(--sh-lg); }
.checkin-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.08); }
.checkin-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); position: relative; z-index: 2; }
.checkin-date { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 800; }
.checkin-sub { opacity: .9; font-size: var(--fs-sm); margin-top: var(--sp-1); }
.checkin-streak { display: inline-flex; align-items: center; gap: var(--sp-2); background: rgba(255,255,255,.18); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill); font-weight: 700; }
.checkin-btn { margin-top: var(--sp-5); position: relative; z-index: 2; }
.checkin-btn.done { background: rgba(255,255,255,.2); border: 1px dashed rgba(255,255,255,.5); color: #fff; }
.week-dots { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); position: relative; z-index: 2; }
.week-dot { flex: 1; text-align: center; }
.week-dot span { display: block; font-size: var(--fs-xs); opacity: .8; }
.week-dot i { display: block; width: 100%; aspect-ratio: 1; max-width: 38px; margin: 4px auto 0; border-radius: var(--r-sm); background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.2); }
.week-dot.on i { background: var(--sunny-400); border-color: var(--sunny-300); box-shadow: 0 4px 12px rgba(255,178,31,.5); }
.week-dot.today i { outline: 2px solid #fff; outline-offset: 2px; }

.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); text-align: center; }
.stat-card .ic { width: 2.75rem; height: 2.75rem; border-radius: var(--r-md); display: grid; place-items: center; margin: 0 auto var(--sp-3); font-size: 1.3rem; }
.stat-card b { font-family: var(--font-display); font-size: var(--fs-3xl); display: block; line-height: 1; }
.stat-card span { font-size: var(--fs-sm); color: var(--text-3); }

.ring-stat { --val:0; width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; position: relative; }
.ring-stat::before { content:""; position:absolute; inset:0; border-radius:50%; background: conic-gradient(var(--ring-c,var(--forest-500)) calc(var(--val)*1%), var(--surface-3) 0); }
.ring-stat::after { content:""; position:absolute; inset:10px; border-radius:50%; background: var(--surface); }
.ring-stat .ring-inner { position: relative; text-align: center; }
.ring-inner b { font-family: var(--font-display); font-size: var(--fs-2xl); display: block; line-height: 1; }
.ring-inner span { font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- Library / Book shelf ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; margin-bottom: var(--sp-8); }
.chip {
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill); font-weight: 600; font-size: var(--fs-sm);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2);
  transition: all var(--t-fast);
}
.chip:hover { border-color: var(--forest-300); color: var(--forest-600); }
.chip.active { background: var(--forest-500); color: #fff; border-color: var(--forest-500); box-shadow: var(--sh-glow); }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-5); }
.book-card {
  position: relative; border-radius: var(--r-xl); overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-sm);
  transition: transform var(--t-spring), box-shadow var(--t-base);
  display: flex; flex-direction: column;
}
.book-card:hover { transform: translateY(-6px); box-shadow: var(--sh-lg); }
.book-cover { aspect-ratio: 4/3; display: grid; place-items: center; position: relative; color: #fff; overflow: hidden; }
.book-cover .cover-emoji { font-size: 3rem; filter: drop-shadow(0 6px 12px rgba(0,0,0,.25)); }
.book-cover::after { content:""; position:absolute; inset:0; background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,.28)); }
.book-badge { position: absolute; top: var(--sp-3); left: var(--sp-3); z-index: 2; font-size: var(--fs-xs); font-weight: 700; padding: 3px 10px; border-radius: var(--r-pill); background: rgba(255,255,255,.85); color: #1a5936; backdrop-filter: blur(4px); }
.book-type { position: absolute; top: var(--sp-3); right: var(--sp-3); z-index: 2; font-size: var(--fs-xs); font-weight: 600; padding: 3px 8px; border-radius: var(--r-sm); background: rgba(0,0,0,.35); color: #fff; backdrop-filter: blur(4px); }
.book-body { padding: var(--sp-4); flex: 1; display: flex; flex-direction: column; gap: var(--sp-2); }
.book-title { font-weight: 700; font-family: var(--font-display); font-size: var(--fs-base); line-height: 1.3; }
.book-desc { font-size: var(--fs-sm); color: var(--text-3); flex: 1; }
.book-progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; margin-top: var(--sp-1); }
.book-progress i { display: block; height: 100%; background: var(--grad-sunny); border-radius: inherit; }
.book-read { font-size: var(--fs-xs); color: var(--text-3); display: flex; justify-content: space-between; }

/* ---------- Flashcards ---------- */
.fc-stage { perspective: 1600px; max-width: 460px; margin: 0 auto; }
.flashcard { position: relative; width: 100%; aspect-ratio: 4/3; cursor: pointer; transform-style: preserve-3d; transition: transform var(--t-spring); }
.flashcard.flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: var(--r-2xl); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-3); padding: var(--sp-8); box-shadow: var(--sh-lg); }
.fc-front { background: var(--surface); border: 2px solid var(--border); }
.fc-back { background: var(--grad-hero); color: #fff; transform: rotateY(180deg); border: 2px solid var(--forest-700); }
.fc-emoji { font-size: 4rem; }
.fc-word { font-family: var(--font-display); font-size: var(--fs-4xl); font-weight: 800; }
.fc-hint { font-size: var(--fs-sm); color: var(--text-3); }
.fc-back .fc-word { color: #fff; }
.fc-phon { font-family: var(--font-mono); font-size: var(--fs-lg); opacity: .95; }
.fc-meaning { font-size: var(--fs-xl); font-weight: 600; }
.fc-tools { max-width: 460px; margin: var(--sp-6) auto 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.fc-controls { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); }
.fc-aux { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); }
.fc-count { font-weight: 600; color: var(--text-2); }
.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; flex: 1; }
.progress i { display: block; height: 100%; background: var(--grad-sunny); transition: width var(--t-base); }
.fc-actions { display: flex; gap: var(--sp-2); justify-content: center; }

/* ---------- Quiz ---------- */
.quiz-card { max-width: 640px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-6); box-shadow: var(--sh-md); }
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-5); }
.quiz-q { font-size: var(--fs-lg); margin-bottom: var(--sp-4); }
.quiz-q b { font-family: var(--font-display); color: var(--forest-600); font-size: var(--fs-xl); }
[data-theme="dark"] .quiz-q b { color: var(--forest-300); }
.options { display: grid; gap: var(--sp-3); }
.option {
  text-align: left; padding: var(--sp-4); border-radius: var(--r-md);
  border: 2px solid var(--border); background: var(--surface-2); font-weight: 500; font-size: var(--fs-base);
  transition: all var(--t-fast); display: flex; align-items: center; gap: var(--sp-3);
}
.option:hover:not(:disabled) { border-color: var(--forest-300); background: var(--forest-50); transform: translateX(4px); }
[data-theme="dark"] .option:hover:not(:disabled) { background: rgba(45,143,84,.12); }
.option .key { width: 1.75rem; height: 1.75rem; border-radius: var(--r-sm); background: var(--surface-3); display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); color: var(--text-3); flex-shrink: 0; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.correct .key { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--err); background: var(--err-bg); }
.option.wrong .key { background: var(--err); color: #fff; }
.option:disabled { cursor: default; }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; margin-top: var(--sp-5); }
.score-pill { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill); background: var(--sunny-100); color: var(--sunny-600); font-weight: 700; }
[data-theme="dark"] .score-pill { background: rgba(249,144,7,.16); color: var(--sunny-300); }

/* ---------- Grammar gallery ---------- */
.gram-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: var(--sp-4); }
.gram-thumb { position: relative; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); aspect-ratio: 3/4; cursor: pointer; transition: transform var(--t-base), box-shadow var(--t-base); }
.gram-thumb:hover { transform: translateY(-4px); box-shadow: var(--sh-md); }
.gram-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gram-thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: var(--sp-3); font-size: var(--fs-sm); color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.gram-thumb .open-ic { position: absolute; top: var(--sp-2); right: var(--sp-2); width: 2rem; height: 2rem; border-radius: 50%; background: rgba(0,0,0,.4); color: #fff; display: grid; place-items: center; backdrop-filter: blur(4px); }

/* ---------- Word book (favorites) ---------- */
.wb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: var(--sp-4); }
.word-chip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-1); position: relative; transition: all var(--t-fast); }
.word-chip:hover { border-color: var(--berry-400); transform: translateY(-3px); box-shadow: var(--sh-md); }
.word-chip .w-emoji { font-size: 1.5rem; }
.word-chip .w-word { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); }
.word-chip .w-zh { font-size: var(--fs-sm); color: var(--text-3); }
.word-chip .w-del { position: absolute; top: 6px; right: 6px; width: 1.5rem; height: 1.5rem; border-radius: 50%; color: var(--text-3); display: grid; place-items: center; opacity: .55; transition: opacity var(--t-fast); }
.word-chip:hover .w-del { opacity: 1; }
.word-chip .w-del:hover { color: var(--err); background: var(--err-bg); }
@media (hover: none) { .word-chip .w-del { opacity: 1; } }
.empty { text-align: center; padding: var(--sp-12) var(--sp-4); color: var(--text-3); }
.empty .em { font-size: 3rem; display: block; margin-bottom: var(--sp-3); }

/* ---------- Reader modal ---------- */
.modal { position: fixed; inset: 0; z-index: 200; display: none; }
.modal.open { display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8,18,13,.6); backdrop-filter: blur(6px); animation: fade .25s ease; }
@keyframes fade { from{opacity:0} to{opacity:1} }
.modal-box {
  position: relative; z-index: 2; width: min(1000px, 94vw); height: min(86vh, 720px);
  background: var(--surface); border-radius: var(--r-xl); border: 1px solid var(--border);
  box-shadow: var(--sh-xl); display: flex; flex-direction: column; overflow: hidden;
  animation: pop .3s var(--t-spring);
}
@keyframes pop { from{ transform: translateY(16px) scale(.97); opacity:0 } to{ transform:none; opacity:1 } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.modal-head h3 { font-family: var(--font-display); font-size: var(--fs-lg); }
.modal-head .series-tag { font-size: var(--fs-xs); font-weight: 600; color: var(--forest-600); background: var(--forest-50); padding: 2px 10px; border-radius: var(--r-pill); }
[data-theme="dark"] .modal-head .series-tag { background: rgba(45,143,84,.16); color: var(--forest-300); }
.modal-body { flex: 1; overflow: auto; background: var(--surface-3); position: relative; }
.reader-pdf { width: 100%; height: 100%; border: 0; background: #5a6560; }
.reader-img { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-4); }
.reader-img img { max-width: 100%; border-radius: var(--r-md); box-shadow: var(--sh-md); }
.img-nav { display: flex; align-items: center; gap: var(--sp-4); }
.audio-bar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); }
.audio-bar audio { flex: 1; height: 36px; }
.read-toggle { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill); border: 1px solid var(--border-strong); font-weight: 600; font-size: var(--fs-sm); transition: all var(--t-fast); }
.read-toggle.on { background: var(--ok); color: #fff; border-color: var(--ok); }

/* Lightbox (grammar images) */
.lightbox { position: fixed; inset: 0; z-index: 300; display: none; place-items: center; background: rgba(8,18,13,.85); padding: var(--sp-6); }
.lightbox.open { display: grid; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: var(--r-md); box-shadow: var(--sh-xl); }
.lightbox .lb-close { position: absolute; top: var(--sp-4); right: var(--sp-4); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: var(--sp-6); left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: var(--sp-3) var(--sp-5); border-radius: var(--r-pill); font-weight: 600; font-size: var(--fs-sm); box-shadow: var(--sh-lg); animation: toastIn .3s var(--t-spring); display: inline-flex; align-items: center; gap: var(--sp-2); }
.toast.ok { background: var(--ok); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }
@keyframes toastIn { from{ transform: translateY(20px); opacity:0 } to{ transform:none; opacity:1 } }

/* ---------- Footer ---------- */
.footer { background: var(--surface); border-top: 1px solid var(--border); padding: var(--sp-12) 0 var(--sp-8); margin-top: var(--sp-16); }
.footer-inner { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--sp-4); display: grid; gap: var(--sp-6); }
.footer-top { display: flex; flex-wrap: wrap; gap: var(--sp-4); justify-content: space-between; align-items: center; }
.footer-credits { color: var(--text-3); font-size: var(--fs-sm); }
.footer a { color: var(--forest-600); font-weight: 600; }
[data-theme="dark"] .footer a { color: var(--forest-300); }
.footer-note { color: var(--text-3); font-size: var(--fs-sm); border-top: 1px solid var(--border); padding-top: var(--sp-5); }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s var(--t-slow), transform .6s var(--t-slow); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (min-width: 760px) {
  .nav-links { display: flex; }
  .menu-toggle { display: none; }
  .hero-inner { grid-template-columns: 1.1fr .9fr; }
  .dash-grid { grid-template-columns: 1.3fr 1fr; }
  .stat-cards { grid-template-columns: repeat(4, 1fr); }
  .section-title { font-size: var(--fs-5xl); }
}
@media (min-width: 1040px) {
  .hero-title { font-size: 3.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
