/* ---------- Design tokens ---------- */
:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-alt: #1e2230;
  --border: #2a2f3f;
  --text: #e4e6ec;
  --text-dim: #9aa0b4;
  --accent: #4fc3f7;
  --accent-dim: #2b5a70;
  --accent-glow: rgba(79, 195, 247, 0.45);
  --green: #57d38c;
  --green-glow: rgba(87, 211, 140, 0.45);
  --yellow: #e8c547;
  --red: #ef6461;
  --red-glow: rgba(239, 100, 97, 0.5);
  --purple: #b48ce8;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* A faint circuit-trace tile (thin right-angle wires + via-dots), plus two
   soft color glows anchored near the top corners - a nod to the subject
   matter (this is a circuit simulator) instead of a plain flat dark page.
   Kept very low-opacity so it reads as ambient texture, not decoration you
   consciously notice or that competes with actual lesson content. */
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 550px at 12% -10%, rgba(79, 195, 247, 0.09), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, rgba(87, 211, 140, 0.06), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cg fill='none' stroke='%234fc3f7' stroke-width='1' opacity='0.075'%3E%3Cpath d='M0 24 H44 V64 H88'/%3E%3Cpath d='M120 96 H88 V64'/%3E%3Ccircle cx='44' cy='64' r='2.5' fill='%234fc3f7'/%3E%3Ccircle cx='88' cy='64' r='2.5' fill='%234fc3f7'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat, repeat;
  background-attachment: fixed;
}

/* A calmer scrollbar than the browser default, matching the dark theme -
   applies everywhere scrolling happens (sidebar, lesson content, editor). */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); background-clip: padding-box; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

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

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1.1rem; }
.brand-icon { color: var(--accent); flex-shrink: 0; filter: drop-shadow(0 0 4px var(--accent-glow)); }
.brand span { color: var(--accent); text-shadow: 0 0 14px var(--accent-glow); }

.progress-summary {
  font-size: 0.85rem;
  color: var(--text-dim);
  background: var(--panel-alt);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ---------- View tabs (Lessons / Projects / Dashboard) ---------- */
.view-tabs {
  display: flex;
  gap: 4px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}

.view-tab {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}

.view-tab:hover { color: var(--text); }

.view-tab.active {
  background: var(--accent);
  color: #06202b;
  font-weight: 600;
}

/* ---------- Top-level views ---------- */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.view[hidden] { display: none; }

.main-panel-wide { max-width: 1100px; }

/* ---------- Layout (Lessons view: sidebar + content) ---------- */
.layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--panel-alt), var(--panel) 220px);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0;
}

/* A thin gradient "trace" along the top, echoing the circuit board this
   whole app teaches - a small detail rather than a loud banner. */
.sidebar::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--green), var(--purple));
}

.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }

/* Desktop-only collapse tab, sitting right on the seam between the sidebar
   and the lesson content - a separate control from .sidebar-toggle above,
   which only exists for the mobile drawer. Collapsing removes the sidebar
   from the flex row entirely, and also lifts .main-panel's max-width cap -
   otherwise the panel would just stop at its own cap instead of actually
   using the space the sidebar left behind. */
.sidebar-collapse-btn {
  display: none;
}

@media (min-width: 769px) {
  .sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    flex-shrink: 0;
    background: var(--panel);
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
  }
  .sidebar-collapse-btn:hover { background: var(--panel-alt); color: var(--text); }

  .layout.sidebar-collapsed .sidebar { display: none; }
  .layout.sidebar-collapsed .main-panel { max-width: none; }
}

/* Below ~768px the two-column layout doesn't fit - the sidebar becomes a
   slide-in drawer instead of a permanent column, opened with a button in
   the top bar. This matters because a student is just as likely to open
   this on a phone as a laptop while away from their desk. */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .layout { position: relative; }

  .sidebar {
    position: fixed;
    top: 49px;
    left: 0;
    bottom: 0;
    width: 82%;
    max-width: 300px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    top: 49px; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
  }

  .main-panel, .main-panel-wide { max-width: 100%; padding: 16px; }
  .topbar { padding: 8px 12px; flex-wrap: wrap; gap: 8px; row-gap: 8px; }
  .brand { font-size: 1rem; }
  .progress-summary { font-size: 0.75rem; padding: 3px 8px; }
  .view-tabs { order: 3; width: 100%; justify-content: center; }
  .view-tab { flex: 1; text-align: center; }
}

.sidebar-level {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-top: 8px;
}

.sidebar-level::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  flex-shrink: 0;
}

.lesson-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  color: var(--text-dim);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lesson-link:hover { background: var(--panel-alt); color: var(--text); }

.lesson-link.active {
  border-left-color: var(--accent);
  background: var(--panel-alt);
  color: var(--text);
  box-shadow: inset 0 0 20px -12px var(--accent-glow);
}

.lesson-check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--text-dim);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lesson-link.done .lesson-check {
  background: var(--green);
  border-color: var(--green);
  color: #06301b;
  box-shadow: 0 0 8px var(--green-glow);
}

