/* ============================================
   Health & Society Study Suite — Premium Minimal
   Inspired by Apple, Linear, Vercel
   ============================================ */

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

:root {
  /* Surfaces */
  --bg: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --bg-tertiary: #F3F4F6;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --surface-overlay: rgba(255, 255, 255, 0.85);

  /* Borders */
  --border: #F0F0F0;
  --border-strong: #E5E7EB;
  --border-hover: #D1D5DB;

  /* Text */
  --ink: #111827;
  --ink-secondary: #374151;
  --muted: #6B7280;
  --faint: #9CA3AF;
  --placeholder: #D1D5DB;

  /* Brand — Indigo */
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --primary-soft: rgba(99, 102, 241, 0.06);
  --primary-medium: rgba(99, 102, 241, 0.12);
  --primary-ring: rgba(99, 102, 241, 0.2);
  --primary-text: #4F46E5;

  /* Semantic */
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.06);
  --success-text: #059669;
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.06);
  --warning-text: #D97706;
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.06);
  --danger-text: #DC2626;
  --info: #3B82F6;
  --info-soft: rgba(59, 130, 246, 0.06);

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 0 3px var(--primary-ring);
  --shadow-card: 0 0 0 1px var(--border), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 0 0 1px var(--border-strong), 0 4px 12px rgba(0, 0, 0, 0.06);

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Typography */
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 350ms;

  /* Layout */
  --nav-height: 56px;
  --tab-height: 64px;
  --content-max: 960px;
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090B;
    --bg-secondary: #111113;
    --bg-tertiary: #18181B;
    --surface: #18181B;
    --surface-raised: #1F1F23;
    --surface-overlay: rgba(24, 24, 27, 0.9);

    --border: #27272A;
    --border-strong: #3F3F46;
    --border-hover: #52525B;

    --ink: #FAFAFA;
    --ink-secondary: #D4D4D8;
    --muted: #A1A1AA;
    --faint: #71717A;
    --placeholder: #52525B;

    --primary: #818CF8;
    --primary-hover: #A5B4FC;
    --primary-soft: rgba(129, 140, 248, 0.08);
    --primary-medium: rgba(129, 140, 248, 0.15);
    --primary-ring: rgba(129, 140, 248, 0.25);
    --primary-text: #A5B4FC;

    --success: #34D399;
    --success-soft: rgba(52, 211, 153, 0.08);
    --success-text: #6EE7B7;
    --warning: #FBBF24;
    --warning-soft: rgba(251, 191, 36, 0.08);
    --warning-text: #FDE68A;
    --danger: #F87171;
    --danger-soft: rgba(248, 113, 113, 0.08);
    --danger-text: #FCA5A5;
    --info: #60A5FA;
    --info-soft: rgba(96, 165, 250, 0.08);

    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 0 0 1px var(--border);
    --shadow-card-hover: 0 0 0 1px var(--border-strong), 0 4px 12px rgba(0, 0, 0, 0.2);
  }
}

/* ---------- Base ---------- */
html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-shell {
  position: relative;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 20px calc(var(--tab-height) + 24px);
}

#app {
  position: relative;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  cursor: pointer;
  background: none;
}

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

/* ---------- Loading ---------- */
.loading-screen {
  min-height: 80dvh;
  display: grid;
  place-items: center;
  gap: 20px;
  text-align: center;
}

.loading-screen h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.loading-screen p {
  color: var(--muted);
  font-size: 0.85rem;
}

.loading-orb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--primary);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   BOTTOM TAB BAR
   ======================================== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: var(--tab-height);
  background: var(--surface-overlay);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color var(--duration-fast) ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.tab-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--primary);
  transition: width var(--duration-normal) var(--ease-out);
}

.tab-item.active {
  color: var(--primary);
}

.tab-item.active::before {
  width: 20px;
}

