:root {
  --primary: #1B4F72;
  --secondary: #2E86C1;
  --accent: #D4E6F1;
  --success: #27AE60;
  --danger: #E74C3C;
  --warning: #F39C12;
  --bg: #F8F9FA;
  --card: #FFFFFF;
  --text: #2C3E50;
  --muted: #95A5A6;
  --border: #DEE2E6;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── NAV ── */
.nav {
  background: var(--primary);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 60px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  color: white;
  font-size: 20px;
  font-weight: 700;
  margin-right: 40px;
  letter-spacing: -0.5px;
}
.nav-brand span { color: var(--accent); font-weight: 400; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-link:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-link.active { color: white; background: rgba(255,255,255,0.2); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.nav-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
}
.nav-user-name {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-weight: 500;
}
.nav-logout {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.nav-logout:hover { color: white; background: rgba(255,255,255,0.1); }

/* ── LOGIN ── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 24px;
}
.login-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
  padding: 48px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}
.login-card h2 {
  font-size: 24px;
  color: var(--primary);
  margin-bottom: 8px;
}
.login-card p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 32px;
}
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 32px;
  background: white;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-google:hover {
  border-color: var(--secondary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.btn-google svg { width: 20px; height: 20px; }

/* ── MIGRATION BANNER ── */
.migration-banner {
  background: var(--accent);
  border: 1px solid var(--secondary);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
}
.migration-banner-text { color: var(--primary); }
.migration-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── LAYOUT ── */
.container { max-width: 960px; margin: 0 auto; padding: 24px; }

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

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
}

/* ── QUIZ ── */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.quiz-progress {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}
.quiz-score {
  font-size: 14px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--primary);
}
.progress-bar-track {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 24px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--secondary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.image-container {
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-container img {
  max-width: 100%;
  max-height: 450px;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 0.3s;
}
.image-container img.zoomed {
  transform: scale(1.8);
  cursor: zoom-out;
}
.image-loading {
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  padding: 40px;
}
.image-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.vignette {
  background: var(--accent);
  border-left: 4px solid var(--secondary);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--primary);
}
.hint-btn {
  background: none;
  border: none;
  color: var(--secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 0;
  text-decoration: underline;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.hint-btn:hover { opacity: 1; }
.hint-content {
  margin-top: 8px;
  line-height: 1.7;
  animation: fadeIn 0.3s ease;
}

/* Image carousel navigation */
.image-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 5;
  line-height: 1;
}
.image-nav:hover { background: rgba(0,0,0,0.8); }
.image-nav-left { left: 12px; }
.image-nav-right { right: 12px; }
.image-counter {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  z-index: 5;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  text-align: left;
  transition: all 0.15s;
  position: relative;
}
.option-btn:hover:not(.disabled) {
  border-color: var(--secondary);
  background: #F0F8FF;
}
.option-btn .option-letter {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}
.option-btn.selected { border-color: var(--secondary); background: #E8F4FD; }
.option-btn.selected .option-letter { background: var(--secondary); color: white; }
.option-btn.correct { border-color: var(--success); background: #EAFAF1; }
.option-btn.correct .option-letter { background: var(--success); color: white; }
.option-btn.incorrect { border-color: var(--danger); background: #FDEDEC; }
.option-btn.incorrect .option-letter { background: var(--danger); color: white; }
.option-btn.disabled { pointer-events: none; opacity: 0.85; }
.option-btn.disabled.dimmed { opacity: 0.5; }

.explanation {
  margin-top: 20px;
  padding: 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  animation: fadeIn 0.3s ease;
}
.explanation.correct-exp { background: #EAFAF1; border: 1px solid #A9DFBF; }
.explanation.incorrect-exp { background: #FDEDEC; border: 1px solid #F5B7B1; }
.explanation h4 { margin-bottom: 8px; font-size: 15px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.quiz-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--secondary); color: white; }
.btn-primary:hover { background: var(--primary); }
.btn-primary:disabled { background: var(--muted); cursor: not-allowed; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219A52; }
.btn-lg { padding: 14px 32px; font-size: 16px; }

/* ── START SCREEN ── */
.start-screen { text-align: center; padding: 60px 20px; }
.start-screen h2 { font-size: 28px; color: var(--primary); margin-bottom: 12px; }
.start-screen p { color: var(--muted); font-size: 16px; margin-bottom: 32px; max-width: 500px; margin-left: auto; margin-right: auto; }
.start-options { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.start-option {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  cursor: pointer;
  transition: all 0.2s;
  width: 180px;
  text-align: center;
}
.start-option:hover { border-color: var(--secondary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.start-option .count { font-size: 28px; font-weight: 700; color: var(--secondary); }
.start-option .label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ── SESSION COMPLETE ── */
.session-complete { text-align: center; padding: 40px 20px; }
.session-complete h2 { font-size: 24px; color: var(--primary); margin-bottom: 8px; }
.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 24px auto;
  font-size: 36px;
  font-weight: 700;
  border: 6px solid;
}
.score-circle.good { border-color: var(--success); color: var(--success); }
.score-circle.ok { border-color: var(--warning); color: var(--warning); }
.score-circle.poor { border-color: var(--danger); color: var(--danger); }
.score-circle small { font-size: 13px; font-weight: 500; color: var(--muted); }

.session-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin: 24px 0;
  flex-wrap: wrap;
}
.stat-item { text-align: center; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ── DASHBOARD ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-align: center;
}
.stat-card .big-number { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .stat-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }

.dx-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.dx-bar-row:last-child { border-bottom: none; }
.dx-bar-label { width: 180px; font-weight: 500; flex-shrink: 0; }
.dx-bar-track { flex: 1; height: 20px; background: var(--bg); border-radius: 10px; overflow: hidden; }
.dx-bar-fill { height: 100%; border-radius: 10px; transition: width 0.5s ease; }
.dx-bar-value { width: 80px; text-align: right; font-weight: 600; flex-shrink: 0; }

.history-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.history-row:last-child { border-bottom: none; }

.weakness-tag {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  margin: 4px;
}
.weakness-tag.weak { background: #FDEDEC; color: var(--danger); }
.weakness-tag.strong { background: #EAFAF1; color: var(--success); }
.weakness-tag.neutral { background: var(--accent); color: var(--secondary); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state h3 { color: var(--primary); margin-bottom: 8px; }

/* ── SETTINGS ── */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-weight: 500; }
.setting-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
select, input[type="number"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .container { padding: 16px; }
  .nav-brand { font-size: 16px; margin-right: 16px; }
  .nav-link { padding: 6px 10px; font-size: 13px; }
  .nav-user-name { display: none; }
  .image-container img { max-height: 280px; }
  .start-options { flex-direction: column; align-items: center; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .migration-banner { flex-direction: column; text-align: center; }
}