.lesson-link.done .lesson-check::after { content: "✓"; }

/* ---------- Main panel ---------- */
/* A short, conceptual-only lesson (no challenge, no quiz) is otherwise just
   a block of text pinned to the top with a dead void underneath - centering
   it vertically makes the page feel composed instead of top-heavy. "safe"
   is the important part: it only centers when everything actually fits: a
   longer lesson (challenge + editor + circuit board) overflows the
   viewport, and centering THAT would push its own top edge above the
   scrollable area, forcing a scroll up just to see the title. Unsupported
   browsers just ignore the whole rule and get today's plain top-alignment. */
.main-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 60px;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
}

/* The lesson prose itself stays at a readable line length even though its
   container (.main-panel, above) now stretches much wider - only the code
   editor and circuit board actually benefit from the extra width. */
.lesson-content {
  max-width: 760px;
}

.lesson-content h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.lesson-eyebrow {
  color: var(--accent);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.lesson-content p {
  line-height: 1.6;
  color: var(--text);
}

.lesson-content code {
  background: var(--panel-alt);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.85em;
  color: var(--accent);
}

.code-block {
  background: #0b0d13;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
  white-space: pre;
  overflow-x: auto;
  margin: 12px 0;
  color: #dcdfe6;
}

.note-box {
  border-left: 3px solid var(--purple);
  background: rgba(180, 140, 232, 0.08);
  padding: 10px 14px;
  border-radius: 4px;
  margin: 12px 0;
  font-size: 0.9rem;
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.lesson-nav-right {
  display: flex;
  gap: 10px;
}

/* ---------- Editor ---------- */
.editor-section { margin-top: 28px; }

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.editor-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.CodeMirror {
  height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.9rem;
}

.editor-note {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 6px;
}

.editor-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.component-picker {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* ---------- Simulator / circuit board ---------- */
.simulator-section { margin-top: 28px; }

.sim-svg {
  width: 100%;
  height: auto;
  background: #0b0d13;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 8px;
}

.sim-connector-hit { cursor: pointer; }
.sim-connector-hit:hover + .sim-connector { filter: brightness(1.6); stroke: #fff; }
.sim-wire { cursor: pointer; }
.sim-wire:hover { stroke: var(--red) !important; opacity: 0.7; }
.sim-draggable { cursor: grab; }
.sim-draggable:active { cursor: grabbing; }

.wire-palette {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.wire-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
}

.wire-swatch.auto {
  background: repeating-conic-gradient(from 0deg, #4fc3f7 0deg 90deg, #57d38c 90deg 180deg, #f5c542 180deg 270deg, #e2453c 270deg 360deg);
  font-size: 0;
}

.wire-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

.console-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  margin-bottom: 6px;
}

.sim-console {
  background: #0b0d13;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-height: 90px;
  max-height: 200px;
  overflow-y: auto;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  color: var(--green);
  white-space: pre-wrap;
  margin: 0;
}

.sim-console .sim-error { color: var(--red); }
.sim-console .sim-status { color: var(--text-dim); }

/* ---------- Buttons ---------- */
/* Two different speeds on purpose: hover eases in like the button is
   lifting off the page (150ms), but the press-down on click is snappier
   (70ms) so it actually feels like a click landing, not a slow squish. */
.btn {
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.96); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition-duration: 0.07s; }
.btn:disabled { cursor: default; transform: none; opacity: 0.5; box-shadow: none; }

.btn-secondary { background: var(--panel-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-primary { background: var(--accent); color: #06202b; font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 6px 18px var(--accent-glow); }

.btn-hint {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}
.btn-hint:hover:not(:disabled) { background: rgba(79, 195, 247, 0.12); border-color: var(--accent); }

/* Stop is only ever clickable while a sketch is actively running (it's
   disabled otherwise) - a soft pulse while enabled reinforces "this is
   live" for free, straight from the existing disabled attribute with no
   JS changes needed. */
.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 100, 97, 0.15); }
.btn-danger:not(:disabled) { animation: btn-pulse-red 1.6s ease-in-out infinite; }

.btn-complete {
  background: var(--green);
  color: #06301b;
  font-weight: 600;
}
.btn-complete:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 6px 18px var(--green-glow); }

@keyframes btn-pulse-red {
  0%, 100% { box-shadow: 0 0 0 rgba(239, 100, 97, 0); }
  50% { box-shadow: 0 0 10px var(--red-glow); }
}

/* ---------- Challenge section ---------- */
.challenge-section { margin-top: 28px; }

.challenge-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.challenge-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.difficulty-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.difficulty-easy { color: var(--green); border-color: var(--green); }
.difficulty-medium { color: var(--yellow); border-color: var(--yellow); }
.difficulty-hard { color: var(--red); border-color: var(--red); }
.difficulty-boss { color: var(--purple); border-color: var(--purple); }

.challenge-prompt { margin: 8px 0 14px; line-height: 1.5; }

.hint-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.hint-box {
  background: var(--panel-alt);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.solution-box {
  background: var(--panel-alt);
  border-left: 3px solid var(--green);
  border-radius: 4px;
  padding: 10px 14px;
  margin-top: 8px;
}

/* ---------- Status bar ---------- */
.statusbar {
  flex-shrink: 0;
  padding: 4px 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ==================== Quiz / code games ==================== */
.quiz-section { margin-top: 28px; }

.quiz-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.quiz-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }

.quiz-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--purple);
  color: var(--purple);
}

.quiz-prompt { margin: 8px 0 14px; line-height: 1.5; }

/* Drag-to-reorder list (a "Parsons problem" - arrange scrambled code lines) */
.quiz-order-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quiz-line-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0b0d13;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
  white-space: pre;
  user-select: none;
}

.quiz-line-item.dragging { opacity: 0.4; border-color: var(--accent); }
.quiz-line-item.correct { border-color: var(--green); background: rgba(87, 211, 140, 0.08); }
.quiz-line-item.incorrect { border-color: var(--red); background: rgba(239, 100, 97, 0.08); }

.quiz-drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 1rem;
  flex-shrink: 0;
  touch-action: none;
}
.quiz-drag-handle:active { cursor: grabbing; }

