@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg: #faf8f6;
  --bg-2: #f4f1ed;
  --surface: #ffffff;
  --surface-soft: #fdfcfb;
  --text: #2c2c2c;
  --text-secondary: #555;
  --muted: #8a8a8a;
  --line: #e8e4df;
  --line-strong: #d9d4cd;
  --accent: #7c5cfc;
  --accent-strong: #6344e0;
  --accent-soft: #f0ecff;
  --accent-glow: rgba(124, 92, 252, 0.15);
  --warm: #ff8a65;
  --warm-soft: #fff3ee;
  --success-soft: #edf9f0;
  --success-text: #2d8a4e;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgba(124, 92, 252, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 0%, rgba(255, 138, 101, 0.06) 0%, transparent 50%);
  min-height: 100vh;
}

h1, h2, h3 {
  margin: 0;
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent) 0%, var(--warm) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

p {
  margin: 0;
}

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

.shell {
  max-width: 1060px;
  margin: 40px auto;
  padding: 0 20px 40px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card > p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.stack {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.stack > button {
  justify-self: start;
  min-width: 180px;
}

/* ── Tabs ────────────────────────────────────── */

.tab-bar {
  display: flex;
  gap: 0;
  margin-top: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-2);
}

.tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.tab::after {
  display: none;
}

.tab:hover {
  background: var(--surface);
  transform: none;
  box-shadow: none;
}

.tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: none;
  transform: none;
}

.tab-panel {
  margin-top: 16px;
}

/* ── Session Dashboard ──────────────────────── */

.dashboard-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.dashboard-col > h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.session-list {
  max-height: 260px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.session-list:empty::after {
  content: 'None';
  color: var(--muted);
  font-size: 14px;
  padding: 12px 0;
}

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color 0.2s ease;
}

.session-row:hover {
  border-color: var(--accent);
}

.session-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.session-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.session-top strong {
  font-size: 13px;
}

.session-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.progress-bar-bg {
  width: 60px;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

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

.session-detail {
  font-size: 12px;
  color: var(--muted);
}

.session-row > button {
  min-width: 90px;
  font-size: 13px;
  padding: 8px 14px;
}

.dashboard-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.btn-link {
  background: transparent;
  color: var(--accent);
  padding: 6px 12px;
  font-size: 14px;
}

.btn-link::after {
  display: none;
}

.btn-link:hover {
  background: var(--accent-soft);
  box-shadow: none;
  transform: none;
}

/* ── Forms ───────────────────────────────────── */

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder {
  color: var(--muted);
  font-weight: 400;
}

button {
  border: 0;
  border-radius: var(--radius-md);
  padding: 11px 20px;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%);
  pointer-events: none;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* ── Rows ────────────────────────────────────── */

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.between {
  justify-content: space-between;
}

/* (old attempt/resume styles removed — replaced by session dashboard) */

/* ── Exam section ────────────────────────────── */

#examSection {
  padding: 24px;
}

#examTitle {
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.15;
}

#overallTimer {
  min-width: 80px;
  padding: 8px 12px;
  border: 1.5px solid rgba(124, 92, 252, 0.25);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
}

#pauseBtn {
  background: var(--text-secondary);
}

#pauseBtn:hover {
  background: #444;
}

#finishBtn {
  background: var(--warm);
}

#finishBtn:hover {
  background: #e67a55;
  box-shadow: 0 6px 20px rgba(255, 138, 101, 0.2);
}

#questionIndex {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* ── Question prompt ─────────────────────────── */

.prompt {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: var(--surface);
}

.question-body {
  display: grid;
  gap: 14px;
}

.question-stem {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 17px;
  font-weight: 450;
  color: var(--text);
}

.question-image {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
  image-rendering: -webkit-optimize-contrast;
}

.code-block {
  margin: 0;
  background: #1e1e2e;
  color: #cdd6f4;
  border: 1px solid #313244;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  overflow: auto;
}

.code-block code {
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre;
}

/* ── Options ─────────────────────────────────── */

.option-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: var(--surface-soft);
}

.option-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.options-list {
  display: grid;
  gap: 8px;
}

.option-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s ease;
}

.option-item:hover {
  border-color: #999;
  box-shadow: var(--shadow-sm);
}

.option-item.selected {
  border-color: #222;
  background: #f5f5f5;
}

.option-item input {
  margin: 0;
  accent-color: #222;
}

.option-label {
  font-weight: 700;
  color: var(--text);
}

.option-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border: 2px solid #222;
  border-radius: 999px;
  background: #fff;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  color: #222;
  transition: all 0.15s ease;
}

.option-item.selected .option-badge {
  background: #222;
  color: #fff;
}

.compact-options .options-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compact-options .option-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 999px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.compact-options .option-item:hover {
  background: transparent;
  box-shadow: none;
}

.compact-options .option-item input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.compact-options .option-item .option-badge {
  width: 22px;
  height: 18px;
  font-size: 10px;
  border-width: 1.5px;
  border-color: #222;
  color: #222;
  transition: all 0.15s ease;
}

.compact-options .option-item input:checked + .option-badge {
  background: #222;
  border-color: #222;
  color: #fff;
}

/* ── Navigation ──────────────────────────────── */

.nav-bottom {
  margin-top: 14px;
}

#prevBtn {
  min-width: 130px;
  background: var(--line-strong);
  color: var(--text);
}

#prevBtn::after {
  display: none;
}

#prevBtn:hover {
  background: var(--line);
  box-shadow: none;
}

#nextBtn {
  min-width: 130px;
}

/* ── Summary ─────────────────────────────────── */

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.stat-value {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.timing-table {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.timing-row {
  display: grid;
  grid-template-columns: 48px 36px 1fr 56px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
}

.timing-q {
  font-weight: 600;
  color: var(--text);
}

.timing-answer {
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.timing-bar-bg {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}

.timing-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.timing-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}

/* ── Utility ─────────────────────────────────── */

.muted {
  color: var(--muted);
  font-size: 14px;
}

.hidden {
  display: none;
}

pre {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Responsive ──────────────────────────────── */

@media (max-width: 860px) {
  .shell {
    margin: 20px auto;
    padding: 0 12px 20px;
  }

  .card {
    padding: 20px 18px;
    border-radius: var(--radius-lg);
  }

  .row {
    flex-wrap: wrap;
  }

  .between {
    gap: 8px;
  }

  .dashboard-columns {
    grid-template-columns: 1fr;
  }

  .session-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .session-row > button {
    width: 100%;
  }

  #prevBtn,
  #nextBtn {
    min-width: 100px;
  }

  .prompt {
    padding: 14px;
  }

  .option-card {
    padding: 14px;
  }
}
