:root {
  --bg:            #f0f2f5;
  --surf:          #faf9f7;
  --border:        #ede9e3;
  --accent:        #534AB7;
  --accent-light:  #eeedfe;
  --ink:           #111827;
  --muted:         rgba(0,0,0,0.35);
  --correct:       #059669;
  --correct-bg:    #ecfdf5;
  --correct-bord:  #a7f3d0;
  --wrong:         #dc2626;
  --wrong-bg:      #fef2f2;
  --wrong-bord:    #fca5a5;
  --font:          'Satoshi', system-ui, -apple-system, sans-serif;
  --mono:          'JetBrains Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, select, textarea { font: inherit; }

/* ── Layout ─────────────────────────────── */

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

/* ── Sidebar ─────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 12px;
  background: var(--surf);
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 0 8px 4px;
}

.brand {
  margin: 0 0 2px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* ── Controls ────────────────────────────── */

.control {
  display: grid;
  gap: 5px;
  padding: 0 8px;
}

.control > span {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

select {
  width: 100%;
  padding: 9px 30px 9px 11px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: transparent;
}

/* ── Buttons ─────────────────────────────── */

button {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s, color 0.1s;
}

button:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-row {
  display: flex;
  gap: 8px;
  padding: 0 8px;
}

.button-row button { flex: 1; }

/* ── Stats ───────────────────────────────── */

.stats {
  margin-top: auto;
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stats div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.stats span {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats strong {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ── Practice panel ──────────────────────── */

.practice-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

/* ── Topbar ──────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: var(--surf);
  border-bottom: 1px solid var(--border);
}

.meta {
  margin: 0 0 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Timer ───────────────────────────────── */

.timer {
  display: grid;
  gap: 1px;
  min-width: 84px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  text-align: right;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}

.timer:hover { border-color: var(--accent); background: var(--accent-light); }

.timer span {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.timer strong {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.timer.is-paused { border-color: var(--accent); background: var(--accent-light); }
.timer.is-paused span,
.timer.is-paused strong { color: var(--accent); }

.nav-buttons { display: flex; gap: 8px; }

/* ── Question card ───────────────────────── */

.question-card {
  width: min(920px, 100%);
  padding: 28px 32px;
}

/* ── Context passage ─────────────────────── */

.context {
  height: clamp(300px, 44vh, 580px);
  min-height: 200px;
  max-height: 76vh;
  overflow: auto;
  resize: vertical;
  margin-bottom: 20px;
  padding: 20px 24px;
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
}

.context[hidden] { display: none; }
.context p { margin: 0 0 1em; }
.context p:last-child { margin-bottom: 0; }

/* ── Prompt ──────────────────────────────── */

.prompt {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* ── Choices ─────────────────────────────── */

.choices {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.choice {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  text-align: left;
  font-size: 14px;
  line-height: 1.45;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  transition: border-color 0.1s, background 0.1s;
}

.choice b {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  align-self: center;
}

.choice:hover { border-color: var(--accent); background: var(--accent-light); }
.choice.selected { border-color: var(--accent); background: var(--accent-light); }

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

.choice.incorrect { border-color: var(--wrong-bord); background: var(--wrong-bg); }
.choice.incorrect b { color: var(--wrong); }

/* ── Essay ───────────────────────────────── */

.essay-box {
  display: none;
  width: 100%;
  min-height: 320px;
  margin-top: 20px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.65;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  resize: vertical;
}

.essay-box:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: transparent;
}

/* ── Result ──────────────────────────────── */

.result {
  min-height: 22px;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* ── Explanation ─────────────────────────── */

.explanation {
  margin-top: 16px;
  padding: 18px 22px;
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
}

.explanation[hidden] { display: none; }

.explanation h3 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.explanation p { margin: 0 0 0.8em; }
.explanation p:last-child { margin-bottom: 0; }

/* ── Mobile ──────────────────────────────── */

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
  }

  .topbar-actions { justify-content: flex-start; }

  .question-card { padding: 20px; }
}
