/* =====================================================
   THEME VARIABLES
   ===================================================== */
:root {
  --bg:              #f0f2f5;
  --bg-secondary:    #ffffff;
  --text:            #111214;
  --text-muted:      #6b7280;
  --border:          #e2e5ea;
  --card:            #ffffff;
  --card-front:      #eef1ff;
  --card-shadow:     0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  --accent:          #2563eb;
  --accent-dim:      #dbeafe;
  --correct:         #16a34a;
  --correct-bg:      #dcfce7;
  --incorrect:       #dc2626;
  --incorrect-bg:    #fee2e2;
  --warning:         #d97706;
  --nav-bg:          rgba(255,255,255,0.96);
  --nav-border:      #e2e5ea;
  --header-bg:       rgba(255,255,255,0.92);
  --tag-bg:          #dbeafe;
  --tag-text:        #1d4ed8;
  --highlight:       #fef9c3;
  --overlay:         rgba(0,0,0,0.45);
  --section-1:       #2563eb;
  --section-2:       #16a34a;
  --section-3:       #d97706;
  --section-4:       #7c3aed;
  --section-5:       #db2777;
  --section-6:       #0891b2;
  --section-7:       #ea580c;
  --radius-sm:       10px;
  --radius-md:       14px;
  --radius-lg:       18px;
}

body.dark-theme {
  --bg:              #0f1117;
  --bg-secondary:    #161b27;
  --text:            #f0f2f5;
  --text-muted:      #8892a0;
  --border:          #232c3b;
  --card:            #1a2233;
  --card-front:      #1e2d4a;
  --card-shadow:     0 1px 6px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
  --accent:          #60a5fa;
  --accent-dim:      #172554;
  --correct:         #4ade80;
  --correct-bg:      #052e16;
  --incorrect:       #f87171;
  --incorrect-bg:    #2d1515;
  --warning:         #fbbf24;
  --nav-bg:          rgba(15,17,23,0.97);
  --nav-border:      #232c3b;
  --header-bg:       rgba(15,17,23,0.94);
  --tag-bg:          #172554;
  --tag-text:        #93c5fd;
  --highlight:       #2d2a10;
  --overlay:         rgba(0,0,0,0.65);
  --section-1:       #60a5fa;
  --section-2:       #4ade80;
  --section-3:       #fbbf24;
  --section-4:       #a78bfa;
  --section-5:       #f472b6;
  --section-6:       #38bdf8;
  --section-7:       #fb923c;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-wrap: break-word;
  word-break: break-word;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
  padding-top: 56px;
  padding-bottom: 76px;
}

img, svg { display: block; }
button, select, input { font-family: inherit; }

/* =====================================================
   TOP HEADER
   ===================================================== */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.25s;
}

#app-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

#theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#theme-toggle:active { background: var(--accent-dim); }

#mute-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  margin-right: 2px;
}
#mute-toggle:hover { color: var(--text); background: var(--accent-dim); }
#mute-toggle.muted { color: var(--incorrect); }

.header-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.music-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#music-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
}
#music-toggle:hover { background: var(--accent-dim); }
#music-toggle.playing { color: var(--accent); }

#music-volume {
  -webkit-appearance: none;
  appearance: none;
  width: 64px;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.2s;
}
#music-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
#music-volume::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

mark.note-highlight {
  background: #fef08a;
  color: #1a1a1a;
  border-radius: 2px;
  padding: 0 2px;
}
body.dark-theme mark.note-highlight {
  background: #713f12;
  color: #fef9c3;
}

.recent-misses-section h3 { margin: 0 0 4px 0; font-size: 15px; }
.progress-section-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 12px 0; }

