/* =============================================================================
   STEP QUESTIONS — STYLESHEET
   =============================================================================

   Structure
   ─────────
   1.  Design Tokens (Custom Properties)
   2.  Dark Mode Overrides
   3.  Reset & Base
   4.  Typography
   5.  Layout — App Shell
   6.  Topbar
   7.  Sidebar
   8.  Viewer
   9.  Attempt Panel
  10.  Stars / Difficulty
  11.  Timer
  12.  Solution Section
  13.  Question Navigation
  14.  Past Attempts Sidebar
  15.  Tag Chips
  16.  Buttons
  17.  Modals
  18.  Notifications
  19.  Splash Screen
  20.  Dashboard — Layout
  21.  Dashboard — Stats
  22.  Dashboard — STEP Matrix
  23.  Dashboard — Charts
  24.  Dashboard — Heatmap
  25.  Dashboard — Priority List
  26.  Dashboard — Recent Activity
  27.  Dashboard — Day Screen
  28.  Animations
  29.  Utilities
  30.  Responsive

   ============================================================================= */


/* =============================================================================
   1. DESIGN TOKENS
   ============================================================================= */
:root {
  /* ── Typefaces ── */
  --font-sans:  "IBM Plex Sans",  system-ui, sans-serif;
  --font-mono:  "IBM Plex Mono",  "Courier New", monospace;

  /* ── Colour palette ── */
  --clr-bg:           #f4f3ef;   /* warm off-white */
  --clr-surface:      #ffffff;
  --clr-surface-alt:  #f9f8f5;
  --clr-border:       #e2e0d9;
  --clr-border-strong: #c8c5bc;

  --clr-text:         #1a1916;
  --clr-text-muted:   #6b6860;
  --clr-text-xmuted:  #9c9890;

  /* ── Accent: deep navy-ink ── */
  --clr-accent:       #1a2744;
  --clr-accent-hover: #0f1a30;
  --clr-accent-soft:  #eef1f8;
  --clr-accent-text:  #1a2744;

  /* ── Semantic colours ── */
  --clr-success:      #1a6b45;
  --clr-success-bg:   #edfaf3;
  --clr-warning:      #92470a;
  --clr-warning-bg:   #fff7ed;
  --clr-danger:       #9b1c1c;
  --clr-danger-bg:    #fef2f2;
  --clr-info-bg:      #eff6ff;

  /* ── Shape ── */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  /* ── Elevation ── */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 4px 8px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 24px rgba(0,0,0,0.09), 0 4px 8px rgba(0,0,0,0.06);

  /* ── Motion ── */
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
  --duration:   180ms;
  --transition: var(--duration) var(--ease);

  /* ── Sidebar ── */
  --sidebar-w:  300px;

  /* ── Topbar ── */
  --topbar-h:   52px;
}


/* =============================================================================
   2. DARK MODE OVERRIDES
   ============================================================================= */
body.dark-mode {
  --clr-bg:            #111110;
  --clr-surface:       #1c1b1a;
  --clr-surface-alt:   #242322;
  --clr-border:        #2e2d2b;
  --clr-border-strong: #3d3c39;

  --clr-text:          #e8e6e1;
  --clr-text-muted:    #8a8780;
  --clr-text-xmuted:   #5a5855;

  --clr-accent:        #7ea8e8;
  --clr-accent-hover:  #9bbcee;
  --clr-accent-soft:   #1a2744;
  --clr-accent-text:   #7ea8e8;

  --clr-success-bg:    #0d2b1d;
  --clr-warning-bg:    #2a1a06;
  --clr-danger-bg:     #2a0d0d;
  --clr-info-bg:       #0d1a2e;

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow:     0 4px 8px rgba(0,0,0,0.5);
  --shadow-lg:  0 12px 24px rgba(0,0,0,0.6);
}


