: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);
}

.back-to-prepgraph {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.back-to-prepgraph:hover {
  color: var(--accent);
}

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

/* ── User bar ────────────────────────────── */

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
  margin: 0 0px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-logout {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.user-logout:hover {
  color: var(--ink);
  border-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; }

.context.is-brief {
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
  resize: none;
}

/* ── Figure ──────────────────────────────── */

.question-figure {
  margin: 0 0 20px;
  padding: 18px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.question-figure[hidden] { display: none; }

.question-figure img {
  display: block;
  max-width: min(100%, 520px);
  max-height: 440px;
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

/* ── 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; }

.answer-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--correct-bord);
  border-radius: 10px;
  background: var(--correct-bg);
}

.answer-summary span {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--correct);
}

.answer-summary strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.explanation-section {
  margin: 0 0 14px;
}

.explanation-section:last-child {
  margin-bottom: 0;
}

.explanation-section h4 {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.choice-rationales,
.statement-analysis {
  display: grid;
  gap: 8px;
}

.choice-rationale,
.statement-card {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfaf8;
}

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

.choice-letter,
.statement-card b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 28px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.choice-rationale.is-correct .choice-letter {
  border-color: var(--correct);
  color: white;
  background: var(--correct);
}

.choice-rationale p,
.statement-card p {
  margin: 0;
}

/* ── Lessons ─────────────────────────────── */

.lesson-view {
  display: grid;
  gap: 14px;
}

.lesson-view[hidden] { display: none; }

.lesson-section {
  padding: 18px 22px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.lesson-section h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.lesson-section h3 span {
  color: var(--muted);
}

.lesson-section ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.65;
}

.lesson-section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
}

.question-links {
  max-height: 360px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.question-links button {
  width: 100%;
  text-align: left;
  line-height: 1.35;
}

/* ── Onboarding ──────────────────────────── */

#onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.onboarding-modal {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

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

.onboarding-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 6px;
}

.onboarding-sub {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 22px;
}

.onboarding-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.onboarding-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.onboarding-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--accent-light);
}

.onboarding-icon {
  font-size: 24px;
  margin-bottom: 4px;
  line-height: 1;
}

.onboarding-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.onboarding-card-count {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.onboarding-card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 2px;
}

.onboarding-all {
  width: 100%;
  padding: 13px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
}

.onboarding-all:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Study Guide sidebar link ────────────── */

.study-guide-cta {
  padding: 0 8px;
}

.study-guide-btn {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.study-guide-btn:hover {
  background: var(--accent);
  color: white;
}

/* ── Study Guide page ────────────────────── */

.sg-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.sg-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sg-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sg-back {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  transition: border-color 0.1s, color 0.1s;
  white-space: nowrap;
}

.sg-back:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.sg-topic {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.sg-topic select { width: auto; }

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

.question-link-btn {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  line-height: 1.35;
  transition: border-color 0.1s, background 0.1s, color 0.1s;
}

.question-link-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* ── Official GMAC badge ─────────────────── */

.official-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #0f766e;
  color: #0f766e;
  background: #ecfdf5;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
}

.official-badge[hidden] { display: none; }

/* ── Difficulty badge ────────────────────── */

.difficulty-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  margin-top: 6px;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.difficulty-badge[hidden] { display: none; }

.difficulty-beginner  { border: 1px solid #059669; color: #059669; background: #ecfdf5; }
.difficulty-intermediate { border: 1px solid #d97706; color: #92400e; background: #fffbeb; }
.difficulty-advanced  { border: 1px solid #dc2626; color: #dc2626; background: #fef2f2; }

/* GRE type badges (reuse difficulty-badge shape) */
.difficulty-badge[class*="type-"] { border: 1px solid #d4d2cc; color: #5f5e5a; background: #f6f4ee; }
.difficulty-badge.pre-2011 { border-color: #a78bfa; color: #6d28d9; background: #f5f3ff; }

.explanation-empty {
  color: var(--muted);
  font-style: italic;
  margin: 8px 0 0;
}

/* ── Structured explanation ──────────────── */

.answer-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 10px;
}

.answer-summary > span {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.answer-summary > strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.explanation-section {
  margin-bottom: 14px;
}

.explanation-section h4 {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.explanation-section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
}

.statement-analysis {
  display: grid;
  gap: 8px;
}

.statement-card {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: start;
}

.statement-card b {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  padding-top: 2px;
}

.statement-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.choice-rationales {
  display: grid;
  gap: 8px;
}

.choice-rationale {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: start;
}

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

.choice-letter {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  padding-top: 2px;
}

.choice-rationale.is-correct .choice-letter {
  color: var(--correct);
}

.choice-rationale p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

/* ── Concept panel (in explanation) ─────── */

.concept-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.concept-panel h3 {
  margin: 0 0 8px;
}

.concept-note {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
}

.study-focus {
  margin: 0 0 12px;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.study-focus li {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.concept-visual {
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 320px;
}

.concept-visual svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ── 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; }
}