.collapsible-section { border: none; padding: 0; margin: 0; }
.collapsible-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  padding: 6px 2px;
  list-style: none;
  user-select: none;
}
.collapsible-summary::-webkit-details-marker { display: none; }
.collapsible-summary::before {
  content: '▶';
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.2s;
  display: inline-block;
}
details[open] .collapsible-summary::before { transform: rotate(90deg); }
.collapsible-count {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

.recent-miss-list { display: flex; flex-direction: column; gap: 8px; }
.recent-miss-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.recent-miss-item:hover { border-color: var(--accent); background: var(--accent-dim); }
.recent-miss-q { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; line-height: 1.4; }
.recent-miss-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.recent-miss-ans { font-size: 11.5px; color: var(--correct); }
.recent-miss-section { font-size: 11.5px; color: var(--text-muted); }

body.dark-theme #icon-sun  { display: none; }
body.dark-theme #icon-moon { display: block !important; }
body:not(.dark-theme) #icon-sun  { display: block; }
body:not(.dark-theme) #icon-moon { display: none !important; }

/* =====================================================
   BOTTOM NAV
   ===================================================== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--nav-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: background 0.25s;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 0;
  font-size: 10px;
  font-weight: 500;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}

.nav-btn.active { color: var(--accent); }
.nav-btn:active { opacity: 0.7; }

/* =====================================================
   BACK TO TOP
   ===================================================== */
#back-to-top {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 90;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

#back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* =====================================================
   PAGE CONTAINER
   ===================================================== */
#app-content {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  min-height: calc(100vh - 128px);
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeUp 0.22s ease both; }

/* =====================================================
   HERO CARD
   ===================================================== */
.hero-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin-bottom: 14px;
}

.hero-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.hero-card h2 {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}

.hero-card p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
}

/* =====================================================
   CHIPS
   ===================================================== */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.chip {
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

/* =====================================================
   SEARCH
   ===================================================== */
.search-wrap {
  display: block;
  margin-bottom: 14px;
}

.search-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.search-input {
  width: 100%;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  box-shadow: var(--card-shadow);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

/* =====================================================
   SECTION CARDS (study home)
   ===================================================== */
.section-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  padding: 15px 16px;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s;
  -webkit-tap-highlight-color: transparent;
}

.section-card:active {
  transform: scale(0.985);
  box-shadow: none;
}

.section-card[data-section="0"] { border-left-color: var(--section-1); }
.section-card[data-section="1"] { border-left-color: var(--section-2); }
.section-card[data-section="2"] { border-left-color: var(--section-3); }
.section-card[data-section="3"] { border-left-color: var(--section-4); }
.section-card[data-section="4"] { border-left-color: var(--section-5); }
.section-card[data-section="5"] { border-left-color: var(--section-6); }
.section-card[data-section="6"] { border-left-color: var(--section-7); }

.section-card-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 2px;
}

.section-card-source {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 7px;
}

.section-card-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.section-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.stat-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-weight: 600;
  white-space: nowrap;
}

/* =====================================================
   STUDY SECTION DETAIL — HEADER
   ===================================================== */
.study-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.study-header > div {
  flex: 1;
  min-width: 0;
}

.study-header h2 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: break-word;
}

.back-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow);
  transition: background 0.15s;
}

.back-btn:active { background: var(--bg); }

.note-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* =====================================================
   NOTES CONTAINER
   ===================================================== */
.notes-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  padding: 18px;
  margin-bottom: 12px;
}

.note-chip-row {
  margin-top: 0;
  margin-bottom: 14px;
}

.study-intro {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* =====================================================
   QUICK FACTS GRID
   ===================================================== */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.fact-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}

.fact-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.fact-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  overflow-wrap: break-word;
}

/* =====================================================
   NOTE BLOCKS — accordion style
   ===================================================== */
