:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-2: #242e3c;
  --border: #2d3a4a;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3dd6c6;
  --accent-dim: rgba(61, 214, 198, 0.15);
  --success: #4ade80;
  --success-dim: rgba(74, 222, 128, 0.12);
  --error: #f87171;
  --error-dim: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.brand-icon {
  font-size: 1.75rem;
  color: var(--accent);
}

.brand strong { display: block; font-size: 1.1rem; }
.brand small { color: var(--muted); font-size: 0.8rem; }

.nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }

.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  font-size: 0.85rem;
}

.sidebar-footer .muted { color: var(--muted); }

.menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 1.25rem;
  cursor: pointer;
}

/* Main */
.main {
  padding: 2.5rem 3rem;
  max-width: 960px;
}

.view { display: none; animation: fadeIn 0.35s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero { margin-bottom: 2.5rem; }

.eyebrow {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 400;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.hero h1 em { font-style: italic; color: var(--accent); }

.lead { color: var(--muted); font-size: 1.1rem; max-width: 540px; }

.page-header { margin-bottom: 2rem; }
.page-header h1 { font-family: var(--serif); font-size: 2rem; font-weight: 400; margin-bottom: 0.35rem; }
.page-header p { color: var(--muted); }

/* Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.card-accent { border-color: rgba(61, 214, 198, 0.35); }

.card h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.card p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.card-link { color: var(--accent); font-size: 0.85rem; font-weight: 600; }

.info-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
}

.info-banner h3 { margin-bottom: 0.75rem; font-size: 1rem; }

.info-banner ul { list-style: none; }
.info-banner li {
  padding: 0.4rem 0;
  padding-left: 1.25rem;
  position: relative;
  color: var(--muted);
  font-size: 0.95rem;
}

.info-banner li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* Guide */
.guide-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.guide-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.guide-tab.active, .guide-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.guide-section h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

.guide-section h3 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
}

.guide-section p, .guide-section li {
  color: var(--muted);
  font-size: 0.95rem;
}

.guide-section ul, .guide-section ol {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.guide-section li { margin-bottom: 0.35rem; }

.guide-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.guide-block.highlight {
  border-left: 3px solid var(--accent);
}

/* Quiz / Exam */
.quiz-start, .exam-start {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.quiz-start p, .exam-start p { color: var(--muted); margin-bottom: 1.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.btn:hover { opacity: 0.9; transform: scale(1.02); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
}

.quiz-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

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

.question-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.scenario-context {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.scenario-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warning);
  margin-bottom: 0.5rem;
}

.scenario-context p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  font-style: italic;
}

.scenario-question {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.question-text-fr,
.scenario-question-fr {
  font-size: 0.95rem;
  font-weight: 400;
  margin-top: 0.5rem;
}

.lang-en { color: var(--text); }
.lang-fr {
  color: var(--muted);
  font-size: 0.92em;
  margin-top: 0.45rem;
  line-height: 1.55;
  border-left: 2px solid var(--border);
  padding-left: 0.75rem;
}

.lang-fr-inline {
  color: var(--muted);
  font-size: 0.88em;
}

.scenario-context .lang-en,
.scenario-context .lang-fr {
  font-style: italic;
}

.vocab-glossary { margin-bottom: 1.5rem; }

.glossary-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem 1rem;
}

.glossary-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.75rem 0;
  color: var(--accent);
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.glossary-group h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.glossary-group ul { list-style: none; }

.glossary-group li {
  font-size: 0.85rem;
  padding: 0.3rem 0;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.glossary-group li strong { color: var(--text); }

.glossary-arrow { color: var(--accent); margin: 0 0.35rem; }

.vocab-prompt {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.vocab-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.65rem;
}

.vocab-keyword {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
}

.vocab-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.vocab-pair-en { color: var(--accent); font-weight: 600; }
.vocab-pair-arrow { color: var(--muted); }
.guide-source {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.guide-source a { color: var(--accent); }
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.answer-en { line-height: 1.45; }

.answer-fr {
  font-size: 0.85em;
  line-height: 1.4;
}

.explanation-detail .lang-en {
  margin-bottom: 0.25rem;
}

.explanation-detail .lang-fr {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.question-hint {
  font-size: 0.8rem;
  color: var(--warning);
  margin-bottom: 1.25rem;
}

.answers { display: flex; flex-direction: column; gap: 0.6rem; }

.answer-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.answer-btn:hover:not(:disabled) { border-color: var(--accent); }

.answer-btn.selected { border-color: var(--accent); background: var(--accent-dim); }

.answer-btn.correct { border-color: var(--success); background: var(--success-dim); }
.answer-btn.incorrect { border-color: var(--error); background: var(--error-dim); }
.answer-btn.missed { border-color: var(--success); opacity: 0.7; }

.answer-letter {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.explanation {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.55;
}

.explanation.correct-exp { background: var(--success-dim); border: 1px solid rgba(74, 222, 128, 0.3); }
.explanation.wrong-exp { background: var(--error-dim); border: 1px solid rgba(248, 113, 113, 0.3); }

.explanation-title {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.explanation-answers {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.7;
}

.explanation-answers strong { color: var(--accent); }

.explanation-detail {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
}

.explanation-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

.timer.warning { color: var(--warning); }
.timer.danger { color: var(--error); animation: pulse 1s infinite; }

@keyframes pulse {
  50% { opacity: 0.6; }
}

/* Results */
.results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.score-circle.pass { border-color: var(--success); }
.score-circle.fail { border-color: var(--error); }

.score-value { font-size: 2.5rem; font-weight: 700; line-height: 1; }
.score-label { font-size: 0.8rem; color: var(--muted); }

.results h2 { font-family: var(--serif); font-size: 1.75rem; margin-bottom: 0.5rem; }
.results p { color: var(--muted); margin-bottom: 1.5rem; }

.category-breakdown {
  text-align: left;
  margin-top: 1.5rem;
}

.category-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.category-name { flex: 0 0 140px; font-size: 0.85rem; color: var(--muted); }

.category-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.category-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.category-pct { flex: 0 0 40px; text-align: right; font-size: 0.85rem; font-weight: 600; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }

.history-list { list-style: none; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.history-item .badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}

.badge.pass { background: var(--success-dim); color: var(--success); }
.badge.fail { background: var(--error-dim); color: var(--error); }

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    z-index: 90;
    transition: left 0.3s;
    width: 260px;
  }
  .sidebar.open { left: 0; }
  .menu-toggle { display: block; }
  .main { padding: 4rem 1.25rem 2rem; }
}