/* =============================================================================
   3. RESET & BASE
   ============================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  background: var(--clr-bg);
  color: var(--clr-text);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

ul { list-style: none; }

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

input, select, textarea {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
  color: var(--clr-text);
}

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

textarea { resize: vertical; }

hr {
  border: none;
  border-top: 1px solid var(--clr-border);
}

/* Remove number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }


/* =============================================================================
   4. TYPOGRAPHY
   ============================================================================= */
h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
}

.mono {
  font-family: var(--font-mono);
}


/* =============================================================================
   5. LAYOUT — APP SHELL
   ============================================================================= */
.app-layout {
  display: grid;
  grid-template-areas:
    "topbar  topbar"
    "sidebar viewer";
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}


/* =============================================================================
   6. TOPBAR
   ============================================================================= */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  z-index: 100;
}

.topbar__logo {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--clr-text-muted);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.topbar__logo:hover { color: var(--clr-text); }

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.topbar__auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar__user {
  position: relative;
}

.avatar {
  font-size: 1rem;
  line-height: 1;
}

/* Dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 200;
  transform-origin: top right;
  animation: dropdown-appear 120ms var(--ease) forwards;
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--clr-text);
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}

.dropdown__item:hover { background: var(--clr-bg); }

.dropdown__item--danger { color: var(--clr-danger); }
.dropdown__item--danger:hover { background: var(--clr-danger-bg); }

.dropdown__icon { font-size: 0.85rem; }

.dropdown__divider { margin: 4px 0; }


/* =============================================================================
   7. SIDEBAR
   ============================================================================= */
.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  overflow: hidden;
}

.sidebar__search {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--clr-border);
}

.sidebar__search input[type="search"] {
  width: 100%;
  background: var(--clr-surface-alt);
}

/* Question list */
.question-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--clr-border) transparent;
}

.question-list li {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.question-list li:hover {
  background: var(--clr-surface-alt);
  color: var(--clr-text);
}

.question-list li.active {
  background: var(--clr-accent-soft);
  color: var(--clr-accent-text);
  font-weight: 600;
}


/* =============================================================================
   8. VIEWER
   ============================================================================= */
.viewer-area {
  grid-area: viewer;
  overflow-y: auto;
  background: var(--clr-bg);
}

.viewer {
  padding: 2rem;
  min-height: 100%;
}

.viewer__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - var(--topbar-h) - 4rem);
}

.viewer__empty-text {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--clr-text-xmuted);
}

/* Question header */
.question-header {
  margin-bottom: 1.5rem;
}

.question-title {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.question-title h2 {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  letter-spacing: 0.04em;
}

.question-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-muted {
  font-size: 0.8rem;
  color: var(--clr-text-xmuted);
  font-style: italic;
}

/* Two-column layout inside viewer */
.question-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.5rem;
  align-items: start;
}

/* Question image card */
.question-content {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.question-content img {
  margin: 0;
  width: 100%;
}

/* Sidebar (right column) */
.question-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question-sidebar h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--clr-text-muted);
  margin-bottom: 0.25rem;
}

/* Animate panels in */
.question-main,
.question-sidebar {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 250ms var(--ease), transform 250ms var(--ease);
}

.question-main.show,
.question-sidebar.show {
  opacity: 1;
  transform: none;
}

/* =============================================================================
   [8b] VIEWER — STATUS BADGE + FLAG BUTTON
   ============================================================================= */

/* Row sitting below the question title */
.viewer-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.viewer-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.viewer-badge.status-completed {
  background: var(--clr-success-bg);
  color: var(--clr-success);
}

.viewer-badge.status-attempted {
  background: var(--clr-warning-bg);
  color: var(--clr-warning);
}

.viewer-badge.status-none {
  background: var(--clr-surface-alt);
  color: var(--clr-text-xmuted);
  border: 1px solid var(--clr-border);
}

.viewer-badge-meta {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
}

