:root {
  --bg: #0d1226;
  --bg2: #141b36;
  --card: #171e3d;
  --line: #2a3468;
  --text: #e8ecff;
  --muted: #9aa3c7;
  --accent: #6ea8fe;
  --accent2: #b48cf2;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- app bar ---------- */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--accent);
  background: rgba(110, 168, 254, 0.12);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.brand h1 { font-size: 20px; margin: 0; letter-spacing: 0.5px; }
.brand p { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

.ghost-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
}

/* ---------- home ---------- */
#homeView, #sessionView {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.intro h2 {
  font-size: 26px;
  margin: 8px 0;
  line-height: 1.25;
}
.intro p { color: var(--muted); font-size: 15px; line-height: 1.6; }

.arc {
  display: flex;
  gap: 8px;
  margin: 18px 0 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.arc-step {
  flex: 1 0 auto;
  min-width: 96px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.arc-step span {
  display: block;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 4px;
}

.problem-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 20px;
}
@media (min-width: 700px) {
  .problem-grid { grid-template-columns: 1fr 1fr; }
}

.problem-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  width: 100%;
}
.problem-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.problem-card h3 { margin: 0 0 6px; font-size: 18px; }
.problem-card .lc { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.diff { font-size: 12px; font-weight: 600; }
.diff.Easy { color: var(--good); }
.diff.Medium { color: var(--warn); }
.diff.Hard { color: var(--bad); }
.problem-card .why {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 10px 0 12px;
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.card-tags span {
  font-size: 11px;
  background: rgba(110, 168, 254, 0.12);
  color: var(--accent);
  border-radius: 20px;
  padding: 3px 10px;
}
.start-mock {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent2);
}

.site-foot {
  margin-top: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- session ---------- */
.session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.timer-wrap { text-align: center; }
.timer {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 2px;
}
.timer.low { color: var(--warn); }
.timer.done { color: var(--bad); }
.phase { font-size: 13px; color: var(--muted); margin-top: 2px; }
.timer-controls { display: flex; gap: 8px; }

.primary-btn {
  background: var(--accent);
  color: #0d1226;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.ghost-btn.small { padding: 6px 10px; font-size: 12px; }
.ghost-btn.danger { color: var(--bad); }

.timebar {
  height: 6px;
  background: var(--bg2);
  border-radius: 4px;
  margin: 14px 0 4px;
  overflow: hidden;
}
#timeProgress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 1s linear;
}

.session-title { font-size: 24px; margin: 14px 0 4px; }
.session-meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.session-meta .diff { margin-right: 8px; }

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tabs button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-family: inherit;
}
.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.fu-count {
  font-size: 11px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1px 8px;
  margin-left: 4px;
}

.why-box {
  background: rgba(180, 140, 242, 0.08);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent2);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
}
.why-box strong { color: var(--accent2); }

.statement {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.7;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.tab-panel h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); }
.constraints { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.8; }
.constraints code, .example code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg2);
  padding: 2px 6px;
  border-radius: 6px;
}
.example {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 10px;
  overflow-x: auto;
}

/* ---------- code tab ---------- */
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}
.code-head > div { display: flex; gap: 8px; }
#codePad {
  width: 100%;
  min-height: 380px;
  background: #0a0e20;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  tab-size: 4;
}
#codePad:focus { outline: none; border-color: var(--accent); }
.notes-h { margin-top: 20px; }
#notesPad.notes {
  width: 100%;
  min-height: 120px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
}

/* ---------- follow-ups ---------- */
.fu-intro { color: var(--muted); font-size: 14px; line-height: 1.6; }
.followup {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.followup .fu-title { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.followup .fu-prompt {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.followup.locked { text-align: center; padding: 20px; }
.followup.locked .fu-title { color: var(--muted); margin-bottom: 10px; }

/* ---------- solution ---------- */
.solution-meta {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}
.solution-meta code {
  font-family: var(--mono);
  background: var(--bg2);
  color: var(--text);
  padding: 2px 8px;
  border-radius: 6px;
}
.solution-pre {
  background: #0a0e20;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  color: var(--text);
}

/* ---------- debrief ---------- */
.rubric-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
}
.rubric-item input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--good);
  flex-shrink: 0;
}
.rubric-item.checked { border-color: var(--good); }
.rubric-item.checked span { color: var(--muted); text-decoration: line-through; }
#resetRubric { margin-top: 12px; }