.study-block {
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.study-block:last-child { margin-bottom: 0; }

.study-block-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.study-block-summary::-webkit-details-marker { display: none; }

.study-block-summary::after {
  content: '›';
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.study-block[open] > .study-block-summary {
  border-bottom-color: var(--border);
  background: var(--card);
}

.study-block[open] > .study-block-summary::after {
  transform: rotate(90deg);
}

.study-block-summary:hover {
  background: var(--card);
}

.study-block-body {
  padding: 14px 16px;
  background: var(--card);
}

.study-para {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text);
  margin: 0 0 12px 0;
  overflow-wrap: break-word;
}

.study-para:last-child { margin-bottom: 0; }

.note-subheading {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin: 18px 0 8px 0;
  line-height: 1.4;
}
.note-subheading:first-child { margin-top: 0; }
.note-subheading-num {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

.note-list {
  list-style: disc;
  padding-left: 22px;
  margin: 8px 0 12px 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
}
.note-list li {
  margin-bottom: 6px;
  padding-left: 4px;
}
.note-list li:last-child { margin-bottom: 0; }

.note-sublist {
  list-style: circle;
  padding-left: 20px;
  margin: 4px 0 4px 0;
}
.note-sublist li {
  margin-bottom: 3px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── TEST PARAMETERS BLOCK ─────────────────────────────────────── */
.params-block {
  margin: 0 0 18px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.params-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.params-summary::-webkit-details-marker { display: none; }

.params-summary::after {
  content: '›';
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.params-block[open] > .params-summary {
  border-bottom-color: var(--border);
  background: var(--card);
}

.params-block[open] > .params-summary::after {
  transform: rotate(90deg);
}

.params-summary:hover { background: var(--card); }

.params-body {
  padding: 14px 16px;
  background: var(--card);
}

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 10px;
}

.params-table th,
.params-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  line-height: 1.4;
}

.params-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.params-table tr:last-child td { border-bottom: none; }

.params-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  font-style: italic;
}

/* legacy bullets (used outside notes) */
.study-bullets {
  padding-left: 18px;
  margin: 0;
}

.study-bullets li {
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 7px;
  color: var(--text);
  overflow-wrap: break-word;
}

.study-bullets li:last-child { margin-bottom: 0; }

/* =====================================================
   SEARCH RESULTS
   ===================================================== */
.search-mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 700;
}

.search-hit {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-hit:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,179,237,0.15);
}

.search-hit-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.search-hit-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}

.search-hit-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.search-hit-excerpt {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  margin: 0;
  overflow-wrap: break-word;
}

/* quiz setup "ready set" block inside notes-container */
.notes-container > h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}

/* =====================================================
   JUMP-TO-PRACTICE CARD
   ===================================================== */
.quiz-jump-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  padding: 18px;
  margin-bottom: 12px;
}

.quiz-jump-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 5px;
}

.quiz-jump-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.paired-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 14px;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn-primary,
.quiz-section-btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
  font-family: inherit;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
  font-family: inherit;
}

.btn-primary:active,
.quiz-section-btn:active,
.btn-secondary:active { opacity: 0.75; }

.notes-container .quiz-section-btn { margin-top: 16px; }

/* =====================================================
   QUIZ — CONTROLS
   ===================================================== */
.quiz-controls {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 14px;
}

.quiz-controls select,
.flashcard-controls select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  outline: none;
  box-shadow: var(--card-shadow);
}

.shuffle-btn {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: var(--card-shadow);
  font-family: inherit;
}

.shuffle-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* =====================================================
   QUIZ — PROGRESS
   ===================================================== */
.quiz-progress {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}

.quiz-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 14px;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* =====================================================
   QUIZ — QUESTION CARD
   ===================================================== */
.quiz-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  padding: 18px;
}

.quiz-question-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.quiz-question-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 16px;
  overflow-wrap: break-word;
}

/* =====================================================
   QUIZ — CHOICES
   ===================================================== */
.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-choice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  width: 100%;
  color: var(--text);
  transition: border-color 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.quiz-choice:not(.disabled):active { opacity: 0.8; }
.quiz-choice.disabled { cursor: default; }

.quiz-choice .choice-key {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  transition: all 0.12s;
}

.quiz-choice.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}