/* Flag button */
#viewer-flag-btn {
  margin-left: auto;
  font-size: 1.1rem;
  color: var(--clr-text-xmuted);
  transition: color var(--transition), transform var(--transition);
}

#viewer-flag-btn:hover  { color: var(--clr-warning); transform: scale(1.15); }
#viewer-flag-btn.flagged { color: var(--clr-warning); }




/* =============================================================================
   9. ATTEMPT PANEL
   ============================================================================= */
.attempt-panel {
  margin-top: 1.25rem;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.attempt-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.attempt-row:last-child { margin-bottom: 0; }

.attempt-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 160px;
}

.attempt-field.full {
  flex: 1 1 100%;
}

.attempt-field label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
}

.attempt-field select,
.attempt-field textarea {
  width: 100%;
}

.attempt-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--clr-border);
}

#commit-attempt.success {
  background: var(--clr-success-bg);
  border-color: var(--clr-success);
  color: var(--clr-success);
  animation: pulse-success 600ms var(--ease);
}


/* =============================================================================
   10. STARS / DIFFICULTY
   ============================================================================= */
.stars {
  display: flex;
  gap: 3px;
  font-size: 1.2rem;
  cursor: pointer;
  user-select: none;
  padding-top: 2px;
}

.stars span {
  transition: transform var(--transition), opacity var(--transition);
}

.stars span:hover { transform: scale(1.25); }


/* =============================================================================
   11. TIMER
   ============================================================================= */
.time-control {
  align-items: flex-start;
}

.timer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
}

#time-display {
  cursor: pointer;
  transition: color var(--transition);
}

#time-display:hover { color: var(--clr-accent); }

.timer-buttons { margin-top: 4px; }

.timer-buttons button,
.time-save-btn {
  padding: 5px 12px;
  background: var(--clr-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.timer-buttons button:hover,
.time-save-btn:hover { background: var(--clr-accent-hover); }

.timer-buttons button:disabled {
  background: var(--clr-border);
  color: var(--clr-text-muted);
  cursor: not-allowed;
}

/* Inline time edit inputs */
.time-edit-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--clr-text-muted);
}

.time-edit-input {
  width: 48px;
  padding: 4px 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
}

.time-save-btn { margin-left: 4px; }


/* =============================================================================
   12. SOLUTION SECTION
   ============================================================================= */
.solution-section { margin-top: 1.25rem; }

#solution-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 500ms var(--ease);
}

#solution-container.show { max-height: 5000px; }

#solution-container img {
  margin: 1rem 0;
  border: 1px solid var(--clr-border);
}

/* =============================================================================
   [12b] IMAGE ZOOM — LIGHTBOX
   ============================================================================= */

/* Zoomable cursor hint */
.zoomable {
  cursor: zoom-in;
  transition: opacity var(--transition);
}

.zoomable:hover { opacity: 0.9; }

/* Full-screen overlay */
#zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
}

#zoom-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.zoom-img {
  max-width: min(90vw, 1100px);
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
  animation: zoom-appear 200ms var(--ease);
}

.zoom-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.zoom-close:hover { background: rgba(255,255,255,0.25); }

@keyframes zoom-appear {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: none; opacity: 1; }
}




/* =============================================================================
   13. QUESTION NAVIGATION
   ============================================================================= */
.question-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--clr-border);
}


/* =============================================================================
   14. PAST ATTEMPTS SIDEBAR
   ============================================================================= */
#past-notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.past-attempt {
  position: relative;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 0.875rem;
  transition: border-color var(--transition);
}

.past-attempt:hover { border-color: var(--clr-border-strong); }

.past-meta {
  font-size: 0.75rem;
  line-height: 1.8;
  color: var(--clr-text-muted);
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
}

.past-notes {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--clr-text);
}

.delete-attempt {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 1rem;
  color: var(--clr-border-strong);
  cursor: pointer;
  transition: color var(--transition);
  line-height: 1;
}

.delete-attempt:hover { color: var(--clr-danger); }

