:root {
  --bg: #f6efe3;
  --paper: rgba(255, 252, 247, 0.9);
  --card: #fffaf2;
  --ink: #1e2a23;
  --muted: #6c746d;
  --brand: #134b3a;
  --brand-2: #d7672b;
  --brand-soft: #dbe9dd;
  --ok: #1f7a4f;
  --ok-soft: #e4f5ea;
  --bad: #a53b2e;
  --bad-soft: #fbe4e0;
  --line: rgba(19, 75, 58, 0.12);
  --shadow: 0 20px 60px rgba(44, 35, 19, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(215, 103, 43, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(19, 75, 58, 0.16), transparent 28%),
    linear-gradient(180deg, #f7f1e7 0%, #efe4d2 100%);
  min-height: 100vh;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hero {
  padding: 12px 4px 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.2rem);
  line-height: 1.05;
}

.hero-copy {
  margin: 14px 0 0;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--muted);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 16px;
  font-size: 0.92rem;
}

.hero-links a {
  color: var(--brand);
  font-weight: 700;
}

.hero-links span {
  color: var(--muted);
}

/* ─── hero top row ─── */
.hero-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ─── language toggle ─── */
.lang-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--brand-soft);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px;
  cursor: pointer;
  font-family: inherit;
  user-select: none;
  flex-shrink: 0;
}

.lang-option {
  position: relative;
  z-index: 1;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  transition: color 0.25s ease;
  white-space: nowrap;
}

.lang-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--brand);
  border-radius: 16px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Default: ZH is active */
.lang-toggle .lang-option[data-lang="zh"] {
  color: #fff;
}

.lang-toggle.en-active .lang-option[data-lang="zh"] {
  color: var(--muted);
}

.lang-toggle.en-active .lang-option[data-lang="en"] {
  color: #fff;
}

.lang-toggle.en-active .lang-slider {
  transform: translateX(100%);
}

.panel {
  background: var(--paper);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 28px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 18px;
}

.section-title h2 {
  margin: 0;
  font-size: 1.15rem;
}

.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.category-title {
  margin-top: 22px;
}

.mode-grid,
.chip-grid,
.options,
.review-list {
  display: grid;
  gap: 12px;
}

.mode-grid {
  margin-top: 16px;
}

.mode-card,
.chip,
.option-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 20px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.mode-card {
  padding: 16px;
  text-align: left;
}

.mode-card strong,
.chip strong {
  display: block;
  font-size: 1rem;
}

.mode-card span,
.chip span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.mode-card.selected,
.chip.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

.chip-grid {
  margin: 16px 0 22px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chip {
  padding: 14px;
  text-align: left;
}

.primary-btn,
.ghost-btn {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 15px 18px;
  font-size: 1rem;
  font-weight: 800;
  font-family: inherit;
}

.primary-btn {
  background: linear-gradient(135deg, var(--brand) 0%, #21624f 100%);
  color: white;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.quiz-topbar,
.question-meta,
.quiz-actions,
.result-actions,
.result-stats {
  display: flex;
  gap: 12px;
}

.quiz-topbar,
.result-stats {
  justify-content: space-between;
}

.mini-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.progress-track {
  height: 10px;
  background: rgba(19, 75, 58, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0 18px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  transition: width 0.2s ease;
}

.question-card {
  background: var(--card);
  border-radius: 24px;
  padding: 18px;
  border: 1px solid rgba(19, 75, 58, 0.08);
}

.question-meta {
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.86rem;
  font-weight: 700;
}

.source {
  color: var(--muted);
  font-size: 0.84rem;
}

.question-card h2 {
  margin: 0 0 18px;
  font-size: 1.3rem;
  line-height: 1.5;
}

.option-btn {
  width: 100%;
  padding: 15px 16px;
  text-align: left;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.55;
}

.option-btn.correct {
  background: var(--ok-soft);
  border-color: rgba(31, 122, 79, 0.35);
}

.option-btn.wrong {
  background: var(--bad-soft);
  border-color: rgba(165, 59, 46, 0.3);
}

.option-btn:disabled {
  opacity: 1;
}

.feedback {
  margin-top: 16px;
  padding: 16px;
  border-radius: 20px;
  line-height: 1.7;
  font-size: 0.95rem;
}

.feedback.correct {
  background: var(--ok-soft);
  color: var(--ok);
}

.feedback.wrong {
  background: var(--bad-soft);
  color: var(--bad);
}

.quiz-actions,
.result-actions {
  margin-top: 18px;
}

.quiz-actions .ghost-btn,
.quiz-actions .primary-btn,
.result-actions .ghost-btn,
.result-actions .primary-btn {
  width: 50%;
}

.result-hero {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(19, 75, 58, 0.1), rgba(215, 103, 43, 0.14));
}

.result-hero h2,
.result-hero p {
  margin: 0;
}

.result-hero p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.result-stats {
  margin: 18px 0;
  flex-wrap: wrap;
}

.stat-box {
  flex: 1 1 140px;
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--line);
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-box strong {
  display: block;
  margin-top: 8px;
  font-size: 1.4rem;
}

.review-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
}

.review-item h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.6;
}

.review-item p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.92rem;
}

.hidden {
  display: none;
}

button {
  cursor: pointer;
}

@media (hover: hover) {
  .mode-card:hover,
  .chip:hover,
  .option-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(19, 75, 58, 0.28);
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 18px 12px 36px;
  }

  .panel {
    padding: 16px;
    border-radius: 24px;
  }

  .chip-grid {
    grid-template-columns: 1fr 1fr;
  }

  .quiz-actions,
  .result-actions {
    flex-direction: column;
  }

  .quiz-actions .ghost-btn,
  .quiz-actions .primary-btn,
  .result-actions .ghost-btn,
  .result-actions .primary-btn {
    width: 100%;
  }
}