.quiz-choice.correct .choice-key {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.quiz-choice.incorrect {
  border-color: var(--incorrect);
  background: var(--incorrect-bg);
}

.quiz-choice.incorrect .choice-key {
  background: var(--incorrect);
  border-color: var(--incorrect);
  color: #fff;
}

.quiz-choice.correct.disabled,
.quiz-choice.incorrect.disabled { opacity: 1; }
.quiz-choice.disabled:not(.correct):not(.incorrect) { opacity: 0.5; }

/* =====================================================
   QUIZ — EXPLANATION + NEXT
   ===================================================== */
.quiz-explanation {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--highlight);
  border-left: 3px solid var(--warning);
  font-size: 13px;
  line-height: 1.65;
}

.quiz-explanation.visible { display: block; }

.quiz-next-btn {
  display: none;
  width: 100%;
  padding: 13px;
  margin-top: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.quiz-next-btn.visible { display: block; }
.quiz-next-btn:active { opacity: 0.8; }

/* =====================================================
   QUIZ — SUMMARY
   ===================================================== */
.quiz-summary { text-align: center; }

.quiz-summary-score {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin: 12px 0 4px;
  letter-spacing: -2px;
}

.quiz-summary-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.summary-section-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-bottom: 22px;
}

.summary-bar-row { font-size: 13px; }

.summary-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-weight: 600;
}

.summary-bar-track {
  height: 7px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.summary-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.quiz-summary-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 6px;
}

/* =====================================================
   MISSED QUESTIONS
   ===================================================== */
.missed-questions {
  margin-top: 20px;
  text-align: left;
}

.missed-questions h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  color: var(--incorrect);
}

.missed-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.missed-item-q {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 5px;
  line-height: 1.45;
  overflow-wrap: break-word;
}

.missed-item-a {
  font-size: 13px;
  color: var(--correct);
  font-weight: 500;
  overflow-wrap: break-word;
}

/* =====================================================
   FLASHCARDS
   ===================================================== */
.flashcard-controls {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 14px;
}

.flashcard-progress-text {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.5;
}

.flashcard-scene {
  perspective: 900px;
  width: 100%;
  height: 240px;
  margin-bottom: 14px;
}

.flashcard {
  width: 100%;
  height: 240px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
  cursor: pointer;
}

.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  text-align: center;
  overflow: hidden;
}

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

.flashcard-front { background: var(--card-front); }

.flashcard-face .card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.flashcard-face .card-content {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

.flashcard-back .card-content {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
}

.flashcard-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
  opacity: 0.75;
}

.flashcard-nav {
  display: flex;
  gap: 9px;
  margin-bottom: 10px;
}

.flashcard-nav button {
  flex: 1;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: background 0.15s;
  font-family: inherit;
}

.flashcard-nav button:active { background: var(--bg); }

.flashcard-actions {
  display: flex;
  gap: 9px;
}

.fc-btn-know {
  flex: 1;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--correct);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.fc-btn-review {
  flex: 1;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--warning);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.fc-btn-know:active,
.fc-btn-review:active { opacity: 0.8; }

/* =====================================================
   PROGRESS DASHBOARD
   ===================================================== */
.progress-header {
  text-align: center;
  margin-bottom: 20px;
}

.progress-score-ring {
  position: relative;
  width: 130px;
  height: 130px;
  margin: 0 auto 10px;
}

.progress-score-ring svg {
  transform: rotate(-90deg);
  width: 130px;
  height: 130px;
}

.progress-score-ring .ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.progress-score-ring .ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.progress-score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
}

.progress-score-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-score-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.stat-card .stat-num .stat-denom {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.progress-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 15px;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  text-align: center;
}

.stat-card .stat-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.35;
}

.progress-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.progress-sections {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.progress-section-row {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
}

.progress-section-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.progress-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.weak-areas { margin-bottom: 20px; }

.weak-areas h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.weak-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 7px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--card-shadow);
}

.weak-item-section {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.reset-btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: 2px solid var(--incorrect);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--incorrect);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  margin-bottom: 20px;
}