.delete-attempt.confirm {
  color: var(--clr-danger);
  font-weight: 700;
}

.empty-attempts {
  font-size: 0.8rem;
  color: var(--clr-text-xmuted);
  font-style: italic;
  padding: 0.5rem 0;
}


/* =============================================================================
   15. TAG CHIPS
   ============================================================================= */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  background: var(--clr-accent-soft);
  color: var(--clr-accent-text);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  border: 1px solid transparent;
}

.tag-chip:hover {
  background: var(--clr-accent);
  color: #fff;
  transform: translateY(-1px);
}


/* =============================================================================
   16. BUTTONS
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-surface);
  color: var(--clr-text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), transform var(--transition),
              box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--clr-surface-alt);
  border-color: var(--clr-border-strong);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Variants */
.btn--primary {
  background: var(--clr-accent);
  border-color: var(--clr-accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--clr-accent-hover);
  border-color: var(--clr-accent-hover);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--clr-surface-alt);
  border-color: var(--clr-border);
}

.btn--icon {
  padding: 6px 8px;
  background: transparent;
  border-color: transparent;
  font-size: 1rem;
}

.btn--icon:hover {
  background: var(--clr-surface-alt);
  border-color: var(--clr-border);
}

.btn--sm { padding: 5px 11px; font-size: 0.8rem; }

/* Used in attempt panel */
button.primary {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  background: var(--clr-accent);
  border: 1px solid var(--clr-accent);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

button.primary:hover { background: var(--clr-accent-hover); }
button.primary:disabled { opacity: 0.4; cursor: not-allowed; }

button.secondary {
  padding: 7px 14px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

button.secondary:hover { background: var(--clr-surface-alt); }


/* =============================================================================
   [16b] FLAG BUTTON — SIDEBAR LIST INDICATOR
   Optionally show a small flag on flagged questions in the sidebar
   ============================================================================= */

.question-list li.flagged::after {
  content: "⚑";
  font-size: 0.7rem;
  color: var(--clr-warning);
  margin-left: auto;
  padding-left: 6px;
}



/* =============================================================================
   17. MODALS
   ============================================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: min(380px, calc(100vw - 2rem));
  box-shadow: var(--shadow-lg);
  animation: modal-appear 180ms var(--ease) forwards;
}

.modal-content h3 {
  font-size: 1.15rem;
  margin-bottom: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 0.875rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--clr-text-muted);
}

.form-group input {
  width: 100%;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--clr-border);
}

.modal-actions .btn { flex: 1; justify-content: center; }


/* =============================================================================
   18. NOTIFICATIONS
   ============================================================================= */
#notifications {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 340px;
}

.notification {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  cursor: pointer;
  animation: toast-in 200ms var(--ease) forwards;
  transition: opacity 120ms, transform 120ms;
}

.notification.closing {
  opacity: 0;
  transform: translateX(10px);
}

.notification.info    { background: var(--clr-info-bg);    border-color: #bfdbfe; color: #1e40af; }
.notification.success { background: var(--clr-success-bg); border-color: #6ee7b7; color: var(--clr-success); }
.notification.warning { background: var(--clr-warning-bg); border-color: #fcd34d; color: var(--clr-warning); }
.notification.danger  { background: var(--clr-danger-bg);  border-color: #fca5a5; color: var(--clr-danger); }

.notification-title {
  font-weight: 700;
  margin-bottom: 2px;
}


/* =============================================================================
   19. SPLASH SCREEN
   ============================================================================= */
#splash-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 9999;
  opacity: 1;
  transition: opacity 1.5s var(--ease);
}

#splash-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

#chaos-canvas {
  position: absolute;
  inset: 0;
}

/* =============================================================================
   [19b] EXAM — HEADER
   ============================================================================= */
.exam-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.5rem;
  padding: 0.875rem 1.5rem;
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  box-shadow: var(--shadow-sm);
}

.exam-header--finished { opacity: 0.5; pointer-events: none; }

.exam-header__left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.exam-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Countdown timer */
.exam-header__center { text-align: center; }

.exam-timer {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--clr-text);
  transition: color var(--transition);
}

.exam-timer.timer-warn { color: var(--clr-warning); }
.exam-timer.timer-crit { color: var(--clr-danger);  }

.exam-timer-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  margin-top: 2px;
}

