/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0064ff;
  --primary-dark: #004fd4;
  --primary-light: #e8f0ff;
  --success: #00c48c;
  --success-light: #e6faf3;
  --danger: #ff4757;
  --danger-light: #fff0f1;
  --warning: #ffb800;
  --warning-light: #fff8e6;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  --transition: all 0.25s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --primary: #4d8eff;
  --primary-dark: #3a7bff;
  --primary-light: rgba(77,142,255,0.12);
  --success: #34d399;
  --success-light: rgba(52,211,153,0.12);
  --danger: #f87171;
  --danger-light: rgba(248,113,113,0.12);
  --warning: #fbbf24;
  --warning-light: rgba(251,191,36,0.12);
  --text: #e8eaf0;
  --text-secondary: #8b95a8;
  --bg: #0f1117;
  --card: #181a24;
  --border: #2a2d3a;
  --shadow: 0 2px 12px rgba(0,0,0,0.30);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
}

html { font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 24px 100px;
}

/* ===== HEADER / NAV ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-bottom: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  letter-spacing: -0.5px;
  cursor: pointer;
}

.logo-icon { font-size: 1.8rem; }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px 6px 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.user-badge:hover { background: var(--bg); }

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
}

.sub-badge {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  color: #92400e;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
}

[data-theme="dark"] .sub-badge { color: var(--warning); }

.stats-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.stats-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* ===== BOTTOM NAV (Liquid Glass) ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.45);
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 8px 0 6px;
  z-index: 100;
  box-shadow: 0 -4px 30px rgba(0, 100, 255, 0.06), 0 -1px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .bottom-nav {
  background: rgba(15, 17, 23, 0.75);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.3), 0 -1px 8px rgba(0, 0, 0, 0.2);
}

.nav-item {
  flex: 1;
  max-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  transition: var(--transition);
  text-decoration: none;
  border-radius: 12px;
  position: relative;
}

.nav-item .nav-icon {
  font-size: 1.3rem;
  transition: var(--transition);
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  inset: 2px 8px;
  background: rgba(0, 100, 255, 0.08);
  border-radius: 12px;
  z-index: -1;
}

[data-theme="dark"] .nav-item.active::before {
  background: rgba(77, 142, 255, 0.15);
}

.nav-item.active .nav-icon {
  transform: scale(1.15);
  filter: drop-shadow(0 2px 6px rgba(0, 100, 255, 0.3));
}

[data-theme="dark"] .nav-item.active .nav-icon {
  filter: drop-shadow(0 2px 6px rgba(77, 142, 255, 0.4));
}

.nav-item:hover {
  color: var(--primary);
}

.nav-item:hover .nav-icon {
  transform: scale(1.1) translateY(-1px);
}

.nav-item .nav-lock {
  font-size: 0.6rem;
  opacity: 0.5;
}

/* ===== AUTH SCREENS ===== */
.auth-container {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-icon { font-size: 3rem; }
.auth-logo h1 {
  font-size: 2rem;
  color: var(--primary);
  letter-spacing: -1px;
}
.auth-logo p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
  background: var(--bg);
  color: var(--text);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

[data-theme="dark"] .form-input:focus { background: var(--card); }

.auth-error {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 16px;
  text-align: center;
}

.auth-success {
  background: var(--success-light);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #065f46;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 16px;
  text-align: center;
}

[data-theme="dark"] .auth-success { color: var(--success); }

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.auth-switch a:hover { text-decoration: underline; }

/* ===== HOME/DASHBOARD ===== */
.hero {
  text-align: left;
  padding: 36px 8px 32px;
}

.hero h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 8px;
  line-height: 1.2;
}

.hero h1 span { color: var(--primary); }

.hero p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 560px;
  margin: 0 0 24px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.action-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.action-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.action-card .action-icon { font-size: 1.8rem; margin-bottom: 8px; }

.action-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.action-card p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.action-card.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.action-card.locked:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}

.lock-overlay {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 0.8rem;
}

/* ===== READINESS GAUGE (Marine Barometer) ===== */
.readiness-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 24px;
  text-align: center;
  transition: var(--transition);
}

.readiness-section:hover {
  box-shadow: var(--shadow);
}

.readiness-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 20px;
}