.reset-btn:active { background: var(--incorrect-bg); }

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.modal-box h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-box p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.modal-cancel {
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.modal-confirm {
  border: none;
  background: var(--incorrect);
  color: #fff;
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state-text { font-size: 14px; line-height: 1.6; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (min-width: 580px) {
  #app-content { padding: 20px; }

  .section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .quiz-controls { flex-direction: row; flex-wrap: wrap; }
  .quiz-controls select { flex: 1; min-width: 0; }

  .flashcard-controls { flex-direction: row; flex-wrap: wrap; }
  .flashcard-controls select { flex: 1; min-width: 0; }

  .flashcard-scene,
  .flashcard { height: 280px; }
}

@media (min-width: 800px) {
  #app-content { padding: 24px; }
  .section-grid { grid-template-columns: 1fr 1fr 1fr; }
  .hero-card h2 { font-size: 22px; }
}

/* =====================================================
   NOTES TAB — PAGE HEADER
   ===================================================== */
.notes-page-header {
  margin-bottom: 16px;
}

.notes-page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.notes-page-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* =====================================================
   HOME DASHBOARD — WELCOME BANNER
   ===================================================== */
.home-welcome {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin-bottom: 12px;
}

.home-greeting {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 5px;
}

.home-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.2;
  margin-bottom: 4px;
}

.home-intro {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
  margin: 2px 0 0 0;
}

.home-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* =====================================================
   HOME DASHBOARD — STATS ROW
   ===================================================== */
.home-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.home-stat-pill {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.home-stat-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.home-stat-denom {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.6;
}

.home-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

/* =====================================================
   HOME DASHBOARD — QUICK ACTIONS
   ===================================================== */
.home-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 20px;
}

.home-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 10px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.13s, opacity 0.13s;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.home-action-btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.home-action-notes {
  background: var(--accent-dim);
  color: var(--accent);
}

body.dark-theme .home-action-notes {
  background: #1e3a5f;
  color: var(--accent);
}

.home-action-quiz {
  background: #ecfdf5;
  color: var(--correct);
}

body.dark-theme .home-action-quiz {
  background: #052e16;
  color: var(--correct);
}

.home-action-cards {
  background: #fff7ed;
  color: var(--warning);
}

body.dark-theme .home-action-cards {
  background: #2d1c00;
  color: var(--warning);
}

.home-action-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.home-action-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
}

/* =====================================================
   HOME DASHBOARD — SECTION LABELS
   ===================================================== */
.home-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 4px;
}

/* =====================================================
   HOME DASHBOARD — SECTION PROGRESS MINI CARDS
   ===================================================== */
.home-sections {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.home-section-mini {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.13s;
  -webkit-tap-highlight-color: transparent;
}

.home-section-mini:active {
  transform: scale(0.985);
}

.home-section-mini-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.home-section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.home-section-mini-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: break-word;
  min-width: 0;
}

.home-section-mini-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.home-mini-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.home-mini-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.home-section-mini-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* =====================================================
   HOME DASHBOARD — FOCUS NEXT
   ===================================================== */
.home-weak {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.home-weak-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--incorrect);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.home-weak-title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.home-weak-pct {
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.home-empty-note {
  font-size: 13px;
  color: var(--text-muted);
  padding: 12px 0 6px;
  text-align: center;
}

/* =====================================================
   HOME DASHBOARD — RECENT MISSES
   ===================================================== */
.home-missed {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.home-missed-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  padding: 11px 14px;
  cursor: pointer;
  transition: transform 0.13s;
  -webkit-tap-highlight-color: transparent;
}

.home-missed-item:active {
  transform: scale(0.985);
}

.home-missed-q {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 4px;
  overflow-wrap: break-word;
}

.home-missed-a {
  font-size: 12px;
  color: var(--correct);
  font-weight: 500;
  overflow-wrap: break-word;
}

/* =====================================================
   HOME — RESPONSIVE ADJUSTMENTS
   ===================================================== */
@media (max-width: 380px) {
  .home-stats-row { grid-template-columns: repeat(2, 1fr); }
  .home-stat-num  { font-size: 17px; }
  .home-actions   { gap: 7px; }
  .home-action-btn { padding: 13px 8px; }
  .home-action-label { font-size: 12px; }
}

@media (min-width: 580px) {
  .home-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .home-weak {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
}