/* Progress bar (right side) */
.exam-header__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.exam-progress { width: 100%; max-width: 200px; }

.exam-progress__text {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  display: block;
  margin-bottom: 4px;
  text-align: right;
}

.exam-progress__track {
  height: 4px;
  background: var(--clr-border);
  border-radius: 999px;
  overflow: hidden;
}

.exam-progress__bar {
  height: 100%;
  background: var(--clr-accent);
  border-radius: 999px;
  transition: width 300ms var(--ease);
}


/* =============================================================================
   [19c] EXAM — BODY + QUESTION BLOCKS
   ============================================================================= */
.exam-body {
  height: calc(100vh - 70px); /* header height */
  overflow-y: auto;
  background: var(--clr-bg);
}

.exam-questions {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* Individual question block */
.exam-question-block {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.exam-question-block__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.25rem;
  background: var(--clr-surface-alt);
  border-bottom: 1px solid var(--clr-border);
}

.exam-q-number {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--clr-text);
}

.exam-q-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-unattempted { background: var(--clr-surface); border: 1px solid var(--clr-border); color: var(--clr-text-xmuted); }
.badge-attempted   { background: var(--clr-success-bg); color: var(--clr-success); }

.exam-question-block__body {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
}

/* Question image */
.exam-question-block__img {
  padding: 1.5rem;
  border-right: 1px solid var(--clr-border);
}

.exam-question-block__img img { width: 100%; }

/* Notes + controls panel */
.exam-question-block__panel {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.exam-field { display: flex; flex-direction: column; gap: 6px; }

.exam-field__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
}

.exam-stars { font-size: 1.3rem; }

.exam-notes {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  background: var(--clr-surface-alt);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  color: var(--clr-text);
  transition: border-color var(--transition);
}

.exam-notes:focus {
  outline: none;
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-soft);
}

.exam-field--checkbox { margin-top: auto; padding-top: 0.5rem; border-top: 1px solid var(--clr-border); }

.exam-attempted-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--clr-text-muted);
}

.exam-attempted-cb { cursor: pointer; width: 16px; height: 16px; accent-color: var(--clr-accent); }


/* =============================================================================
   [19d] EXAM — RESULTS SCREEN
   ============================================================================= */
.exam-results {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--clr-bg);
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1.5rem 5rem;
}

.exam-results__inner {
  width: min(800px, 100%);
}

.exam-results__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* Summary stats row */
.exam-results__stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.results-stat {
  flex: 1;
  min-width: 120px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.results-stat__val {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--clr-text);
}

.results-stat__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--clr-text-muted);
}

/* Per-question results list */
.exam-results__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2rem;
}

.results-row {
  display: grid;
  grid-template-columns: 160px 40px 110px 1fr;
  align-items: center;
  gap: 1rem;
  padding: 10px 14px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.results-row__id    { font-family: var(--font-mono); font-weight: 700; }
.results-row__stars { color: var(--clr-warning); font-size: 0.8rem; letter-spacing: 1px; }
.results-row__notes { color: var(--clr-text-muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.exam-results__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}


/* =============================================================================
   [19e] EXAM — PICKER MODAL
   ============================================================================= */
.exam-picker-content { max-width: 440px; }

.exam-picker__select-row { margin-bottom: 0.5rem; }

.exam-picker-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  background: var(--clr-surface-alt);
  font-size: 0.9rem;
  color: var(--clr-text);
  cursor: pointer;
}


/* =============================================================================
   RESPONSIVE — EXAM
   ============================================================================= */
@media (max-width: 768px) {
  .exam-header {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .exam-header__right { display: none; } /* progress bar too cramped */

  .exam-question-block__body { grid-template-columns: 1fr; }
  .exam-question-block__img  { border-right: none; border-bottom: 1px solid var(--clr-border); }

  .results-row { grid-template-columns: 1fr 40px; grid-template-rows: auto auto; }
  .results-row__stars { display: none; }
  .results-row__notes { grid-column: 1 / -1; }
}

/* =============================================================================
   20. DASHBOARD — LAYOUT
   ============================================================================= */
.dashboard-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--clr-border);
}