/* Barometer container */
.barometer {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
}

.barometer svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.barometer-track {
  fill: none;
  stroke: var(--bg);
  stroke-width: 14;
  stroke-linecap: round;
}

.barometer-fill {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(.4,0,.2,1), stroke 0.6s ease;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.15));
}

.barometer-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -30%);
  text-align: center;
}

.barometer-percent {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
}

.barometer-label {
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 4px;
}

.barometer-icon {
  font-size: 1.4rem;
  margin-top: 2px;
}

.barometer-zones {
  display: flex;
  justify-content: space-between;
  max-width: 220px;
  margin: 0 auto 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.barometer-zones span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.barometer-zones .zone-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.gauge-simple-percent { display: none; }
.gauge-simple { display: none; }

.readiness-tip {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ===== CHART ===== */
.chart-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.chart-section:hover {
  box-shadow: var(--shadow);
}

[data-theme=\"dark\"] .chart-section:hover {
  border-color: rgba(77,142,255,0.2);
}

.chart-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.chart-container {
  position: relative;
  height: 240px;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 100px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 14px 36px;
  font-size: 1rem;
  box-shadow: 0 4px 16px rgba(0,100,255,0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,100,255,0.35);
}

[data-theme="dark"] .btn-primary { box-shadow: 0 4px 16px rgba(77,142,255,0.25); }
[data-theme="dark"] .btn-primary:hover { box-shadow: 0 8px 28px rgba(77,142,255,0.35); }

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 28px;
  font-size: 0.95rem;
}

.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  padding: 10px 24px;
  font-size: 0.9rem;
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.85rem;
}

.btn-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 1.2rem;
  color: var(--text-secondary);
}

.btn-icon:hover { background: var(--bg); }

.btn-full { width: 100%; }

/* ===== PROGRESS BAR ===== */
.progress-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.progress-info .question-counter {
  font-weight: 700;
  color: var(--primary);
}

.progress-info .theme-tag {
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 12px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 100px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #38b6ff);
  border-radius: 100px;
  transition: width 0.4s cubic-bezier(.4,0,.2,1);
}

/* ===== QUESTION CARD ===== */
.question-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px 24px;
  box-shadow: var(--shadow);
  animation: slideUp 0.35s cubic-bezier(.4,0,.2,1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.question-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.5;
  letter-spacing: -0.3px;
}

/* ===== CHOICES ===== */
.choices { display: flex; flex-direction: column; gap: 10px; }

.choice-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text);
}

