:root {
  --bg: #0d0709;
  --bg-2: #1a0c10;
  --panel: #241218;
  --panel-2: #2e171c;
  --burgundy: #6b1d2a;
  --burgundy-bright: #8e2435;
  --gold: #c9a227;
  --gold-soft: #e8d48b;
  --parchment: #f3e6c8;
  --parchment-dim: #cbb992;
  --ink: #f5efe3;
  --muted: #a89888;
  --line: rgba(201, 162, 39, 0.28);
  --success: #3d8b5a;
  --danger: #a33a3a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font-display: "Cinzel", "Noto Sans SC", serif;
  --font-body: "Cormorant Garamond", "Noto Sans SC", Georgia, serif;
  --font-ui: "Noto Sans SC", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
}

body {
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(142, 36, 53, 0.35), transparent 60%),
    radial-gradient(ellipse 40% 30% at 90% 20%, rgba(201, 162, 39, 0.12), transparent 50%),
    radial-gradient(ellipse 40% 40% at 10% 80%, rgba(107, 29, 42, 0.25), transparent 50%),
    linear-gradient(180deg, #12080b 0%, #0d0709 100%);
  z-index: -1;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(13, 7, 9, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  color: var(--gold);
  font-size: 1.1rem;
  background: linear-gradient(145deg, var(--burgundy), #2a0d12);
  box-shadow: 0 0 18px rgba(201, 162, 39, 0.25);
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--gold-soft);
}

.brand-sub {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

a.nav-btn {
  text-decoration: none;
  display: inline-block;
}

a.brand {
  text-decoration: none;
  color: inherit;
}

.nav-btn {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--parchment-dim);
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-btn:hover {
  color: var(--parchment);
  border-color: var(--line);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--burgundy), var(--burgundy-bright));
  color: var(--parchment);
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(142, 36, 53, 0.4);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.view { display: none; animation: fadeIn 0.35s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.hero {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(46, 23, 28, 0.9), rgba(26, 12, 16, 0.95));
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.eyebrow {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.75rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.25;
  margin: 0 0 1rem;
  color: var(--parchment);
}

.gold { color: var(--gold); }

.lead {
  max-width: 36rem;
  margin: 0 auto 1.75rem;
  color: var(--parchment-dim);
  font-size: 1.1rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 520px;
  margin: 0 auto;
}

.stat-card {
  padding: 0.85rem 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.stat-num {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--gold-soft);
}

.stat-label {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--gold-soft);
  margin: 0 0 1rem;
  letter-spacing: 0.04em;
}

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

.book-card {
  text-align: left;
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  color: inherit;
  cursor: pointer;
  transition: 0.25s ease;
  font-family: inherit;
  box-shadow: var(--shadow);
}

.book-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 16px 36px rgba(201, 162, 39, 0.15);
}

.book-num {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.08em;
}

.book-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0.35rem 0 0.15rem;
  color: var(--parchment);
}

.book-zh {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--parchment-dim);
  margin: 0 0 0.75rem;
}

.book-count {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--muted);
}

.panel-head {
  margin-bottom: 1.25rem;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--gold-soft);
  margin: 0 0 0.35rem;
}

.muted { color: var(--muted); font-family: var(--font-ui); font-size: 0.85rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(36, 18, 24, 0.7);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--muted);
}

.field.grow { flex: 1; min-width: 180px; }

.field.check {
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  padding-bottom: 0.45rem;
  color: var(--parchment-dim);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.field.check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.field.check .check-ui {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1.5px solid rgba(201, 162, 39, 0.55);
  background: linear-gradient(145deg, #1a0c10, #2a1016);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(107, 29, 42, 0.35);
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.field.check .check-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(145deg, #8a6b2a, #c9a227 45%, #e8d48b);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45), 0 0 8px rgba(201, 162, 39, 0.25);
  transition: transform 0.22s ease, background 0.22s ease;
}

.field.check input[type="checkbox"]:checked + .check-ui {
  border-color: var(--gold);
  background: linear-gradient(145deg, var(--burgundy), var(--burgundy-bright));
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.35),
    0 0 14px rgba(201, 162, 39, 0.35);
}

.field.check input[type="checkbox"]:checked + .check-ui::after {
  transform: translateX(18px);
  background: linear-gradient(145deg, #e8d48b, #c9a227 55%, #f5e6b0);
}

.field.check input[type="checkbox"]:focus-visible + .check-ui {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.field.check:hover .check-ui {
  border-color: var(--gold-soft);
}

.field.check .check-label {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--parchment-dim);
}

.field input[type="search"],
.field input[type="text"],
.field select,
#quiz-input {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #12090c;
  color: var(--parchment);
  outline: none;
  min-width: 140px;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color: var(--parchment);
  cursor: pointer;
  padding-right: 2rem;
  background-color: #12090c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23c9a227' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 10px 6px;
  color-scheme: dark;
}

.field select option {
  background: #1a0c10;
  color: var(--parchment);
}

.field input:focus,
.field select:focus,
#quiz-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2);
}

.btn {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--parchment);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: 0.2s ease;
}

