/* ============================================================
   CSS VARIABLES & THEMES
   ============================================================ */
:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-dark: #154360;
  --accent: #e67e22;
  --accent-light: #f39c12;
  --success: #27ae60;
  --success-bg: #d5f5e3;
  --danger: #e74c3c;
  --danger-bg: #fadbd8;
  --warning: #f1c40f;
  --bg: #f0f2f5;
  --bg2: #e8eaed;
  --card: #ffffff;
  --card-bg: #ffffff;
  --bg-alt: #e8eaed;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --text-lighter: #b0b8c1;
  --border: #dfe6e9;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font-base: 16px;
  --font-scale: 1;
  --bookmark-color: #e67e22;
  --diff-easy: #27ae60;
  --diff-medium: #f39c12;
  --diff-hard: #e74c3c;
}

[data-theme="dark"] {
  --primary: #5dade2;
  --primary-light: #85c1e9;
  --primary-dark: #2e86c1;
  --accent: #f5b041;
  --accent-light: #f9e79f;
  --success: #58d68d;
  --success-bg: #1a3a2a;
  --danger: #ec7063;
  --danger-bg: #3a1a1a;
  --bg: #1a1d23;
  --bg2: #22262e;
  --card: #2a2e36;
  --card-bg: #2a2e36;
  --bg-alt: #22262e;
  --text: #e0e0e0;
  --text-light: #a0a8b4;
  --text-lighter: #6c7580;
  --border: #3a3e46;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --bookmark-color: #f5b041;
}

/* ============================================================
   BASE
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: calc(var(--font-base) * var(--font-scale)); scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.65;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  background: linear-gradient(135deg, #1a5276 0%, #2980b9 50%, #3498db 100%);
  color: white; padding: 24px 20px 18px; text-align: center;
  position: relative; overflow: hidden;
}
[data-theme="dark"] .header {
  background: linear-gradient(135deg, #1a2634 0%, #1e3a52 50%, #224a6e 100%);
}
.header::before { content:''; position:absolute; top:-50%; left:-50%; width:200%; height:200%; background:radial-gradient(circle, rgba(255,255,255,0.04) 0%, transparent 70%); }
.header h1 { font-size: 1.5em; font-weight: 700; letter-spacing: -0.3px; position: relative; }
.header .subtitle { font-size: 0.88em; opacity: 0.85; margin-top: 3px; position: relative; }
.header .badge-row { margin-top: 8px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; position: relative; }
.header .badge { display:inline-block; background:rgba(255,255,255,0.18); padding:3px 12px; border-radius:20px; font-size:0.78em; }
.header .badge-diff { background:rgba(255,255,255,0.25); padding:3px 14px; border-radius:20px; font-size:0.78em; font-weight:700; letter-spacing:0.3px; }
.diff-meter { display:inline-block; width:60px; height:8px; background:rgba(255,255,255,0.2); border-radius:4px; vertical-align:middle; margin-left:6px; overflow:hidden; }
.diff-meter-fill { height:100%; border-radius:4px; transition:width 0.6s ease; }

/* ============================================================
   FLOATING CONTROL WIDGET (bottom-right)
   ============================================================ */
.float-timer {
  position: fixed; bottom: 20px; right: 20px; z-index: 600;
  display: flex; align-items: center; gap: 0;
  cursor: pointer; user-select: none;
  transition: all 0.3s ease;
}
.float-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); color: var(--primary);
  padding: 8px 14px; border-radius: 28px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border: 2px solid var(--border);
  font-family: 'Courier New', monospace; font-size: 1.05em; font-weight: 700;
  transition: all 0.25s;
}
.float-pill:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.2); transform: translateY(-1px); }
.float-pill .pill-icon { font-style: normal; font-size: 0.9em; }
.float-pill.warning { color: var(--accent); border-color: var(--accent); }
.float-pill.danger { color: var(--danger); border-color: var(--danger); animation: pulse 0.5s infinite; }
.float-pill.overtime { color: #fff; background: var(--danger); border-color: var(--danger); animation: none; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.6;} }

/* Expanded control panel */
.float-panel {
  display: none; position: fixed; bottom: 68px; right: 20px; z-index: 590;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18); padding: 16px 18px;
  min-width: 220px; animation: panelUp 0.25s ease;
}
.float-panel.show { display: block; }
@keyframes panelUp { from{opacity:0;transform:translateY(12px);} to{opacity:1;transform:translateY(0);} }

.fp-title { font-size: 0.72em; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

.fp-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.fp-row:last-child { border-bottom: none; }
.fp-label { font-size: 0.85em; color: var(--text); display: flex; align-items: center; gap: 6px; }

.fp-btn {
  padding: 5px 12px; border-radius: 6px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text); cursor: pointer; font-size: 0.82em;
  font-weight: 600; transition: all 0.15s;
}
.fp-btn:hover { border-color: var(--primary); color: var(--primary); }
.fp-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.fp-timer-controls { display: flex; align-items: center; gap: 8px; }
.fp-timer-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 0.9em;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.fp-timer-btn:hover { border-color: var(--primary); background: rgba(41,128,185,0.1); }
.fp-timer-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.fp-slider-row { display: flex; align-items: center; gap: 6px; }
.fp-slider-row span { font-size: 0.72em; color: var(--text-light); }
.fp-slider { flex: 1; cursor: pointer; width: 80px; }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex; background: var(--card); border-bottom: 2px solid var(--border);
  position: sticky; top: 0; z-index: 190;
}
.tab {
  flex: 1; padding: 11px 8px; text-align: center; cursor: pointer;
  font-size: 0.84em; font-weight: 600; color: var(--text-light);
  border-bottom: 3px solid transparent; transition: all 0.2s; user-select: none;
}
.tab:hover { color: var(--primary); background: var(--bg); }
.tab.active { color: var(--primary); border-bottom-color: var(--accent); }

/* ============================================================
   CONTAINER (tablet optimized)
   ============================================================ */
.container { max-width: 900px; margin: 0 auto; padding: 16px 20px; }
@media (min-width: 768px) { .container { padding: 20px 32px; } }
@media (min-width: 1024px) { .container { padding: 24px 40px; } }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar-wrap { background: var(--bg2); border-radius: 20px; height: 10px; margin: 14px 0; overflow: hidden; }
.progress-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 20px; transition: width 0.4s ease; width: 0%;
}
.progress-info { display: flex; justify-content: space-between; font-size: 0.82em; color: var(--text-light); margin-bottom: 10px; }

/* ============================================================
   QUESTION NAV (mini map of questions)
   ============================================================ */