.choice-btn:hover:not(.disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.choice-btn .choice-letter {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--bg);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.choice-btn:hover:not(.disabled) .choice-letter {
  background: var(--primary);
  color: #fff;
}

.choice-btn.selected { border-color: var(--primary); background: var(--primary-light); }
.choice-btn.selected .choice-letter { background: var(--primary); color: #fff; }
.choice-btn.correct { border-color: var(--success); background: var(--success-light); }
.choice-btn.correct .choice-letter { background: var(--success); color: #fff; }
.choice-btn.wrong { border-color: var(--danger); background: var(--danger-light); }
.choice-btn.wrong .choice-letter { background: var(--danger); color: #fff; }
.choice-btn.disabled { cursor: default; opacity: 0.7; }
.choice-btn.disabled.correct, .choice-btn.disabled.wrong { opacity: 1; }

/* ===== QCM ===== */
.qcm-badge {
  display: inline-block;
  padding: 2px 10px;
  background: var(--warning-light);
  color: #92400e;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
}

.qcm-badge-sm {
  display: inline-block;
  padding: 1px 6px;
  background: var(--warning-light);
  color: #92400e;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
}

[data-theme="dark"] .qcm-badge,
[data-theme="dark"] .qcm-badge-sm { color: var(--warning); }

.qcm-hint {
  font-size: 0.82rem;
  color: var(--warning);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--warning-light);
  border-radius: var(--radius-sm);
  text-align: center;
}

.check-mark {
  margin-left: auto;
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 5px;
  flex-shrink: 0;
  position: relative;
  transition: var(--transition);
}

.choice-btn.selected .check-mark { background: var(--primary); border-color: var(--primary); }
.choice-btn.selected .check-mark::after { content: '✓'; position: absolute; top: -1px; left: 3px; color: #fff; font-size: 0.8rem; font-weight: 700; }
.choice-btn.correct .check-mark { background: var(--success); border-color: var(--success); }
.choice-btn.correct .check-mark::after { content: '✓'; position: absolute; top: -1px; left: 3px; color: #fff; font-size: 0.8rem; font-weight: 700; }
.choice-btn.wrong .check-mark { background: var(--danger); border-color: var(--danger); }
.choice-btn.wrong .check-mark::after { content: '✗'; position: absolute; top: -1px; left: 3px; color: #fff; font-size: 0.85rem; font-weight: 700; }

/* ===== EXPLANATION ===== */
.explanation {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
  animation: fadeIn 0.3s ease;
}

.explanation.correct-explanation { background: var(--success-light); border-left: 4px solid var(--success); color: #065f46; }
.explanation.wrong-explanation { background: var(--danger-light); border-left: 4px solid var(--danger); color: #991b1b; }
[data-theme="dark"] .explanation.correct-explanation { color: var(--success); }
[data-theme="dark"] .explanation.wrong-explanation { color: var(--danger); }
.explanation .explanation-title { font-weight: 700; margin-bottom: 4px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.next-area { display: flex; justify-content: flex-end; margin-top: 20px; }

/* ===== RESULTS SCREEN ===== */
.results-header { text-align: center; padding: 32px 20px; }

.results-header .score-circle {
  width: 150px; height: 150px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 0 auto 20px;
  font-weight: 800; font-size: 2.8rem;
  line-height: 1; border: 6px solid;
}

.results-header .score-circle.passed { background: var(--success-light); border-color: var(--success); color: var(--success); }
.results-header .score-circle.failed { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.results-header .score-circle small { font-size: 0.9rem; font-weight: 600; opacity: 0.7; }
.results-header h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.results-header p { color: var(--text-secondary); font-size: 0.95rem; }

.results-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  text-align: center;
}

.summary-card .summary-value { font-size: 1.6rem; font-weight: 800; }
.summary-card .summary-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; }
.summary-card.good .summary-value { color: var(--success); }
.summary-card.bad .summary-value { color: var(--danger); }

/* ===== THEME BREAKDOWN ===== */
.theme-breakdown {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.theme-breakdown h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}

.theme-row:last-child { border-bottom: none; }
.theme-name { font-size: 0.88rem; font-weight: 600; flex: 1; }

.theme-bar-wrap {
  flex: 1.5;
  margin: 0 16px;
  height: 8px;
  background: var(--bg);
  border-radius: 100px;
  overflow: hidden;
}

.theme-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
}

.theme-score { font-size: 0.82rem; font-weight: 700; min-width: 50px; text-align: right; }

/* ===== REVIEW LIST ===== */
.review-section { margin-top: 24px; }
.review-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }

.review-toggle { margin-bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.review-toggle .btn { min-width: 0; }
.review-toggle .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.review-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 10px;
}

.review-item.review-correct { border-left: 4px solid var(--success); }
.review-item.review-wrong { border-left: 4px solid var(--danger); }
.review-item .review-q { font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
.review-item .review-answer { font-size: 0.83rem; color: var(--text-secondary); }
.review-item .review-answer strong { color: var(--text); }

.review-item .review-explanation {
  font-size: 0.82rem; color: var(--text-secondary);
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--bg);
}

/* ===== ACTIONS ===== */
.results-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 32px;
  flex-wrap: wrap;
}

/* ===== HISTORY ===== */
.history-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition);
}

.history-card:hover { background: var(--bg); transform: translateX(4px); }

.history-info { display: flex; flex-direction: column; gap: 2px; }
.history-info .history-title { font-weight: 600; font-size: 0.9rem; }
.history-info .history-date { font-size: 0.78rem; color: var(--text-secondary); }

.history-type-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 6px;
}

.history-type-badge.exam { background: var(--primary-light); color: var(--primary); }
.history-type-badge.training { background: var(--warning-light); color: #92400e; }

.history-score {
  font-weight: 800;
  font-size: 1.1rem;
  padding: 4px 14px;
  border-radius: 100px;
}

.history-score.passed { background: var(--success-light); color: var(--success); }
.history-score.failed { background: var(--danger-light); color: var(--danger); }

/* ===== TRAINING PAGE ===== */
.training-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.theme-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.theme-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.theme-card .theme-icon { font-size: 2rem; margin-bottom: 8px; }
.theme-card h4 { font-size: 0.85rem; font-weight: 700; margin-bottom: 4px; }
.theme-card .theme-count { font-size: 0.75rem; color: var(--text-secondary); }

.theme-card .theme-mastery {
  margin-top: 8px;
  height: 4px;
  background: var(--bg);
  border-radius: 100px;
  overflow: hidden;
}

.theme-card .theme-mastery-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s;
}

/* ===== LESSONS ===== */
.lesson-list { display: flex; flex-direction: column; gap: 10px; }

.lesson-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.lesson-card:hover { border-color: var(--primary); background: var(--primary-light); transform: translateX(4px); }

.lesson-icon { font-size: 1.6rem; flex-shrink: 0; }

.lesson-info h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 2px; }
.lesson-info .lesson-theme { font-size: 0.78rem; color: var(--text-secondary); }

.lesson-arrow { margin-left: auto; color: var(--text-secondary); font-size: 1.2rem; }

/* ===== LESSON DETAIL ===== */
.lesson-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 20px;
}