.tab-icon {
  font-size: 1.25rem;
  line-height: 1;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.tab-item:active .tab-icon {
  transform: scale(0.88);
}

/* ========================================
   HERO — Clean, minimal header
   ======================================== */
.hero {
  position: relative;
  padding: 32px 28px;
  border-radius: var(--radius-xl);
  background: var(--primary);
  color: #FFFFFF;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 50%);
  pointer-events: none;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.hero h1 {
  margin: 16px 0 8px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 800;
}

.hero p {
  max-width: 520px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  line-height: 1.6;
}

.hero-actions,
.action-row,
.mode-grid,
.top-bar-actions,
.control-row,
.setup-pill-row,
.chip-row,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-actions {
  margin-top: 20px;
  gap: 8px;
}

.hero-side {
  display: none;
}

.hero-side-card {
  display: none;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 20px;
}

.metric-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
}

.metric-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value {
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #FFFFFF;
}

/* Hero list items in hero */
.hero-list {
  display: none;
}

/* ========================================
   PAGE STACKS
   ======================================== */
.page-stack,
.dashboard-stack,
.stats-stack,
.setup-stack,
.result-stack {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

/* ========================================
   PANELS & CARDS
   ======================================== */
.panel,
.section-summary,
.card-block,
.quiz-card,
.results-card,
.modal-card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.panel,
.section-summary,
.card-block,
.results-card,
.modal-card {
  padding: 20px;
}

.panel-head,
.stack-head,
.section-head,
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head p,
.stack-head p,
.section-head p,
.soft-text,
.section-summary p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-head h2,
.section-summary h2,
.card-block h3,
.stack-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ========================================
   MODE CARDS
   ======================================== */
.mode-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.mode-card,
.section-card {
  position: relative;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: left;
  transition:
    transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) ease;
}

.mode-card:hover,
.section-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card-hover);
}

.mode-card:active,
.section-card:active {
  transform: translateY(0);
}

/* Tags, chips, badges */
.mode-tag,
.chip,
.section-badge,
.timer-badge,
.study-badge,
.pill,
.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
}

.mode-tag,
.chip,
.section-badge,
.timer-badge,
.study-badge,
.pill {
  padding: 3px 10px;
}

.mode-tag,
.study-badge {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.mode-card h3,
.section-card h3,
.results-card h2,
.quiz-card h2 {
  margin: 10px 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.mode-card p,
.section-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.mode-card .action-row {
  margin-top: 12px;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn,
.ghost-btn,
.icon-btn,
.option-btn {
  transition:
    transform var(--duration-fast) var(--ease-out),
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    opacity var(--duration-fast) ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.8125rem;
  border: 1px solid transparent;
  letter-spacing: -0.01em;
}

.btn:hover {
  transform: translateY(-0.5px);
}

.btn:active {
  transform: translateY(0);
  opacity: 0.85;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.hero .btn-primary {
  background: #FFFFFF;
  color: var(--primary);
}

.hero .btn-primary:hover {
  background: rgba(255, 255, 255, 0.9);
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.btn-secondary:hover {
  background: var(--primary-medium);
}

.hero .btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
}

.hero .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btn-outline {
  border-color: var(--border-strong);
  background: transparent;
  color: var(--ink-secondary);
}

.btn-outline:hover {
  border-color: var(--border-hover);
  background: var(--bg-secondary);
}

.hero .btn-outline {
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

.hero .btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-warm {
  background: var(--warning-soft);
  color: var(--warning-text);
}

.btn-warm:hover {
  background: rgba(245, 158, 11, 0.12);
}

.hero .btn-warm {
  background: rgba(251, 191, 36, 0.2);
  color: #FDE68A;
}

.hero .btn-warm:hover {
  background: rgba(251, 191, 36, 0.28);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger-text);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.btn-success {
  background: var(--success-soft);
  color: var(--success-text);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.12);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.75rem;
  border-radius: var(--radius-xs);
}

.ghost-btn,
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
}

.ghost-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted);
}

.ghost-btn:hover {
  color: var(--ink-secondary);
  border-color: var(--border-strong);
  background: var(--bg-secondary);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  font-size: 0.95rem;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-secondary);
}

.ghost-btn.active,
.shuffle-btn.active,
.bookmark-btn.active {
  color: var(--primary-text);
  background: var(--primary-soft);
  border-color: var(--primary);
}

.shuffle-btn {
  min-height: 36px;
}

/* ========================================
   SECTIONS
   ======================================== */
.section-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.section-card .section-stats,
.section-card .section-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.section-stat {
  min-width: 60px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  background: var(--bg-secondary);
}

.section-stat strong {
  display: block;
  font-size: 0.9rem;
  line-height: 1.1;
  color: var(--primary-text);
  font-weight: 700;
}

.section-stat span {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 0.65rem;
  font-weight: 500;
}

.progress-bar {
  margin-top: 12px;
  width: 100%;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width var(--duration-slow) var(--ease-out);
}

/* ========================================
   DASHBOARD GRID
   ======================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.stack-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}

.chip-row {
  margin-top: 10px;
}

.chip {
  background: var(--bg-secondary);
  color: var(--muted);
  font-weight: 500;
}

.chip strong {
  color: var(--ink);
}

/* Lists */
.hero-list,
.plain-list,
.history-list,
.wrong-list,
.anchor-list,
.pattern-list,
.weak-list {
  display: grid;
  gap: 6px;
}