.btn:hover { border-color: var(--gold); color: var(--gold-soft); }
.btn.primary {
  background: linear-gradient(135deg, var(--burgundy), var(--burgundy-bright));
  border-color: var(--gold);
}
.btn.ghost { background: transparent; }
.btn.success { background: rgba(61, 139, 90, 0.25); border-color: var(--success); color: #9fd4b0; }
.btn.danger { background: rgba(163, 58, 58, 0.25); border-color: var(--danger); color: #f0a0a0; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.az-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.85rem;
}

.az-bar button {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.25);
  color: var(--parchment-dim);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  cursor: pointer;
}

.az-bar button:hover,
.az-bar button.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(107, 29, 42, 0.4);
}

.list-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
}

.pager { display: flex; align-items: center; gap: 0.5rem; }

.word-table-wrap {
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(18, 9, 12, 0.7);
  max-height: 60vh;
}

.word-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.word-table th {
  position: sticky;
  top: 0;
  background: #2a141a;
  color: var(--gold);
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}

.word-table td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid rgba(201, 162, 39, 0.1);
  color: var(--parchment);
}

.word-table tr:hover td { background: rgba(142, 36, 53, 0.15); }

.word-table .speak-btn {
  border: none;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  font-size: 1rem;
}

.flash-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--muted);
}

.flash-stats .know { color: #9fd4b0; }
.flash-stats .dont { color: #f0a0a0; }

.flash-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.flash-card {
  width: min(420px, 100%);
  min-height: 260px;
  border-radius: 18px;
  border: 2px solid var(--gold);
  background:
    radial-gradient(circle at 30% 20%, rgba(201, 162, 39, 0.12), transparent 50%),
    linear-gradient(160deg, #3a1a22, #1a0c10);
  box-shadow: var(--shadow), 0 0 40px rgba(201, 162, 39, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  user-select: none;
}

.flash-face { text-align: center; width: 100%; }
.flash-face.hidden { display: none; }

.flash-hint {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1rem;
  letter-spacing: 0.06em;
}

.flash-word {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  color: var(--parchment);
  word-break: break-word;
}

.flash-book-tag {
  margin-top: 1rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--gold);
}

.flash-note {
  margin-top: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--parchment-dim);
}

.flash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.quiz-panel, .quiz-result {
  margin-top: 1rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(36, 18, 24, 0.75);
}

.hidden { display: none !important; }

.quiz-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
}

.quiz-progress .bar {
  flex: 1;
  min-width: 120px;
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.quiz-progress .fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--burgundy), var(--gold));
  transition: width 0.3s ease;
}

.quiz-prompt { text-align: center; margin-bottom: 1.25rem; }

.quiz-target {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--gold-soft);
  margin-top: 0.5rem;
}

.quiz-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
}

.quiz-choices button {
  font-family: var(--font-ui);
  font-size: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #12090c;
  color: var(--parchment);
  cursor: pointer;
  transition: 0.15s ease;
}

.quiz-choices button:hover:not(:disabled) {
  border-color: var(--gold);
}

.quiz-choices button.correct {
  border-color: var(--success);
  background: rgba(61, 139, 90, 0.3);
}

.quiz-choices button.wrong {
  border-color: var(--danger);
  background: rgba(163, 58, 58, 0.3);
}

.quiz-type-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

#quiz-input { min-width: min(280px, 100%); flex: 1; }

.quiz-feedback {
  text-align: center;
  font-family: var(--font-ui);
  min-height: 1.5rem;
  margin-top: 1rem;
}

.quiz-result { text-align: center; }
.quiz-result h3 {
  font-family: var(--font-display);
  color: var(--gold-soft);
  margin-top: 0;
}

.result-score {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--gold);
  margin: 0.5rem 0;
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.dl-card {
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow);
}

.dl-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--gold-soft);
  margin: 0 0 0.75rem;
}

.dl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .site-header { padding: 0.75rem 1rem; }
  .nav-btn { font-size: 0.7rem; padding: 0.4rem 0.65rem; }
  .hero-stats { grid-template-columns: 1fr; max-width: 220px; }
  .flash-actions .btn { flex: 1 1 40%; }
}

/* Language switcher */
.lang-switcher {
  display: flex;
  align-items: center;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--parchment-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.55rem 0.35rem 0.7rem;
  background: rgba(36, 18, 24, 0.75);
  min-height: calc(0.78rem + 0.9rem);
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lang-switch:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2);
}

.lang-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-soft);
  line-height: 1;
  flex-shrink: 0;
}

.lang-icon .lang-globe {
  display: block;
  opacity: 0.9;
}

.lang-switch select {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  line-height: 1.2;
  border: none;
  color: var(--parchment);
  outline: none;
  cursor: pointer;
  min-width: 7.25rem;
  width: auto;
  max-width: none;
  padding: 0.1rem 1.35rem 0.1rem 0.1rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23c9a227' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.2rem center;
  background-size: 10px 6px;
  color-scheme: dark;
  vertical-align: middle;
}

.lang-switch select::-ms-expand {
  display: none;
}

.lang-switch select:focus {
  outline: none;
}

.lang-switch select option {
  background: #1a0c10;
  color: var(--parchment);
}

.footer-note {
  margin: 0.5rem 0 0;
  opacity: 0.85;
}

@media (max-width: 900px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
  }
  .lang-switcher {
    align-self: flex-end;
  }
}