.lesson-content h3 {
  font-size: 1.1rem; font-weight: 700;
  color: var(--primary); margin: 20px 0 10px;
}

.lesson-content h3:first-child { margin-top: 0; }

.lesson-content h4 { font-size: 0.95rem; font-weight: 700; margin: 16px 0 8px; }

.lesson-content p { margin-bottom: 10px; line-height: 1.7; font-size: 0.92rem; }

.lesson-content ul, .lesson-content ol {
  margin: 0 0 10px 20px; font-size: 0.92rem; line-height: 1.7;
}

.lesson-content li { margin-bottom: 4px; }
.lesson-content table { width: 100%; margin: 12px 0; border-collapse: collapse; }
.lesson-content strong { color: var(--primary-dark); }
[data-theme="dark"] .lesson-content strong { color: var(--primary); }

.key-points {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
}

[data-theme="dark"] .key-points { border-color: rgba(77,142,255,0.3); }

.key-points h4 {
  font-size: 0.9rem; font-weight: 700;
  color: var(--primary); margin-bottom: 8px;
}

.key-points ul { list-style: none; padding: 0; margin: 0; }

.key-points li {
  padding: 4px 0 4px 20px;
  font-size: 0.85rem;
  position: relative;
}

.key-points li::before {
  content: '✓'; position: absolute; left: 0;
  color: var(--primary); font-weight: 700;
}

/* ===== SUBSCRIPTION ===== */
.sub-section { text-align: center; padding: 40px 20px; }
.sub-section .sub-icon { font-size: 3rem; margin-bottom: 16px; }

.sub-section h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }

.sub-section p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 24px; }

.sub-features {
  display: flex; flex-direction: column; gap: 10px;
  text-align: left; max-width: 360px; margin: 0 auto 28px;
}

.sub-feature { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.sub-feature .feat-icon { font-size: 1.2rem; }

.sub-active {
  background: var(--success-light);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.sub-active h3 { color: var(--success); font-size: 1.2rem; font-weight: 800; margin-bottom: 4px; }
.sub-active p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0; }

.key-input-group {
  display: flex; gap: 8px; max-width: 400px; margin: 0 auto;
}

.key-input-group .form-input {
  text-transform: uppercase; letter-spacing: 2px;
  font-weight: 600; text-align: center;
}

/* ===== PROFILE ===== */
.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800;
  flex-shrink: 0;
}