.hero-list-item,
.plain-item,
.history-item,
.wrong-item,
.anchor-item,
.pattern-item,
.weak-item {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  transition: border-color var(--duration-fast) ease, background var(--duration-fast) ease;
}

.hero-list-item:hover,
.plain-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-tertiary);
}

.hero .hero-list-item {
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.hero .hero-list-item:hover {
  background: rgba(255, 255, 255, 0.14);
}

.hero-list-item strong,
.plain-item strong,
.anchor-item strong,
.weak-item strong,
.wrong-item strong {
  display: block;
  margin-bottom: 3px;
  font-weight: 600;
  font-size: 0.875rem;
}

.hero-list-item span,
.plain-item span,
.anchor-item span,
.pattern-item span,
.weak-item span,
.wrong-item span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.hero .hero-list-item span {
  color: rgba(255, 255, 255, 0.6);
}

/* Section summary */
.section-summary {
  display: grid;
  gap: 20px;
}

.section-head .actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-chip-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.section-chip {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.section-chip strong {
  display: block;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary-text);
}

.section-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 2px;
}

.anchor-list,
.pattern-list,
.weak-list {
  margin-top: 12px;
}

.anchor-item,
.pattern-item,
.weak-item {
  display: grid;
  gap: 3px;
}

.anchor-item em,
.pattern-item em,
.weak-item em {
  font-style: normal;
  font-size: 0.7rem;
  color: var(--faint);
  font-weight: 500;
}

/* ========================================
   TOP BAR
   ======================================== */
.top-bar {
  padding: 0;
  flex-wrap: wrap;
  gap: 12px;
}

.title-wrap h1,
.title-wrap h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.title-wrap p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.top-bar-actions {
  align-items: center;
}

/* Search */
.search-wrap {
  position: relative;
  min-width: 200px;
  flex: 1;
}

.search-wrap input,
.filter-select {
  width: 100%;
  min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 0 12px;
  color: var(--ink);
  outline: 0;
  font-size: 0.8125rem;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.search-wrap input:focus,
.filter-select:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
  background: var(--surface);
}

.search-wrap input {
  padding-left: 36px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 0.85rem;
}

/* ========================================
   STUDY MODE
   ======================================== */
.study-layout,
.quiz-layout,
.stats-layout {
  display: grid;
  gap: 16px;
}

.study-layout {
  grid-template-columns: 1fr;
  margin-top: 16px;
}

.card-stage {
  display: grid;
  gap: 14px;
}

.study-card {
  perspective: 1100px;
}

.study-card-inner {
  position: relative;
  min-height: 340px;
  transform-style: preserve-3d;
  transition: transform 450ms var(--ease-out);
}

.study-card-inner.flipped {
  transform: rotateY(180deg);
}

.study-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.study-face.back {
  transform: rotateY(180deg);
}

.study-face-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary-text);
}

.study-face.back .card-label {
  color: var(--success-text);
}

.study-content {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  line-height: 1.85;
  word-break: keep-all;
  color: var(--ink);
  padding: 8px;
}

.study-face-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--faint);
  font-size: 0.75rem;
}

.control-row {
  justify-content: center;
}

.control-row .btn {
  min-width: 120px;
}

.study-side {
  display: none;
}

.study-info {
  display: grid;
  gap: 8px;
}

.study-info-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.study-info-item strong {
  display: block;
  margin-bottom: 3px;
  font-weight: 600;
  font-size: 0.8125rem;
}

.study-info-item span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.kbd-hints {
  font-size: 0.72rem;
  color: var(--faint);
  text-align: center;
}

.kbd-hints kbd {
  margin: 0 2px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
}

/* ========================================
   SETUP PANELS
   ======================================== */
.setup-panel {
  max-width: var(--content-max);
  margin: 0 auto;
}

.setup-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.setup-card {
  padding: 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.setup-card h3 {
  margin: 0 0 3px;
  font-size: 0.875rem;
  font-weight: 700;
}

.setup-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.75rem;
}

.setup-pill-row {
  margin-top: 8px;
}

.pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--duration-fast) ease;
}

.pill:hover {
  border-color: var(--border-strong);
  color: var(--ink-secondary);
  background: var(--bg-secondary);
}

.pill.active {
  color: #FFFFFF;
  background: var(--primary);
  border-color: var(--primary);
}

.section-check-grid {
  display: grid;
  gap: 4px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  font-size: 0.8125rem;
}