.dashboard-header__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  margin-bottom: 0.25rem;
}

.dashboard-header__title {
  font-size: 1.75rem;
  font-weight: 700;
}

.dashboard-section {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.dashboard-section__title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.dashboard-section__subtitle {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  margin-bottom: 1rem;
}

.unit {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--clr-text-muted);
}

.dashboard-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}


/* =============================================================================
   21. DASHBOARD — STATS
   ============================================================================= */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.stat-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.stat-card h3 {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  margin-bottom: 0.35rem;
}

.stat-card .value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--clr-text);
}


/* =============================================================================
   22. DASHBOARD — STEP MATRIX
   ============================================================================= */
.step-matrix {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 0.75rem;
}

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

.matrix-year {
  width: 48px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  flex-shrink: 0;
}

.matrix-cell {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition);
  border: 1px solid rgba(0,0,0,0.06);
}

.matrix-cell:hover { transform: scale(1.35); z-index: 1; }

.matrix-paper-gap { width: 14px; flex-shrink: 0; }

/* Cell states */
.matrix-missing  { background: transparent; border-color: transparent; cursor: default; }
.matrix-empty    { background: var(--clr-surface-alt); border-color: var(--clr-border); }
.matrix-low      { background: #c7d2fe; border-color: #a5b4fc; }
.matrix-mid      { background: #6366f1; border-color: #4f46e5; }
.matrix-high     { background: #1e1b4b; border-color: #312e81; }

body.dark-mode .matrix-empty { background: #2a2928; }
body.dark-mode .matrix-low   { background: #1e3a5f; border-color: #2563eb; }
body.dark-mode .matrix-mid   { background: #2563eb; border-color: #3b82f6; }
body.dark-mode .matrix-high  { background: #7ea8e8; border-color: #93c5fd; }

/* Legend */
.matrix-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
}

.matrix-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--clr-text-muted);
}

.matrix-legend__item::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.1);
  background: currentColor;
}

.matrix-legend__item.matrix-empty::before  { background: var(--clr-surface-alt); border-color: var(--clr-border); }
.matrix-legend__item.matrix-low::before    { background: #c7d2fe; }
.matrix-legend__item.matrix-mid::before    { background: #6366f1; }
.matrix-legend__item.matrix-high::before   { background: #1e1b4b; }


/* =============================================================================
   23. DASHBOARD — CHARTS
   ============================================================================= */
/* Canvas sizing handled in section rule above */


/* =============================================================================
   24. DASHBOARD — HEATMAP
   ============================================================================= */
.heatmap {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 4px;
  margin-top: 0.5rem;
}

.heat-day {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: pointer;
  transition: transform var(--transition);
}

.heat-day:hover { transform: scale(1.3); z-index: 1; }

/* Intensity scale */
.heat-0  { background: var(--clr-surface-alt); }
.heat-1  { background: #dbeafe; }
.heat-2  { background: #bfdbfe; }
.heat-3  { background: #93c5fd; }
.heat-4  { background: #60a5fa; }
.heat-5  { background: #3b82f6; }
.heat-6  { background: #2563eb; }
.heat-7  { background: #1d4ed8; }
.heat-8  { background: #1e40af; }
.heat-9  { background: #1e3a8a; }
.heat-10 { background: #172554; }

body.dark-mode .heat-0  { background: #242322; }
body.dark-mode .heat-1  { background: #082f49; }
body.dark-mode .heat-2  { background: #0c4a6e; }
body.dark-mode .heat-3  { background: #075985; }
body.dark-mode .heat-4  { background: #0369a1; }
body.dark-mode .heat-5  { background: #0284c7; }
body.dark-mode .heat-6  { background: #0ea5e9; }
body.dark-mode .heat-7  { background: #38bdf8; }
body.dark-mode .heat-8  { background: #7ea8e8; }
body.dark-mode .heat-9  { background: #93c5fd; }
body.dark-mode .heat-10 { background: #bfdbfe; }


/* =============================================================================
   25. DASHBOARD — PRIORITY LIST
   ============================================================================= */
.priority-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.priority-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  background: var(--clr-surface-alt);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--clr-text);
}


/* =============================================================================
   [26b] TOPIC DETAIL — FULL SCREEN PANEL
   ============================================================================= */

#topic-detail-panel {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
}

#topic-detail-panel.open {
  opacity: 1;
  pointer-events: auto;
}

.topic-detail__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(3px);
}

.topic-detail__sheet {
  position: relative;
  z-index: 1;
  background: var(--clr-bg);
  width: min(1100px, 100vw);
  max-height: 100vh;
  overflow-y: auto;
  padding: 2.5rem 2rem 4rem;
  box-shadow: var(--shadow-lg);
  animation: modal-appear 200ms var(--ease);
}

/* On larger screens, show as a centred modal rather than full-width */
@media (min-width: 768px) {
  .topic-detail__sheet {
    width: min(1100px, 92vw);
    max-height: 90vh;
    margin-top: 5vh;
    border-radius: var(--radius-xl);
    border: 1px solid var(--clr-border);
  }
}

.topic-detail__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--clr-border);
}

.topic-detail__title { font-size: 1.6rem; font-weight: 700; }

.topic-detail__close { flex-shrink: 0; }

/* Summary pills */
.topic-detail__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.topic-summary-pill {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--clr-text-muted);
}

/* Two-column question lists */
.topic-detail__columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 640px) {
  .topic-detail__columns { grid-template-columns: 1fr; }
}

.topic-detail__col-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  margin-bottom: 0.75rem;
}

.topic-detail__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Individual question card */
.topic-q-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.topic-q-card:hover {
  border-color: var(--clr-border-strong);
  background: var(--clr-surface-alt);
}

.topic-q-card__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.topic-q-card__id {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--clr-text);
}

.topic-q-card__badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.topic-q-card__badge.status-completed { background: var(--clr-success-bg); color: var(--clr-success); }
.topic-q-card__badge.status-attempted { background: var(--clr-warning-bg); color: var(--clr-warning); }
.topic-q-card__badge.status-none      { background: var(--clr-surface-alt); color: var(--clr-text-xmuted); border: 1px solid var(--clr-border); }

.topic-q-card__meta {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  margin-top: 2px;
}

.topic-q-card__notes {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  font-style: italic;
  margin-top: 6px;
  line-height: 1.4;

  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}




/* =============================================================================
   27. DASHBOARD — DAY SCREEN
   ============================================================================= */
.day-screen {
  padding: 2rem;
  max-width: 1280px;
  margin: 0 auto;
}

.day-screen__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--clr-border);
}

.day-attempts {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.question-block {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  padding: 1.25rem;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
}

.question-block .question-content { flex-shrink: 0; max-width: 360px; }
.question-block .question-content img { margin: 0; }

.attempts-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* =============================================================================
   WEAK TOPICS
   ============================================================================= */

.weak-topics-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-top: 0.25rem;
}

.weak-topic-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.weak-topic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.weak-topic-tag {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--clr-text);
}

.weak-topic-stars {
  font-size: 0.8rem;
  letter-spacing: 1px;
}

.weak-topic-stars.severity-high  { color: var(--clr-danger); }
.weak-topic-stars.severity-mid   { color: var(--clr-warning); }
.weak-topic-stars.severity-low   { color: var(--clr-success); }

.weak-topic-bar-track {
  height: 5px;
  background: var(--clr-border);
  border-radius: 999px;
  overflow: hidden;
}

.weak-topic-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 400ms var(--ease);
}

.weak-topic-bar.severity-high { background: var(--clr-danger); }
.weak-topic-bar.severity-mid  { background: var(--clr-warning); }
.weak-topic-bar.severity-low  { background: var(--clr-success); }

.weak-topic-meta {
  font-size: 0.72rem;
  color: var(--clr-text-xmuted);
}

/* =============================================================================
   TOPIC TREE
   ============================================================================= */

.topic-tree {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 0.25rem;
}

/* Topic node (one per tag) */
.topic-node {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.topic-node__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--clr-surface-alt);
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.topic-node__header:hover { background: var(--clr-accent-soft); }

.topic-node__title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.topic-node__tag {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--clr-text);
  white-space: nowrap;
}

.topic-node__counts {
  display: flex;
  gap: 0.5rem;
  font-size: 0.72rem;
  flex-wrap: wrap;
}

.count-completed { color: var(--clr-success); font-weight: 600; }
.count-attempted { color: var(--clr-warning); }
.count-total     { color: var(--clr-text-xmuted); }

.topic-node__progress {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 120px;
  flex-shrink: 0;
}

.topic-node__bar-track {
  flex: 1;
  height: 4px;
  background: var(--clr-border);
  border-radius: 999px;
  overflow: hidden;
}

.topic-node__bar {
  height: 100%;
  background: var(--clr-success);
  border-radius: 999px;
  transition: width 400ms var(--ease);
}

.topic-node__pct {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--clr-text-muted);
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.topic-node__chevron {
  font-size: 1.1rem;
  color: var(--clr-text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.topic-node__chevron.open { transform: rotate(90deg); }

/* Question list inside a node */
.topic-node__questions {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  gap: 2px;
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
}

.topic-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.topic-question:hover { background: var(--clr-accent-soft); }

.topic-question__id {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text);
}

.topic-question__status {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
}

.topic-question.status-completed .topic-question__status {
  background: var(--clr-success-bg);
  color: var(--clr-success);
}

.topic-question.status-attempted .topic-question__status {
  background: var(--clr-warning-bg);
  color: var(--clr-warning);
}

.topic-question.status-none .topic-question__status {
  background: var(--clr-surface-alt);
  color: var(--clr-text-xmuted);
}

/* =============================================================================
   SHARED DASHBOARD UTILITY
   ============================================================================= */

.dashboard-empty {
  font-size: 0.85rem;
  color: var(--clr-text-xmuted);
  font-style: italic;
  padding: 0.5rem 0;
}


/* =============================================================================
   28. ANIMATIONS
   ============================================================================= */
@keyframes dropdown-appear {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

@keyframes modal-appear {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: none; }
}

@keyframes pulse-success {
  from { box-shadow: 0 0 0 0 rgba(26, 107, 69, 0.4); }
  to   { box-shadow: 0 0 0 8px rgba(26, 107, 69, 0); }
}


/* =============================================================================
   29. UTILITIES
   ============================================================================= */
.hidden { display: none !important; }


/* =============================================================================
   30. RESPONSIVE
   ============================================================================= */
@media (max-width: 1024px) {
  .dashboard-stats  { grid-template-columns: repeat(2, 1fr); }
  .dashboard-split  { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .question-layout {
    grid-template-columns: 1fr;
  }

  .question-sidebar {
    order: -1;
  }
}

@media (max-width: 600px) {
  .app-layout {
    grid-template-areas:
      "topbar"
      "viewer";
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
  }

  .sidebar { display: none; }

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

  .dashboard-layout { padding: 1.5rem 1rem; }
}