.profile-info h3 { font-size: 1.1rem; font-weight: 700; }
.profile-info p { font-size: 0.82rem; color: var(--text-secondary); }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.profile-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.profile-stat .stat-value { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.profile-stat .stat-label { font-size: 0.75rem; color: var(--text-secondary); }

/* ===== TIMER ===== */
.timer {
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 4px;
}

.question-timer-wrap {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 16px; padding: 0 4px;
}

.question-timer-bar {
  flex: 1; height: 6px;
  background: linear-gradient(90deg, var(--primary), #38b6ff);
  border-radius: 100px;
  transition: width 0.15s linear;
}

.question-timer-bar.timer-warning { background: linear-gradient(90deg, var(--warning), #ffd54f); }

.question-timer-bar.timer-danger {
  background: linear-gradient(90deg, var(--danger), #ff6b6b);
  animation: pulse-timer 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-timer { from { opacity: 1; } to { opacity: 0.6; } }

.question-timer-text {
  font-size: 0.82rem; font-weight: 700;
  color: var(--text-secondary);
  min-width: 28px; text-align: right;
}

/* ===== QUESTION IMAGE ===== */
.question-image {
  display: flex; justify-content: center;
  margin-bottom: 20px; padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.question-image svg {
  max-width: 220px; max-height: 200px;
  width: 100%; height: auto;
}

/* ===== SECTION TITLES ===== */
.section-title {
  font-size: 1.2rem; font-weight: 800;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

.section-subtitle {
  font-size: 0.85rem; color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ===== BACK BUTTON ===== */
.back-row {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 16px;
}

.back-btn {
  background: none; border: none;
  font-size: 1.2rem; cursor: pointer;
  color: var(--text-secondary); padding: 4px;
  transition: var(--transition);
}

.back-btn:hover { color: var(--primary); }

.back-row h2 { font-size: 1.1rem; font-weight: 700; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }

.empty-state h3 {
  font-size: 1.1rem; font-weight: 700;
  color: var(--text); margin-bottom: 6px;
}

.empty-state p { font-size: 0.9rem; margin-bottom: 20px; }

/* ===== RESPONSIVE ===== */

/* Large screens — use the extra space */
@media (min-width: 900px) {
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
  .training-grid { grid-template-columns: repeat(3, 1fr); }
  .results-summary { grid-template-columns: repeat(3, 1fr); }
  .profile-card { padding: 28px 32px; }
}

/* Tablet */
@media (max-width: 899px) and (min-width: 601px) {
  #app { padding: 20px 20px 100px; }
}

/* Mobile */
@media (max-width: 600px) {
  #app { max-width: 100%; padding: 16px 14px 100px; }
  .hero { text-align: center; padding: 28px 8px 24px; }
  .hero p { margin: 0 auto 24px; }
  .hero h1 { font-size: 1.5rem; }
  .quick-actions { grid-template-columns: 1fr; }
  .training-grid { grid-template-columns: 1fr; }
  .results-summary { grid-template-columns: 1fr; }
  .profile-stats { grid-template-columns: 1fr; }
  .question-card { padding: 24px 18px 18px; }
  .question-card h2 { font-size: 1.05rem; }
  .results-header .score-circle { width: 120px; height: 120px; font-size: 2.2rem; }
  .auth-card { padding: 24px 20px; }
  .key-input-group { flex-direction: column; }
}

/* ===== ENTRANCE ANIMATIONS ===== */
@keyframes animFadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes animFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes animScaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes animSlideRight {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Hero */
.hero {
  animation: animSlideRight 0.5s cubic-bezier(.4,0,.2,1) both;
}

.hero h1 {
  animation: animFadeUp 0.5s cubic-bezier(.4,0,.2,1) 0.1s both;
}

.hero p {
  animation: animFadeUp 0.5s cubic-bezier(.4,0,.2,1) 0.2s both;
}

/* Quick action cards — staggered */
.action-card {
  animation: animFadeUp 0.45s cubic-bezier(.4,0,.2,1) both;
}
.action-card:nth-child(1) { animation-delay: 0.08s; }
.action-card:nth-child(2) { animation-delay: 0.16s; }
.action-card:nth-child(3) { animation-delay: 0.24s; }
.action-card:nth-child(4) { animation-delay: 0.32s; }

/* Readiness & chart sections */
.readiness-section {
  animation: animScaleIn 0.5s cubic-bezier(.4,0,.2,1) 0.15s both;
}

.barometer {
  animation: animScaleIn 0.6s cubic-bezier(.4,0,.2,1) 0.3s both;
}

.chart-section {
  animation: animScaleIn 0.5s cubic-bezier(.4,0,.2,1) 0.25s both;
}

/* Training theme cards — staggered */
.theme-card {
  animation: animFadeUp 0.4s cubic-bezier(.4,0,.2,1) both;
}
.theme-card:nth-child(1) { animation-delay: 0.05s; }
.theme-card:nth-child(2) { animation-delay: 0.10s; }
.theme-card:nth-child(3) { animation-delay: 0.15s; }
.theme-card:nth-child(4) { animation-delay: 0.20s; }
.theme-card:nth-child(5) { animation-delay: 0.25s; }
.theme-card:nth-child(6) { animation-delay: 0.30s; }
.theme-card:nth-child(7) { animation-delay: 0.35s; }
.theme-card:nth-child(8) { animation-delay: 0.40s; }

/* Lessons list — staggered */
.lesson-card {
  animation: animFadeUp 0.4s cubic-bezier(.4,0,.2,1) both;
}
.lesson-card:nth-child(1) { animation-delay: 0.05s; }
.lesson-card:nth-child(2) { animation-delay: 0.10s; }
.lesson-card:nth-child(3) { animation-delay: 0.15s; }
.lesson-card:nth-child(4) { animation-delay: 0.20s; }
.lesson-card:nth-child(5) { animation-delay: 0.25s; }
.lesson-card:nth-child(6) { animation-delay: 0.30s; }

/* Lesson detail */
.lesson-content {
  animation: animFadeUp 0.5s cubic-bezier(.4,0,.2,1) 0.1s both;
}

/* History cards — staggered */
.history-card {
  animation: animFadeUp 0.35s cubic-bezier(.4,0,.2,1) both;
}
.history-card:nth-child(1) { animation-delay: 0.05s; }
.history-card:nth-child(2) { animation-delay: 0.10s; }
.history-card:nth-child(3) { animation-delay: 0.12s; }
.history-card:nth-child(4) { animation-delay: 0.14s; }
.history-card:nth-child(5) { animation-delay: 0.16s; }
.history-card:nth-child(n+6) { animation-delay: 0.18s; }

/* Profile */
.profile-card {
  animation: animSlideRight 0.5s cubic-bezier(.4,0,.2,1) both;
}

.profile-stat {
  animation: animScaleIn 0.4s cubic-bezier(.4,0,.2,1) both;
}
.profile-stat:nth-child(1) { animation-delay: 0.1s; }
.profile-stat:nth-child(2) { animation-delay: 0.18s; }
.profile-stat:nth-child(3) { animation-delay: 0.26s; }

/* Auth */
.auth-logo {
  animation: animFadeUp 0.5s cubic-bezier(.4,0,.2,1) both;
}

.auth-card {
  animation: animScaleIn 0.45s cubic-bezier(.4,0,.2,1) 0.15s both;
}

/* Subscription */
.sub-section {
  animation: animFadeUp 0.5s cubic-bezier(.4,0,.2,1) both;
}

.sub-active {
  animation: animScaleIn 0.5s cubic-bezier(.4,0,.2,1) 0.1s both;
}

/* Results — score circle pop-in */
@keyframes animPopIn {
  0% { opacity: 0; transform: scale(0.5); }
  70% { transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

.results-header .score-circle {
  animation: animPopIn 0.6s cubic-bezier(.4,0,.2,1) 0.1s both;
}

.summary-card {
  animation: animFadeUp 0.4s cubic-bezier(.4,0,.2,1) both;
}
.summary-card:nth-child(1) { animation-delay: 0.15s; }
.summary-card:nth-child(2) { animation-delay: 0.22s; }
.summary-card:nth-child(3) { animation-delay: 0.29s; }

.theme-breakdown {
  animation: animFadeUp 0.5s cubic-bezier(.4,0,.2,1) 0.2s both;
}

/* Section titles */
.section-title {
  animation: animSlideRight 0.4s cubic-bezier(.4,0,.2,1) both;
}

/* Back row */
.back-row {
  animation: animFadeIn 0.3s cubic-bezier(.4,0,.2,1) both;
}

/* Empty state */
.empty-state {
  animation: animFadeUp 0.5s cubic-bezier(.4,0,.2,1) 0.1s both;
}

/* Bottom nav gentle entrance */
.bottom-nav {
  animation: animFadeIn 0.4s cubic-bezier(.4,0,.2,1) both;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg);
  transform: rotate(20deg) scale(1.08);
}