.q-nav {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 16px;
  padding: 12px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.q-nav-dot {
  width: 32px; height: 32px; border-radius: 6px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72em; font-weight: 700; cursor: pointer; transition: all 0.2s;
  color: var(--text-light); background: var(--bg); position: relative;
}
.q-nav-dot:hover { border-color: var(--primary); color: var(--primary); }
.q-nav-dot.answered { background: var(--primary); color: white; border-color: var(--primary); }
.q-nav-dot.bookmarked::after {
  content: '🔖'; position: absolute; top: -6px; right: -6px; font-size: 0.7em;
}
.q-nav-dot.correct { background: var(--success); border-color: var(--success); color: white; }
.q-nav-dot.wrong { background: var(--danger); border-color: var(--danger); color: white; }

/* ============================================================
   SECTION HEADERS & PASSAGES
   ============================================================ */
.section-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white; padding: 14px 20px; border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 700; font-size: 1em;
}
.passage-header {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: white; padding: 12px 20px; font-size: 0.9em; font-weight: 600;
}
[data-theme="dark"] .passage-header { background: linear-gradient(135deg, #1a2634, #223344); }

.passage-box {
  background: var(--card); border: 1px solid var(--border); border-top: none;
  padding: 20px; font-size: 0.95em; line-height: 1.85;
  border-radius: 0 0 var(--radius) var(--radius); margin-bottom: 16px;
}
.passage-box p { margin-bottom: 12px; text-align: justify; }
.passage-box .blank { display:inline-block; min-width:70px; border-bottom:2px solid var(--primary); text-align:center; font-weight:700; color:var(--primary); margin:0 2px; }
.passage-box .source { text-align:right; font-style:italic; color:var(--text-light); font-size:0.82em; margin-top:8px; }
.passage-box hr { border: none; border-top: 1px dashed var(--border); margin: 16px 0; }

/* ============================================================
   QUESTION CARDS
   ============================================================ */
.question-card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  margin-bottom: 12px; box-shadow: var(--shadow); border: 2px solid var(--border);
  transition: border-color 0.3s, background 0.3s; position: relative;
}
.question-card.answered { border-color: var(--primary-light); }
.question-card.correct { border-color: var(--success); background: var(--success-bg); }
.question-card.wrong { border-color: var(--danger); background: var(--danger-bg); }
.question-card.hidden-review { display: none; }

.q-top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.q-left { display: flex; align-items: flex-start; flex: 1; }
.q-number {
  display:inline-flex; align-items:center; justify-content:center;
  background:var(--primary); color:white; min-width:30px; height:30px;
  border-radius:50%; font-size:0.78em; font-weight:700; margin-right:10px; flex-shrink:0;
}
.q-stem { font-weight: 600; font-size: 0.95em; flex: 1; }

/* Confidence marking bar */
.confidence-bar {
  display: none; /* hidden in exam mode, shown in study mode */
  gap: 4px; flex-shrink: 0; margin-left: auto;
}
body.study-mode .confidence-bar { display: flex; }
.question-card.submitted .confidence-bar,
.question-card.correct .confidence-bar { display: none; }
.conf-btn {
  padding: 3px 8px; border-radius: 12px; border: 1.5px solid var(--border);
  background: transparent; cursor: pointer; font-size: 0.72em; font-weight: 600;
  transition: all 0.15s; color: var(--text-lighter); white-space: nowrap;
}
.conf-btn:hover { transform: scale(1.05); }
.conf-btn.conf-sure:hover, .conf-btn.conf-sure.active { color: #27ae60; border-color: #27ae60; background: rgba(39,174,96,0.1); }
.conf-btn.conf-unsure:hover, .conf-btn.conf-unsure.active { color: #f39c12; border-color: #f39c12; background: rgba(243,156,18,0.1); }
.conf-btn.conf-guess:hover, .conf-btn.conf-guess.active { color: #e74c3c; border-color: #e74c3c; background: rgba(231,76,60,0.1); }
@keyframes confPulse { 0%,100%{box-shadow:none;} 50%{box-shadow:0 0 0 4px rgba(52,152,219,0.3);} }
.conf-pulse { animation: confPulse 0.5s ease 3; border-radius: 14px; }
/* Nav dot confidence colors */
.q-nav-dot.conf-sure { border-bottom: 2.5px solid #27ae60; }
.q-nav-dot.conf-unsure { border-bottom: 2.5px solid #f39c12; }
.q-nav-dot.conf-guess { border-bottom: 2.5px solid #e74c3c; }

/* Cognitive blind spot matrix */
.blind-spot-matrix { margin: 16px 0; padding: 14px; border-radius: 12px; background: var(--card-bg); border: 1px solid var(--border); }
.blind-spot-matrix h4 { margin: 0 0 12px; font-size: 0.95em; text-align: center; }
.matrix-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.matrix-cell { padding: 10px; border-radius: 10px; text-align: center; border: 1.5px solid var(--border); }
.matrix-cell-icon { font-size: 1.3em; margin-bottom: 2px; }
.matrix-cell-label { font-weight: 700; font-size: 0.85em; }
.matrix-cell-desc { font-size: 0.7em; color: var(--text-light); margin-bottom: 4px; }
.matrix-cell-count { font-size: 1.6em; font-weight: 800; }
.matrix-cell-qids { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: 4px; }
.matrix-qid { font-size: 0.7em; padding: 1px 6px; border-radius: 8px; background: rgba(0,0,0,0.06); cursor: pointer; font-weight: 600; }
.matrix-qid:hover { background: var(--primary); color: #fff; }
.matrix-cell-alert { font-size: 0.75em; font-weight: 700; color: #e74c3c; margin-top: 4px; }
.matrix-mastered { background: rgba(39,174,96,0.06); border-color: rgba(39,174,96,0.3); }
.matrix-mastered .matrix-cell-count { color: #27ae60; }
.matrix-blindspot { background: rgba(231,76,60,0.06); border-color: rgba(231,76,60,0.3); }
.matrix-blindspot .matrix-cell-count { color: #e74c3c; }
.matrix-learning { background: rgba(243,156,18,0.06); border-color: rgba(243,156,18,0.3); }
.matrix-learning .matrix-cell-count { color: #f39c12; }
.matrix-lucky { background: rgba(52,152,219,0.06); border-color: rgba(52,152,219,0.3); }
.matrix-lucky .matrix-cell-count { color: #3498db; }
[data-theme="dark"] .matrix-qid { background: rgba(255,255,255,0.1); }

/* ============================================================
   SPACED REPETITION SYSTEM (SRS)
   ============================================================ */
.srs-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  animation: srsFadeIn 0.3s ease;
}
@keyframes srsFadeIn { from{opacity:0;} to{opacity:1;} }
.srs-prompt-card {
  background: var(--card-bg); border-radius: 16px; padding: 28px 24px;
  text-align: center; max-width: 380px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2); border: 1px solid var(--border);
}
.srs-prompt-icon { font-size: 2.5em; margin-bottom: 4px; }
.srs-prompt-card h3 { margin: 0 0 12px; font-size: 1.1em; color: var(--primary); }
.srs-prompt-count { font-size: 3em; font-weight: 900; color: var(--accent); }
.srs-prompt-label { font-size: 0.85em; color: var(--text-light); margin-bottom: 14px; }
.srs-stats-row { display: flex; gap: 16px; justify-content: center; margin-bottom: 16px; }
.srs-stat { font-size: 0.78em; color: var(--text-light); }
.srs-stat-num { font-weight: 800; color: var(--text); }
.srs-start-btn { width: 100%; margin-bottom: 8px; font-size: 1em; padding: 12px; }
.srs-skip-btn { width: 100%; font-size: 0.85em; padding: 8px; background: transparent; border: 1px solid var(--border); color: var(--text-light); border-radius: 8px; cursor: pointer; }
.srs-skip-btn:hover { background: rgba(0,0,0,0.04); }
.srs-panel { max-width: 700px; margin: 0 auto; padding: 16px 0; }
.srs-header { text-align: center; margin-bottom: 16px; }
.srs-header h3 { margin: 0 0 10px; color: var(--primary); }
.srs-review-progress { display: flex; align-items: center; gap: 10px; justify-content: center; }
.srs-prog-bar-wrap { width: 200px; height: 6px; background: var(--bg-alt); border-radius: 3px; overflow: hidden; }
.srs-prog-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; width: 0; }
#srsCounter { font-size: 0.82em; font-weight: 700; color: var(--text-light); }
.srs-question-card { background: var(--card-bg); border-radius: 12px; padding: 18px; border: 1px solid var(--border); margin-bottom: 12px; }
.srs-q-meta { display: flex; gap: 12px; margin-bottom: 8px; font-size: 0.75em; }
.srs-streak { color: #e67e22; font-weight: 600; }
.srs-interval { color: var(--text-light); }
.srs-q-stem { font-weight: 600; font-size: 0.95em; margin-bottom: 12px; }
.srs-q-stem .q-number { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; background: var(--primary); color: #fff; border-radius: 50%; font-size: 0.75em; font-weight: 700; margin-right: 8px; }
.srs-options { display: grid; gap: 6px; }
.srs-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  border: 1.5px solid var(--border); cursor: pointer;
  transition: all 0.15s; font-size: 0.9em;
}
.srs-option:hover { border-color: var(--primary); background: rgba(52,152,219,0.04); }
.srs-option .option-label { min-width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: var(--bg-alt); border-radius: 50%; font-size: 0.78em; font-weight: 700; flex-shrink: 0; }
.srs-disabled { pointer-events: none; opacity: 0.7; }
.srs-correct { border-color: var(--success) !important; background: rgba(39,174,96,0.08) !important; opacity: 1 !important; }
.srs-correct .option-label { background: var(--success); color: #fff; }
.srs-wrong { border-color: var(--danger) !important; background: rgba(231,76,60,0.08) !important; opacity: 1 !important; }
.srs-wrong .option-label { background: var(--danger); color: #fff; }
.srs-feedback { margin-top: 10px; }
.srs-fb-correct { color: var(--success); font-weight: 700; font-size: 0.9em; margin-bottom: 6px; }
.srs-fb-wrong { color: var(--danger); font-weight: 700; font-size: 0.9em; margin-bottom: 6px; }
.srs-fb-exp { font-size: 0.82em; color: var(--text-light); padding: 8px; background: var(--bg-alt); border-radius: 8px; margin-bottom: 6px; }
.srs-fb-hint { font-size: 0.8em; color: var(--accent); font-style: italic; }
.srs-next-btn { width: 100%; margin-top: 10px; padding: 12px; font-size: 1em; }
.srs-summary { text-align: center; padding: 20px; }
.srs-summary-icon { font-size: 2.5em; margin-bottom: 6px; }
.srs-summary h3 { margin: 0 0 14px; color: var(--primary); }
.srs-summary-score { margin-bottom: 16px; }
.srs-score-big { font-size: 2.2em; font-weight: 900; }
.srs-score-pct { font-size: 1.1em; font-weight: 700; }
.srs-score-pct.good { color: var(--success); }
.srs-score-pct.medium { color: var(--accent); }
.srs-score-pct.weak { color: var(--danger); }
.srs-score-time { font-size: 0.82em; color: var(--text-light); margin-top: 4px; }
.srs-summary-detail { max-height: 200px; overflow-y: auto; margin-bottom: 14px; text-align: left; }
.srs-result-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; font-size: 0.82em; }
.srs-result-ok { background: rgba(39,174,96,0.06); }
.srs-result-fail { background: rgba(231,76,60,0.06); }
.srs-result-qid { font-weight: 800; min-width: 24px; }
.srs-result-stem { color: var(--text-light); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srs-summary-stats { display: flex; gap: 16px; justify-content: center; margin-bottom: 16px; font-size: 0.8em; color: var(--text-light); flex-wrap: wrap; }
[data-theme="dark"] .srs-overlay { background: rgba(0,0,0,0.7); }
[data-theme="dark"] .srs-skip-btn:hover { background: rgba(255,255,255,0.06); }

/* Difficulty badge */
.diff-badge {
  display: none; font-size: 0.7em; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; margin-left: 8px; vertical-align: middle;
}
.diff-badge.easy { background: rgba(39,174,96,0.15); color: var(--diff-easy); }
.diff-badge.medium { background: rgba(243,156,18,0.15); color: var(--diff-medium); }
.diff-badge.hard { background: rgba(231,76,60,0.15); color: var(--diff-hard); }
.submitted .diff-badge { display: inline-block; }

/* Options */
/* Options: 2-column when all short */
.options { margin-top: 12px; }
.options.grid-2col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.options.grid-2col .option { margin: 0; }
@media (max-width: 480px) {
  .options.grid-2col { grid-template-columns: 1fr; }
}
.option {
  display: flex; align-items: flex-start; padding: 11px 14px; margin: 6px 0;
  border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.15s; font-size: 0.92em;
}
.option:hover { border-color: var(--primary-light); background: rgba(41,128,185,0.06); }
.option.selected { border-color: var(--primary); background: rgba(41,128,185,0.1); }
.option.correct-answer { border-color: var(--success); background: var(--success-bg); }
.option.wrong-answer { border-color: var(--danger); background: var(--danger-bg); }
.option-label {
  min-width:30px; height:30px; border-radius:50%; border:2px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  margin-right:10px; font-weight:700; font-size:0.82em; flex-shrink:0;
  transition: all 0.15s;
}
.option.selected .option-label { background:var(--primary); color:white; border-color:var(--primary); }
.option.correct-answer .option-label { background:var(--success); color:white; border-color:var(--success); }
.option.wrong-answer .option-label { background:var(--danger); color:white; border-color:var(--danger); }

/* Explanation & Vocab */
.explanation {
  display:none; margin-top:14px; padding:14px 16px; background:rgba(241,196,15,0.08);
  border-radius:var(--radius-sm); border-left:4px solid var(--accent); font-size:0.9em;
}
.explanation h4 { color:var(--accent); margin-bottom:8px; font-size:0.92em; }
.explanation .cn { color:var(--text-light); font-size:0.87em; margin-top:4px; }
.exp-all-opts { display:flex; flex-direction:column; gap:8px; }
.exp-opt { padding:8px 12px; border-radius:var(--radius-sm); font-size:0.9em; }
.exp-opt-correct { background:rgba(39,174,96,0.1); border-left:3px solid var(--success); }
.exp-opt-wrong { background:rgba(231,76,60,0.06); border-left:3px solid rgba(231,76,60,0.3); }
.exp-opt-label { font-weight:600; margin-bottom:4px; }
.exp-opt-correct .exp-opt-label { color:var(--success); }
.exp-opt-wrong .exp-opt-label { color:var(--danger); }
.exp-opt-detail { font-size:0.92em; margin-top:2px; line-height:1.5; }

.vocab-box {
  display:none; margin-top:10px; padding:12px 16px; background:rgba(41,128,185,0.06);
  border-radius:var(--radius-sm); font-size:0.85em; border-left: 4px solid var(--primary);
}
.vocab-box h4 { color:var(--primary); margin-bottom:6px; font-size:0.9em; }
.vocab-item { margin:6px 0; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.vocab-item:last-child { border-bottom: none; }
.vocab-item strong { color:var(--primary); }
.ipa-speak {
  color:var(--accent); font-size:0.9em; cursor:pointer; padding:2px 4px;
  border-radius:4px; transition: all 0.2s; user-select:none;
}
.ipa-speak:hover { background:rgba(230,126,34,0.1); }
.ipa-speak:active { transform:scale(0.95); }
.ipa-speaking { background:rgba(230,126,34,0.2); animation:ipaPulse 0.6s ease; }
@keyframes ipaPulse { 0%{transform:scale(1);} 50%{transform:scale(1.05);} 100%{transform:scale(1);} }

/* Dictionary Popup */
.dict-popup {
  display:none; position:fixed; z-index:9999; width:320px; max-width:90vw;
  background:var(--card); border-radius:var(--radius); box-shadow:0 8px 32px rgba(0,0,0,0.18);
  border:2px solid var(--primary); overflow:hidden; animation:dictFadeIn 0.2s ease;
}
@keyframes dictFadeIn { from{opacity:0;transform:translateY(6px);} to{opacity:1;transform:translateY(0);} }
.dict-header {
  display:flex; align-items:center; gap:8px; padding:10px 14px;
  background:linear-gradient(135deg,var(--primary),#2980b9); color:#fff; font-size:1.05em;
}
.dict-header strong { flex:1; }
.dict-close {
  background:none; border:none; color:rgba(255,255,255,0.7); font-size:1.1em;
  cursor:pointer; padding:2px 6px; border-radius:4px;
}
.dict-close:hover { background:rgba(255,255,255,0.15); color:#fff; }
.dict-header .ipa-speak { color:rgba(255,255,255,0.85); font-size:0.85em; }
.dict-header .ipa-speak:hover { background:rgba(255,255,255,0.15); }
.dict-body { padding:12px 14px; font-size:0.88em; line-height:1.6; }
.dict-en { color:var(--text); margin-bottom:6px; }
.dict-cn { color:var(--text-light); font-style:italic; }
.dict-loading { color:var(--text-light); animation:dictPulse 1s infinite; }
@keyframes dictPulse { 0%,100%{opacity:0.4;} 50%{opacity:1;} }

/* Retry Challenge Panel */
.retry-panel { display:none; background:var(--card); border-radius:var(--radius); padding:24px; margin:16px 0; box-shadow:var(--shadow); border:2px solid var(--accent); }
.retry-panel h2 { color:var(--accent); text-align:center; margin-bottom:8px; }
.retry-desc { text-align:center; font-size:0.85em; color:var(--text-light); margin-bottom:16px; }
.retry-progress { height:8px; background:var(--bg); border-radius:4px; overflow:hidden; margin:10px 0 6px; }
.retry-bar { height:100%; background:linear-gradient(90deg,var(--accent),var(--success)); border-radius:4px; transition:width 0.5s ease; width:0%; }
.retry-count { text-align:center; font-size:0.82em; color:var(--text-light); margin-bottom:16px; font-weight:600; }
.retry-card { background:var(--bg); border-radius:var(--radius-sm); padding:16px; margin:12px 0; border-left:4px solid var(--accent); }
.retry-card.retry-done-card { opacity:0.5; border-left-color:var(--success); }
.retry-card .retry-stem { font-weight:700; margin-bottom:10px; font-size:0.95em; }
.retry-card .retry-hint { font-size:0.82em; color:var(--accent); background:rgba(230,126,34,0.08); padding:8px 12px; border-radius:6px; margin-bottom:10px; }
.retry-card .retry-opts { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.retry-opt { padding:10px 14px; border:2px solid var(--border); border-radius:8px; cursor:pointer; font-size:0.9em; transition:all 0.2s; text-align:center; }
.retry-opt:hover { border-color:var(--primary); background:rgba(41,128,185,0.06); }
.retry-opt.retry-correct { border-color:var(--success); background:rgba(39,174,96,0.12); color:var(--success); font-weight:700; }
.retry-opt.retry-wrong { border-color:var(--danger); background:rgba(231,76,60,0.12); color:var(--danger); }
.retry-opt.retry-answer { border-color:var(--success); background:rgba(39,174,96,0.15); font-weight:700; }
.retry-opt.retry-disabled { pointer-events:none; opacity:0.5; }
.retry-feedback { margin-top:8px; padding:8px 12px; border-radius:6px; font-size:0.85em; font-weight:600; }
.retry-feedback.ok { background:rgba(39,174,96,0.1); color:var(--success); }
.retry-feedback.fail { background:rgba(231,76,60,0.1); color:var(--danger); }
.retry-done { text-align:center; padding:24px; }
.retry-done-icon { font-size:3em; margin-bottom:8px; }
.retry-done-text { font-size:1em; color:var(--text); margin-bottom:16px; line-height:1.6; }

/* New: multi-attempt feedback stack */
.retry-feedback-stack { margin-top:10px; }

/* History mistake expandable detail rows */
tr.mistake-row { cursor:pointer; }
tr.mistake-row:hover td { background:rgba(41,128,185,0.05); }
tr.mistake-row td:first-child { white-space:nowrap; }
tr.mistake-detail td { padding:0 !important; }
.mistake-detail-inner { padding:14px 18px; border-left:4px solid var(--accent); background:var(--bg2); }
.mistake-detail-stem { font-weight:700; font-size:0.95em; margin-bottom:12px; line-height:1.5; }
.mistake-detail-opts { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:12px; }
.mistake-detail-opt { padding:8px 12px; border:2px solid var(--border); border-radius:8px; font-size:0.88em; line-height:1.4; }
.mistake-detail-opt.correct-opt { border-color:var(--success); background:rgba(39,174,96,0.1); color:var(--success); font-weight:700; }
.mistake-detail-actions { display:flex; gap:10px; margin-top:12px; flex-wrap:wrap; align-items:center; }
.mistake-wrong-count { font-size:0.82em; color:var(--danger); background:rgba(231,76,60,0.08); padding:3px 10px; border-radius:20px; }
@media(max-width:600px){ .mistake-detail-opts { grid-template-columns:1fr; } }
.retry-fb-item { margin:8px 0; padding:12px 14px; border-radius:8px; font-size:0.88em; animation:retryFbIn 0.3s ease; }
@keyframes retryFbIn { from{opacity:0;transform:translateY(8px);} to{opacity:1;transform:translateY(0);} }
.retry-fb-wrong { background:rgba(231,76,60,0.06); border-left:4px solid var(--danger); }
.retry-fb-correct { background:rgba(39,174,96,0.06); border-left:4px solid var(--success); }
.retry-fb-label { font-weight:700; margin-bottom:6px; font-size:0.95em; }
.retry-fb-wrong .retry-fb-label { color:var(--danger); }
.retry-fb-correct .retry-fb-label { color:var(--success); }
.retry-fb-text { line-height:1.6; color:var(--text); }
.retry-fb-text .cn { color:var(--text-light); font-style:italic; margin-top:4px; }
.retry-understood-btn { margin-top:12px; }

/* Verification micro-task (replaces passive "I understand") */
.verify-task { margin-top:14px; padding:16px; background:rgba(41,128,185,0.04); border:2px solid rgba(41,128,185,0.15); border-radius:var(--radius-sm); animation:retryFbIn 0.35s ease; }
.verify-task-title { font-weight:700; color:var(--primary); font-size:0.92em; margin-bottom:6px; }
.verify-task-prompt { font-size:0.88em; color:var(--text); margin-bottom:12px; line-height:1.5; }
.verify-task-prompt .verify-highlight { background:rgba(231,76,60,0.1); color:var(--danger); padding:2px 6px; border-radius:4px; font-weight:600; }
.verify-choices { display:flex; flex-direction:column; gap:8px; }
.verify-choice { padding:10px 14px; border:2px solid var(--border); border-radius:8px; cursor:pointer; font-size:0.85em; line-height:1.5; transition:all 0.2s; }
.verify-choice:hover { border-color:var(--primary); background:rgba(41,128,185,0.05); }
.verify-choice.verify-picked-right { border-color:var(--success); background:rgba(39,174,96,0.1); pointer-events:none; }
.verify-choice.verify-picked-wrong { border-color:var(--danger); background:rgba(231,76,60,0.06); opacity:0.5; pointer-events:none; }
.verify-choice.verify-reveal-right { border-color:var(--success); background:rgba(39,174,96,0.12); pointer-events:none; font-weight:600; }
.verify-choice.verify-disabled { pointer-events:none; opacity:0.45; }
.verify-result { margin-top:10px; padding:10px 14px; border-radius:8px; font-size:0.88em; font-weight:600; animation:retryFbIn 0.3s ease; }
.verify-result.verify-pass { background:rgba(39,174,96,0.1); color:var(--success); }
.verify-result.verify-fail { background:rgba(231,76,60,0.06); color:var(--danger); }
.verify-explain { display:flex; flex-direction:column; gap:12px; margin-top:4px; }
.verify-explain-wrong, .verify-explain-right { padding:12px 14px; border-radius:8px; font-size:0.88em; line-height:1.6; }
.verify-explain-wrong { background:rgba(231,76,60,0.06); border-left:3px solid var(--danger); }
.verify-explain-right { background:rgba(39,174,96,0.06); border-left:3px solid var(--success); }
.retry-opt.retry-wrong-used { border-color:var(--danger); opacity:0.45; pointer-events:none; text-decoration:line-through; }

/* Active Recall Flashcards (Review phase) */
.recall-panel { margin:20px 0; padding:0; }
.recall-header { text-align:center; margin-bottom:16px; }
.recall-header h4 { color:var(--accent); margin:0 0 4px; }
.recall-header p { font-size:0.82em; color:var(--text-light); margin:0; }
.recall-progress { height:6px; background:var(--bg); border-radius:3px; overflow:hidden; margin:12px 0 8px; }
.recall-progress-bar { height:100%; background:linear-gradient(90deg,var(--accent),var(--success)); border-radius:3px; transition:width 0.4s ease; }
.recall-counter { text-align:center; font-size:0.8em; color:var(--text-light); margin-bottom:14px; font-weight:600; }
.recall-card { background:var(--bg); border:2px solid var(--border); border-radius:var(--radius); padding:24px 20px; text-align:center; min-height:120px; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:10px; transition:border-color 0.3s; }
.recall-card.recall-revealed { border-color:var(--primary); }
.recall-card-type { font-size:0.7em; text-transform:uppercase; letter-spacing:1px; color:var(--text-light); background:var(--border); padding:2px 10px; border-radius:10px; }
.recall-card-def { font-size:0.95em; line-height:1.6; color:var(--text); max-width:480px; }
.recall-card-def .cn { color:var(--text-light); font-style:italic; margin-top:4px; }
.recall-card-ipa { font-size:0.85em; color:var(--primary); cursor:pointer; }
.recall-card-answer { font-size:1.3em; font-weight:700; color:var(--primary); margin:6px 0; animation:retryFbIn 0.3s ease; }
.recall-actions { display:flex; gap:10px; justify-content:center; margin-top:16px; }
.recall-btn { padding:10px 20px; border:2px solid var(--border); border-radius:8px; cursor:pointer; font-size:0.88em; font-weight:600; transition:all 0.2s; background:var(--card); }
.recall-btn:hover { transform:scale(1.03); }
.recall-btn-reveal { border-color:var(--primary); color:var(--primary); }
.recall-btn-reveal:hover { background:rgba(41,128,185,0.08); }
.recall-btn-knew { border-color:var(--success); color:var(--success); }
.recall-btn-knew:hover { background:rgba(39,174,96,0.08); }
.recall-btn-forgot { border-color:var(--danger); color:var(--danger); }
.recall-btn-forgot:hover { background:rgba(231,76,60,0.08); }
.recall-summary { text-align:center; padding:16px; background:var(--bg); border-radius:var(--radius); margin:12px 0; }
.recall-summary-score { font-size:1.5em; font-weight:700; margin:8px 0; }
.recall-summary-score.good { color:var(--success); }
.recall-summary-score.medium { color:var(--accent); }
.recall-summary-score.weak { color:var(--danger); }
.recall-forgot-list { font-size:0.85em; color:var(--text-light); margin-top:8px; line-height:1.6; }
.recall-forgot-word { color:var(--danger); font-weight:600; }

/* Comprehensive all-options review */
.retry-fb-all-opts { margin-top:8px; }
.retry-fb-opt { padding:10px 12px; margin:6px 0; border-radius:6px; font-size:0.88em; line-height:1.6; }
.retry-fb-opt-correct { background:rgba(39,174,96,0.06); border-left:3px solid var(--success); }
.retry-fb-opt-wrong { background:rgba(231,76,60,0.04); border-left:3px solid rgba(231,76,60,0.3); }
.retry-fb-opt-label { font-weight:700; display:block; margin-bottom:4px; }
.retry-fb-opt-correct .retry-fb-opt-label { color:var(--success); }
.retry-fb-opt-wrong .retry-fb-opt-label { color:var(--danger); opacity:0.7; }

/* Gate Lock System */
.gate-locked { position:relative; }

/* Mode Selector */
.mode-selector { position:fixed; top:0;left:0;right:0;bottom:0; z-index:9000; background:var(--bg); display:flex; align-items:center; justify-content:center; padding:20px; }
.mode-card { background:var(--card); border-radius:16px; padding:30px; max-width:600px; width:100%; box-shadow:0 8px 40px rgba(0,0,0,0.12); }
.mode-options { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media(max-width:600px){ .mode-options{grid-template-columns:1fr;} }
.mode-option { border:2px solid var(--border); border-radius:12px; padding:20px 16px; text-align:center; cursor:pointer; transition:all 0.3s; }
.mode-option:hover { border-color:var(--primary); background:rgba(41,128,185,0.04); transform:translateY(-2px); box-shadow:0 4px 16px rgba(0,0,0,0.08); }
.mode-icon { font-size:2.5em; margin-bottom:8px; }
.mode-name { font-weight:700; font-size:1.1em; color:var(--primary); margin-bottom:8px; }
.mode-desc { font-size:0.78em; color:var(--text-light); line-height:1.5; margin-bottom:10px; }
.mode-time { font-size:0.72em; color:var(--accent); font-weight:600; padding:4px 10px; background:rgba(230,126,34,0.08); border-radius:20px; display:inline-block; }

/* Study Mode Header */
.study-header { background:var(--card); padding:12px 20px; box-shadow:0 2px 8px rgba(0,0,0,0.06); margin-bottom:12px; border-radius:var(--radius); display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; }
.study-progress-bar { display:flex; gap:4px; flex:1; }
.study-step { flex:1; text-align:center; padding:8px 4px; border-radius:6px; font-size:0.72em; font-weight:600; color:var(--text-light); background:var(--bg); transition:all 0.3s; white-space:nowrap; cursor:pointer; user-select:none; }
.study-step:hover { filter:brightness(0.95); transform:scale(1.02); }
.study-step span { display:inline-block; width:18px; height:18px; line-height:18px; border-radius:50%; background:var(--border); color:#fff; font-size:0.8em; margin-right:4px; }
.study-step.active { background:rgba(41,128,185,0.1); color:var(--primary); border:2px solid var(--primary); }
.study-step.active span { background:var(--primary); }
.study-step.done { background:rgba(39,174,96,0.1); color:var(--success); }
.study-step.done span { background:var(--success); }
.study-step.locked { opacity:0.5; }
.study-save-btn { background:var(--bg); border:1px solid var(--border); border-radius:6px; font-size:1.1em; padding:4px 8px; cursor:pointer; transition:all 0.2s; }
.study-save-btn:hover { background:var(--primary); color:#fff; }
.study-timer { font-family:'Courier New',monospace; font-weight:700; font-size:0.95em; color:var(--primary); padding:6px 12px; background:var(--bg); border-radius:6px; }

/* Study Mode Section Controls */
.study-section-submit { text-align:center; margin:20px 0; padding:16px; background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow); }
.study-section-submit .btn { font-size:1em; padding:12px 28px; }
.study-section-review { background:var(--card); border-radius:var(--radius); padding:20px; margin:16px 0; box-shadow:var(--shadow); border:2px solid var(--primary); }
.study-section-review h3 { color:var(--primary); text-align:center; margin-bottom:14px; }
.study-section-score { text-align:center; margin:12px 0; }
.study-section-score .big { font-size:2em; font-weight:700; color:var(--primary); }
.study-next-btn { text-align:center; margin:20px 0; }
.study-next-btn .btn { font-size:1.05em; padding:14px 32px; }
.gate-locked > *:not(.gate-overlay) { filter:blur(3px); pointer-events:none; user-select:none; }
.gate-locked > .gate-overlay { position:absolute; top:0;left:0;right:0;bottom:0; display:flex; align-items:center; justify-content:center; background:rgba(255,255,255,0.7); z-index:10; font-size:1.1em; font-weight:700; color:var(--text-light); border-radius:var(--radius); cursor:not-allowed; }
.gate-unlocked > .gate-overlay { display:none !important; }
.gate-unlocked > * { filter:none !important; pointer-events:auto !important; user-select:auto !important; }
.gate-checkpoint { background:var(--card); border-radius:var(--radius); padding:20px; margin:16px 0; text-align:center; box-shadow:var(--shadow); border:2px dashed var(--primary); }
.gate-msg { font-size:0.95em; color:var(--text); margin-bottom:14px; line-height:1.6; }

/* Phrase box (per-question) */
.phrase-box {
  display:none; margin-top:10px; padding:12px 16px; background:rgba(39,174,96,0.06);
  border-radius:var(--radius-sm); font-size:0.85em; border-left: 4px solid var(--success);
}
.phrase-box h4 { color:var(--success); margin-bottom:6px; font-size:0.9em; }
.phrase-item { margin:6px 0; padding:6px 0; border-bottom:1px dashed var(--border); }
.phrase-item:last-child { border-bottom:none; }
.phrase-item strong { color:var(--success); }
.phrase-tag { display:inline-block; padding:1px 8px; border-radius:10px; font-size:0.7em; font-weight:700; margin-right:6px; vertical-align:middle; }
.tag-prep { background:rgba(41,128,185,0.12); color:#2980b9; }
.tag-phrasal { background:rgba(142,68,173,0.12); color:#8e44ad; }
.tag-fixed { background:rgba(230,126,34,0.12); color:#e67e22; }
.tag-conj { background:rgba(231,76,60,0.12); color:#e74c3c; }
.tag-colloc { background:rgba(39,174,96,0.12); color:#27ae60; }

/* Phrase Summary Panel */
.phrase-summary { display:none; background:var(--card); border-radius:var(--radius); padding:20px; margin:16px 0; box-shadow:var(--shadow); border:2px solid var(--success); }

/* Vocab Summary Panel */
.vocab-summary { display:none; background:var(--card); border-radius:var(--radius); padding:20px; margin:16px 0; box-shadow:var(--shadow); border:2px solid var(--primary); }
.vocab-summary h3 { color:var(--primary); margin-bottom:14px; }
.vocab-sum-item { display:flex; align-items:flex-start; gap:10px; padding:10px 0; border-bottom:1px dashed var(--border); font-size:0.85em; }
.vocab-sum-item:last-child { border-bottom:none; }
.vocab-sum-word { flex-shrink:0; min-width:130px; }
.vocab-sum-word strong { color:var(--primary); font-size:1.05em; }
.vocab-sum-word .ipa-speak { font-size:0.82em; }
.vocab-sum-def { flex:1; line-height:1.6; }
.vocab-sum-def .en { color:var(--text); }
.vocab-sum-def .cn { color:var(--text-light); font-style:italic; }
.vocab-sum-qref { flex-shrink:0; font-size:0.75em; color:var(--text-light); background:var(--bg); padding:2px 8px; border-radius:10px; cursor:pointer; }
.vocab-sum-qref:hover { color:var(--primary); background:rgba(41,128,185,0.1); }
.phrase-summary h3 { color:var(--success); margin-bottom:14px; }
.phrase-cat { margin:12px 0; }
.phrase-cat h4 { font-size:0.88em; color:var(--text); margin-bottom:8px; padding-bottom:6px; border-bottom:2px solid var(--border); }
.phrase-cat-item { display:flex; align-items:flex-start; gap:10px; padding:8px 0; border-bottom:1px dashed var(--border); font-size:0.85em; }
.phrase-cat-item:last-child { border-bottom:none; }
.phrase-cat-item .phr-main { flex:1; }
.phrase-cat-item .phr-main strong { color:var(--success); }
.phrase-cat-item .phr-qref { flex-shrink:0; font-size:0.75em; color:var(--text-light); background:var(--bg); padding:2px 8px; border-radius:10px; cursor:pointer; }
.phrase-cat-item .phr-qref:hover { color:var(--primary); background:rgba(41,128,185,0.1); }

/* ============================================================
   WORD COLLECTOR (double-click feature)
   ============================================================ */
.word-collector-float {
  display:none; position:fixed; bottom:68px; left:20px; z-index:500;
  background:var(--accent); color:white; padding:4px 10px; border-radius:20px;
  box-shadow: 0 2px 10px rgba(230,126,34,0.3); font-size:0.75em; font-weight:700;
  cursor:pointer;
}
.word-collector-float .wc-count {
  display:inline-flex; align-items:center; justify-content:center;
  background:white; color:var(--accent); width:18px; height:18px;
  border-radius:50%; font-size:0.8em; margin-left:4px;
}

.word-toast {
  display:none; position:fixed; bottom:116px; left:20px; z-index:510;
  background:var(--card); color:var(--text); padding:8px 16px; border-radius:8px;
  box-shadow: var(--shadow-lg); font-size:0.82em; border:1px solid var(--accent);
  animation: toastIn 0.3s ease;
}
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

.word-notebook {
  display:none; background:var(--card); border-radius:var(--radius);
  padding:20px; margin:16px 0; box-shadow:var(--shadow); border:2px solid var(--accent);
}
.word-notebook h3 { color:var(--accent); margin-bottom:12px; }
.word-nb-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 12px; margin:4px 0; background:var(--bg); border-radius:6px;
  font-size:0.9em;
}
.word-nb-item .remove-word {
  background:none; border:none; color:var(--danger); cursor:pointer;
  font-size:1em; padding:2px 6px;
}
.word-nb-explanation {
  margin-top:16px; padding:16px; background:rgba(230,126,34,0.06);
  border-radius:var(--radius-sm); border-left:4px solid var(--accent);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding:12px 28px; border:none; border-radius:var(--radius-sm);
  font-size:0.95em; font-weight:700; cursor:pointer; transition:all 0.2s;
  text-align:center; user-select:none;
}
.btn-primary { background:linear-gradient(135deg, #1a5276, #2980b9); color:white; }
[data-theme="dark"] .btn-primary { background:linear-gradient(135deg, #2e86c1, #5dade2); }
.btn-primary:hover { transform:translateY(-1px); box-shadow:0 4px 16px rgba(26,82,118,0.3); }
.btn-primary:disabled { background:#bdc3c7; cursor:not-allowed; transform:none; box-shadow:none; }
.btn-accent { background:linear-gradient(135deg, var(--accent), var(--accent-light)); color:white; }
.btn-accent:hover { transform:translateY(-1px); }
.btn-outline { background:var(--card); color:var(--primary); border:2px solid var(--primary); }
.btn-outline:hover { background:var(--primary); color:white; }
.btn-sm { padding:8px 16px; font-size:0.82em; }
.btn-group { display:flex; gap:10px; justify-content:center; margin:16px 0; flex-wrap:wrap; }

/* ============================================================
   REVIEW TOOLBAR (after submission)
   ============================================================ */
.review-bar {
  display:none; background:var(--card); padding:12px 16px;
  border-radius:var(--radius); box-shadow:var(--shadow); margin:12px 0;
  border:1px solid var(--border);
}
.review-bar.show { display:block; }
.review-filters { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.filter-chip {
  padding:6px 14px; border-radius:20px; border:1.5px solid var(--border);
  background:var(--bg); font-size:0.82em; font-weight:600; cursor:pointer;
  transition:all 0.15s; color:var(--text-light);
}
.filter-chip:hover { border-color:var(--primary); color:var(--primary); }
.filter-chip.active { background:var(--primary); color:white; border-color:var(--primary); }

/* ============================================================
   SCORE PANEL
   ============================================================ */
.score-panel {
  background:var(--card); border-radius:var(--radius); padding:28px;
  margin:16px 0; box-shadow:var(--shadow-lg); text-align:center; display:none;
  border:1px solid var(--border);
}
.score-big { font-size:3.2em; font-weight:800; color:var(--primary); }
.score-pct { font-size:1.15em; color:var(--text-light); margin-top:2px; }
.score-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:18px; text-align:left; }
.score-item { background:var(--bg); padding:12px; border-radius:var(--radius-sm); }
.score-item .label { font-size:0.78em; color:var(--text-light); }
.score-item .value { font-size:1.3em; font-weight:700; color:var(--primary); }

/* ============================================================
   HISTORY PANEL
   ============================================================ */
.history-card { background:var(--card); border-radius:var(--radius); padding:20px; margin:12px 0; box-shadow:var(--shadow); border:1px solid var(--border); }
.history-card h3 { color:var(--primary); margin-bottom:12px; font-size:1em; }
.stats-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; margin:12px 0; }
.stat-box { background:var(--bg); padding:14px; border-radius:var(--radius-sm); text-align:center; }
.stat-box .stat-value { font-size:1.6em; font-weight:800; color:var(--primary); }
.stat-box .stat-label { font-size:0.73em; color:var(--text-light); margin-top:2px; }

table { width:100%; border-collapse:collapse; margin:10px 0; font-size:0.83em; }
th { background:var(--primary); color:white; padding:10px 8px; text-align:left; font-weight:600; }
[data-theme="dark"] th { background: var(--primary-dark); }
td { padding:8px; border-bottom:1px solid var(--border); }
tr:hover { background:var(--bg); }

.filter-bar { margin:12px 0; }
.filter-bar select { padding:6px 12px; border-radius:6px; border:1px solid var(--border); font-size:0.85em; background:var(--card); color:var(--text); }

.panel { display:none; }
.panel.active { display:block; }

/* ============================================================
   SPLIT LAYOUT (passage left + questions right) for tablet+
   ============================================================ */
.split-layout {
  display: flex; gap: 20px; margin-bottom: 16px;
  /* break out of narrow container */
  max-width: 1200px; margin-left: auto; margin-right: auto;
}
.split-passage {
  flex: 0 0 54%; position: sticky; top: 50px;
  max-height: calc(100vh - 60px); overflow-y: auto;
  align-self: flex-start; padding-right: 4px;
  /* subtle scrollbar */
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.split-passage::-webkit-scrollbar { width: 5px; }
.split-passage::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.split-passage .passage-box { margin-bottom: 8px; border-radius: var(--radius); border: 1px solid var(--border); }
.split-passage .passage-header { border-radius: var(--radius) var(--radius) 0 0; }
.split-questions { flex: 1; min-width: 0; }
/* Compact questions in split mode */
@media (min-width: 1024px) {
  .split-questions .question-card { padding: 14px 16px; margin-bottom: 10px; }
  .split-questions .option { padding: 8px 12px; margin: 4px 0; }
  .split-questions .option-label { min-width: 26px; height: 26px; font-size: 0.78em; margin-right: 8px; }
  .split-questions .q-stem { font-size: 0.9em; }
  .split-questions .explanation { padding: 10px 12px; font-size: 0.85em; }
  .split-questions .vocab-box { padding: 8px 12px; font-size: 0.82em; }
}

/* On screens too narrow for split, stack normally */
@media (max-width: 1023px) {
  .split-layout { display: block; max-width: none; }
  .split-passage { position: static; max-height: none; display: none; /* hidden, use float panel instead */ }
  .split-questions { width: 100%; }
}
/* On wide screens hide the inline passage that's inside questions area */
@media (min-width: 1024px) {
  .inline-passage-block { display: none; }
}

/* ============================================================
   PASSAGE SLIDE PANEL (floating, for narrow screens or on-demand)
   ============================================================ */
.passage-panel-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3); z-index: 700;
  animation: fadeIn 0.2s ease;
}
.passage-panel-overlay.show { display: block; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.passage-slide {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 85vw);
  background: var(--card); z-index: 710; overflow-y: auto;
  box-shadow: -4px 0 30px rgba(0,0,0,0.15);
  transform: translateX(100%); transition: transform 0.3s ease;
  padding: 0;
}
.passage-slide.open { transform: translateX(0); }

.passage-slide-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white; position: sticky; top: 0; z-index: 2;
}
.passage-slide-header h3 { font-size: 0.92em; font-weight: 700; }
.passage-slide-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.2); color: white; cursor: pointer;
  font-size: 1.1em; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.passage-slide-close:hover { background: rgba(255,255,255,0.35); }

.passage-slide-tabs {
  display: flex; border-bottom: 2px solid var(--border); background: var(--bg);
  position: sticky; top: 52px; z-index: 1;
}
.passage-slide-tab {
  flex: 1; padding: 10px 8px; text-align: center; font-size: 0.78em;
  font-weight: 600; color: var(--text-light); cursor: pointer;
  border-bottom: 3px solid transparent; transition: all 0.2s;
}
.passage-slide-tab:hover { color: var(--primary); }
.passage-slide-tab.active { color: var(--primary); border-bottom-color: var(--accent); }

.passage-slide-body { padding: 16px 18px; }
.passage-slide-body .passage-box { border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 10px; }

/* Passage float button */
.passage-float-btn {
  display: none; position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 500; background: var(--primary); color: white;
  padding: 9px 20px; border-radius: 28px; border: none; cursor: pointer;
  font-size: 0.85em; font-weight: 700; box-shadow: 0 4px 20px rgba(26,82,118,0.35);
  transition: all 0.25s; white-space: nowrap;
}
.passage-float-btn:hover { transform: translateX(-50%) translateY(-2px); box-shadow: 0 6px 24px rgba(26,82,118,0.45); }
.passage-float-btn.show { display: flex; align-items: center; gap: 6px; }
/* On wide screens with split layout, hide on desktop */
@media (min-width: 1024px) {
  .passage-float-btn.show { display: none; }
}

/* ============================================================
   TABLET OPTIMIZATION
   ============================================================ */
@media (min-width: 768px) and (max-width: 1199px) {
  .container { max-width: 860px; }
  .question-card { padding: 24px; }
  .option { padding: 13px 18px; font-size: 0.95em; }
  .option-label { min-width: 34px; height: 34px; font-size: 0.88em; }
  .q-nav-dot { width: 36px; height: 36px; font-size: 0.78em; }
  .passage-box { padding: 24px; line-height: 1.9; }
  .score-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
  .container { max-width: 1320px; padding: 24px 32px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 767px) {
  .header h1 { font-size: 1.15em; }
  .tab { font-size: 0.74em; padding: 10px 4px; }
  .q-nav-dot { width: 28px; height: 28px; font-size: 0.65em; }
  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .float-pill { padding: 6px 10px; font-size: 0.9em; }
  .float-panel { min-width: 190px; right: 12px; bottom: 58px; }
  .word-collector-float { left: 12px; bottom: 12px; }
}