.check-item:hover {
  background: var(--bg-secondary);
}

.check-item input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* ========================================
   QUIZ / MCQ
   ======================================== */
.quiz-card {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 22px;
}

.quiz-meta {
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.quiz-question {
  margin-top: 16px;
  padding: 28px 24px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  line-height: 1.85;
  word-break: keep-all;
}

.quiz-answer,
.explanation-box {
  margin-top: 12px;
  padding: 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 0.875rem;
}

.option-list {
  margin-top: 16px;
  display: grid;
  gap: 6px;
}

.option-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.5;
  transition: all var(--duration-fast) ease;
}

.option-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-secondary);
}

.option-letter {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  color: var(--muted);
  font-weight: 700;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
}

.option-btn.correct {
  border-color: var(--success);
  background: var(--success-soft);
}

.option-btn.correct .option-letter {
  background: var(--success-soft);
  color: var(--success-text);
}

.option-btn.incorrect {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.option-btn.incorrect .option-letter {
  background: var(--danger-soft);
  color: var(--danger-text);
}

.timer-badge {
  background: var(--warning-soft);
  color: var(--warning-text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ========================================
   RESULTS
   ======================================== */
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.score-ring {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 4px solid var(--primary-soft);
  display: grid;
  place-items: center;
  text-align: center;
  background: var(--surface);
  flex-shrink: 0;
}

.score-ring strong {
  display: block;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--primary-text);
  font-weight: 800;
}

.score-ring span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

/* Charts */
.chart-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.chart-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: center;
}

.chart-row .label {
  color: var(--ink-secondary);
  font-size: 0.75rem;
  text-align: right;
  font-weight: 500;
}

.track {
  position: relative;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  overflow: hidden;
}

.track .fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width var(--duration-slow) var(--ease-out);
}

.track .value {
  position: absolute;
  inset: 0 8px 0 auto;
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

/* Stats grid */
.stats-grid,
.mini-stats {
  display: grid;
  gap: 10px;
}

.stat-card,
.mini-stat {
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.stat-label,
.mini-stat .label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value,
.mini-stat .value {
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

/* History & wrong items */
.history-item,
.wrong-item,
.weak-item,
.anchor-item {
  display: grid;
  gap: 4px;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.75rem;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
  padding: 32px 24px;
  border-radius: var(--radius-md);
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  color: var(--muted);
  background: var(--bg-secondary);
  font-size: 0.875rem;
}

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
  animation: modal-bg-in 150ms ease;
}

@keyframes modal-bg-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: min(400px, 100%);
  animation: modal-card-in 250ms var(--ease-spring);
}

@keyframes modal-card-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.modal-card p {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* ========================================
   ANIMATION
   ======================================== */
.fade-in {
  animation: fade-in 200ms var(--ease-out);
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (min-width: 768px) {
  .app-shell {
    padding: 32px 24px 48px;
  }

  .dashboard-grid {
    grid-template-columns: 1.2fr 0.8fr;
  }

  .study-layout {
    grid-template-columns: 1fr 280px;
  }

  .study-side {
    display: grid;
    gap: 14px;
  }

  .hero-metrics {
    grid-template-columns: repeat(4, 1fr);
  }

  .tab-bar {
    display: none;
  }

  .app-shell {
    padding-bottom: 48px;
  }
}

@media (max-width: 767px) {
  .app-shell {
    padding: 16px 14px calc(var(--tab-height) + 20px);
  }

  .hero {
    padding: 24px 20px;
    border-radius: var(--radius-lg);
  }

  .hero h1 {
    font-size: 1.35rem;
  }

  .hero-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel,
  .section-summary,
  .card-block,
  .results-card,
  .quiz-card {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .mode-grid,
  .section-grid {
    grid-template-columns: 1fr;
  }

  .section-chip-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .setup-grid,
  .stack-grid {
    grid-template-columns: 1fr;
  }

  .chart-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .chart-row .label {
    text-align: left;
  }

  .search-wrap {
    min-width: 0;
    width: 100%;
  }

  .control-row .btn {
    min-width: 0;
    flex: 1 1 100px;
  }

  .study-card-inner {
    min-height: 300px;
  }

  .score-ring {
    width: 90px;
    height: 90px;
  }

  .score-ring strong {
    font-size: 1.35rem;
  }

  .title-wrap h1,
  .title-wrap h2 {
    font-size: 1.125rem;
  }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--primary-medium);
  color: var(--primary-text);
}

/* ---------- Focus visible ---------- */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible {
  outline-offset: 2px;
}