.quiz-line-text { flex: 1; overflow-x: auto; }

.quiz-move-buttons { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.quiz-move-btn {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 3px;
  width: 20px;
  height: 16px;
  font-size: 0.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.quiz-move-btn:hover { color: var(--text); }
.quiz-move-btn:disabled { opacity: 0.3; cursor: default; }

.quiz-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.quiz-result {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.9rem;
}
.quiz-result.success { background: rgba(87, 211, 140, 0.1); border-left: 3px solid var(--green); color: var(--green); }
.quiz-result.failure { background: rgba(239, 100, 97, 0.1); border-left: 3px solid var(--red); color: var(--red); }

/* Predict-the-output multiple choice */
.quiz-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.quiz-option {
  text-align: left;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.quiz-option:hover { border-color: var(--accent-dim); }
.quiz-option.selected { border-color: var(--accent); background: rgba(79, 195, 247, 0.1); }
.quiz-option.correct { border-color: var(--green); background: rgba(87, 211, 140, 0.12); }
.quiz-option.incorrect { border-color: var(--red); background: rgba(239, 100, 97, 0.12); }
.quiz-option:disabled { cursor: default; }

/* ==================== Projects ==================== */
.projects-intro { margin-bottom: 20px; }
.projects-intro h1 { margin-bottom: 6px; }
.projects-intro p { color: var(--text-dim); line-height: 1.5; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.project-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.project-card.locked { cursor: default; opacity: 0.55; }
.project-card.locked:hover { transform: none; border-color: var(--border); }

.project-card-icon { font-size: 1.8rem; margin-bottom: 8px; }
.project-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.project-card p { margin: 0 0 10px; color: var(--text-dim); font-size: 0.85rem; line-height: 1.4; }

.project-progress-bar {
  height: 6px;
  background: var(--panel-alt);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.project-progress-fill { height: 100%; background: var(--green); border-radius: 999px; }

.project-lock-note { font-size: 0.78rem; color: var(--red); margin-top: 8px; }

.project-detail-header { margin-bottom: 20px; }
.project-detail-header .btn { margin-bottom: 14px; }

.project-stage-tracker {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.project-stage-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.project-stage-dot.done { background: var(--green); border-color: var(--green); color: #06301b; font-weight: 600; }
.project-stage-dot.active { border-color: var(--accent); color: var(--accent); }

.project-stage-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.project-stage-card h3 { margin: 0 0 8px; }
.project-stage-card p { line-height: 1.55; }
.project-stage-card.done { border-left: 3px solid var(--green); }

/* ==================== Dashboard ==================== */
.dashboard-header { margin-bottom: 24px; }
.dashboard-header h1 { margin-bottom: 4px; }
.dashboard-header p { color: var(--text-dim); }

.rank-ladder {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 20px 0 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.rank-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.rank-step:last-child { border-bottom: none; }
.rank-step.achieved { background: rgba(87, 211, 140, 0.06); }
.rank-step.current { background: rgba(79, 195, 247, 0.1); }
.rank-step.locked { opacity: 0.45; }

.rank-step-badge {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
}
.rank-step.achieved .rank-step-badge { background: var(--green); border-color: var(--green); }
.rank-step.current .rank-step-badge { background: var(--accent); border-color: var(--accent); }

.rank-step-name { font-weight: 600; }
.rank-step-desc { font-size: 0.8rem; color: var(--text-dim); }
.rank-step-tag {
  margin-left: auto;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-tile-value { font-size: 1.6rem; font-weight: 700; }
.stat-tile-label { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }

.dashboard-section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 24px 0 10px;
}

.weak-topic-list { display: flex; flex-direction: column; gap: 8px; }
.weak-topic-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.88rem;
}
.weak-topic-row .tag { font-size: 0.75rem; color: var(--red); }

.dashboard-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 12px 0;
}
