:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-card: #1c2128;
  --bg-code: #0d1117;
  --border: #30363d;
  --border-light: #3d444d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --text-article: #c9d1d9;
  --text-on-accent: #ffffff;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --green: #3fb950;
  --green-dim: #1a4731;
  --yellow: #d29922;
  --yellow-dim: #4b3a12;
  --red: #f85149;
  --red-dim: #4b1d1d;
  --orange: #db6d28;
  --purple: #bc8cff;
  --overlay-strong: rgba(0, 0, 0, 0.5);
  --overlay-soft: rgba(0, 0, 0, 0.2);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-read: 'IBM Plex Sans', 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  color-scheme: dark;
}

/* Light theme: override the variables only, keep the rest of the stylesheet unchanged. */
:root[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --bg-card: #ffffff;
  --bg-code: #f6f8fa;
  --border: #d0d7de;
  --border-light: #afb8c1;
  --text-primary: #1f2328;
  --text-secondary: #59636e;
  --text-muted: #818b98;
  --text-article: #24292f;
  --text-on-accent: #ffffff;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --accent-soft: rgba(9, 105, 218, 0.10);
  --green: #1a7f37;
  --green-dim: #dafbe1;
  --yellow: #9a6700;
  --yellow-dim: #fff8c5;
  --red: #cf222e;
  --red-dim: #ffebe9;
  --orange: #bc4c00;
  --purple: #8250df;
  --overlay-strong: rgba(0, 0, 0, 0.35);
  --overlay-soft: rgba(0, 0, 0, 0.08);
  --shadow: 0 2px 8px rgba(140, 149, 159, 0.2);
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
#sidebar {
  width: 248px;
  background:
    radial-gradient(120% 60% at 0% 0%, var(--accent-soft) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-secondary) 70%, var(--bg-primary) 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  box-shadow: 1px 0 0 0 var(--overlay-soft);
  overflow: hidden;
}

/* ── Sidebar SVG graphics ──
   Shared gradients live in .cf-defs (index.html); stops are styled here
   so every gradient follows the active theme. */
.cf-defs { position: absolute; }
.cf-stop-a { stop-color: var(--accent); }
.cf-stop-b { stop-color: var(--purple); }
.cf-stop-ember-a { stop-color: var(--yellow); }
.cf-stop-ember-b { stop-color: var(--red); }
.cf-stop-ember-c { stop-color: var(--purple); }

/* Circuit traces drifting behind the brand area */
.sidebar-traces {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 380px;
  pointer-events: none;
  opacity: 0.5;
}
.sidebar-traces path {
  fill: none;
  stroke: url(#cfGradAccent);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 3 9;
  opacity: 0.38;
  animation: trace-drift 40s linear infinite;
}
.sidebar-traces path:nth-child(2) { animation-duration: 55s; animation-direction: reverse; opacity: 0.28; }
.sidebar-traces path:nth-child(3) { animation-duration: 70s; opacity: 0.2; }
.sidebar-traces circle {
  fill: var(--accent);
  opacity: 0.25;
  animation: trace-node-pulse 4s ease-in-out infinite;
}
.sidebar-traces circle:nth-of-type(2) { animation-delay: 1.3s; }
.sidebar-traces circle:nth-of-type(3) { animation-delay: 2.6s; }
@keyframes trace-drift {
  to { stroke-dashoffset: -600; }
}
@keyframes trace-node-pulse {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.5; }
}

.sidebar-scroll {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.sidebar-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Brand */
.sidebar-brand {
  padding: 2px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

/* Official wordmark. Two PNGs: light text for the dark theme (default) and a
   dark-text variant for the light theme. The theme attribute picks one; the
   other stays out of layout. The source file is 298x69, so height alone sets
   the size and width follows from the aspect ratio. */
.brand-logo {
  display: block;
  height: 34px;
  width: auto;
  user-select: none;
  -webkit-user-drag: none;
}
.brand-logo-light { display: none; }
:root[data-theme="light"] .brand-logo-dark { display: none; }
:root[data-theme="light"] .brand-logo-light { display: block; }

.logo-tagline {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  /* Lines up under the wordmark text, just right of the chevron mark. */
  padding-left: 36px;
}

/* User badge */
.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.user-badge:hover { border-color: var(--border-light); }

.user-avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.user-avatar-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.user-avatar-track { stroke: var(--border); }
.user-avatar-progress {
  stroke: var(--accent);
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s;
}
.user-avatar-progress.is-low { stroke: var(--yellow); }
.user-avatar-progress.is-mid { stroke: var(--accent); }
.user-avatar-progress.is-high { stroke: var(--green); }

.user-avatar {
  position: absolute;
  inset: 4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.user-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-rank {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

.user-logout {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 6px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.user-logout svg { width: 15px; height: 15px; }
.user-logout:hover {
  color: var(--red);
  background: var(--bg-tertiary);
}

/* Nav sections */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 4px 12px 6px;
}
.nav-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border) 0%, transparent 95%);
}

.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  text-align: left;
}

.nav-btn::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--accent), var(--purple));
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-soft), 0 0 14px var(--accent-soft);
  transition: transform 0.18s ease;
}

.nav-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-btn.active::before { transform: translateY(-50%) scaleY(1); }

.nav-label { flex: 1; }

svg.nav-icon {
  width: 17px;
  height: 17px;
  min-width: 17px;
  stroke: currentColor;
  opacity: 0.75;
  transition: opacity 0.15s, transform 0.15s;
}

.nav-btn:hover svg.nav-icon { opacity: 1; }
.nav-btn.active svg.nav-icon {
  opacity: 1;
  transform: scale(1.05);
  stroke: url(#cfGradAccent);
  filter: drop-shadow(0 0 5px var(--accent-soft));
}

/* Icons redraw themselves on hover (shapes are pathLength-normalized
   to 100 by sidebar-fx.js) */
@media (prefers-reduced-motion: no-preference) {
  .nav-btn:hover svg.nav-icon :is(path, polyline, line, circle, rect) {
    stroke-dasharray: 100;
    animation: nav-icon-draw 0.6s ease-out forwards;
  }
}
@keyframes nav-icon-draw {
  from { stroke-dashoffset: 100; }
  to { stroke-dashoffset: 0; }
}

/* Stats card */
.sidebar-stats {
  margin-top: 4px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 0;
}

.sidebar-stats-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.sidebar-stats-meta {
  font-size: 10px;
  font-weight: 500;
  color: var(--green);
  padding: 2px 6px;
  background: var(--green-dim);
  border-radius: 4px;
  letter-spacing: 0.2px;
}
.sidebar-stats-meta.is-warn {
  color: var(--yellow);
  background: var(--yellow-dim);
}
.sidebar-stats-meta.is-quiet {
  color: var(--text-muted);
  background: var(--bg-tertiary);
}

/* Molten seam under the "Today's forge" header */
.forge-emberline {
  width: 100%;
  height: 10px;
  margin: -2px 0;
  display: block;
}
.forge-emberline path {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.emberline-base {
  stroke: var(--border);
  opacity: 0.8;
}
.emberline-glow {
  stroke: url(#cfGradEmber);
  stroke-dasharray: 26 74;
  animation: ember-flow 5s linear infinite;
  filter: drop-shadow(0 0 3px var(--yellow));
}
@keyframes ember-flow {
  from { stroke-dashoffset: 100; }
  to { stroke-dashoffset: -100; }
}
@media (prefers-reduced-motion: reduce) {
  .emberline-glow,
  .sidebar-traces path,
  .sidebar-traces circle { animation: none; }
}

.sidebar-stats-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mini-stat {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
  transition: background 0.15s;
}
.mini-stat:hover { background: var(--bg-tertiary); }

.mini-stat-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.mini-stat-icon svg {
  width: 16px;
  height: 16px;
}
.mini-stat-icon-streak {
  color: var(--orange);
}

.mini-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.1px;
  text-transform: none;
}

.mini-stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.mini-stat-mastery .mini-stat-icon { color: var(--accent); }
.mini-stat-mastery .mini-stat-value { color: var(--accent); }

.mastery-ring { width: 22px; height: 22px; }
.mastery-ring-track { stroke: var(--border); }
.mastery-ring-progress {
  stroke: currentColor;
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s;
}

/* Footer */
.sidebar-footer {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent 0%, var(--overlay-soft) 100%);
}

.language-select {
  margin: 0;
}

.language-select label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  margin-bottom: 6px;
  padding-left: 2px;
}

.language-select-control {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
  padding-left: 10px;
}
.language-select-control:hover {
  border-color: var(--border-light);
}
.language-select-control:focus-within {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.language-select-flag {
  font-size: 14px;
  color: var(--accent);
  pointer-events: none;
  display: inline-flex;
  align-items: center;
}
.language-select-flag svg {
  width: 14px;
  height: 14px;
  filter: drop-shadow(0 0 4px var(--accent-soft));
}

.language-select select {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 28px 8px 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.language-select select:focus { outline: none; }

.language-select-chevron {
  position: absolute;
  right: 10px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Compact mode for short viewports — hide tagline. */
@media (max-height: 720px) {
  .logo-tagline { display: none; }
  .sidebar-scroll { gap: 12px; padding-top: 14px; }
}

/* MAIN CONTENT */
#mainContent {
  flex: 1;
  margin-left: 240px;
  padding: 32px 40px;
}

.view { display: none; }
.view.active { display: block; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

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

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

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }

/* EMPTY STATE */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 16px;
}

.empty-icon { font-size: 64px; opacity: 0.6; }
.empty-state h2 { font-size: 24px; font-weight: 600; }
.empty-state p { color: var(--text-secondary); max-width: 400px; }

/* Train CTA */
.train-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

/* ═══════════════════════════════════════════════
   ZIG KNOWLEDGE CAROUSEL
   ═══════════════════════════════════════════════ */

.carousel-wrapper {
  width: 100%;
  max-width: 860px;
  margin: 0 auto 24px;
  text-align: left;
}

.carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.carousel-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #e95420;
  background: rgba(233, 84, 32, 0.1);
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid rgba(233, 84, 32, 0.2);
}

.carousel-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.carousel-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.carousel-arrow:hover {
  background: #e95420;
  color: white;
  border-color: #e95420;
  transform: scale(1.08);
}

.carousel-counter {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Ubuntu Mono', monospace;
  min-width: 50px;
  text-align: center;
}

.carousel-track-container {
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.carousel-track {
  display: flex;
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.carousel-slide {
  min-width: 100%;
  box-sizing: border-box;
  padding: 28px 32px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.carousel-slide::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #e95420, #f5a623, #4ab648);
}

.slide-category {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
}
.slide-category.pointer { background: rgba(233, 84, 32, 0.15); color: #e95420; }
.slide-category.mutability { background: rgba(74, 182, 72, 0.15); color: #4ab648; }
.slide-category.comptime { background: rgba(86, 182, 194, 0.15); color: #56b6c2; }
.slide-category.memory { background: rgba(245, 166, 35, 0.15); color: #f5a623; }
.slide-category.error { background: rgba(248, 81, 73, 0.15); color: #f85149; }
.slide-category.types { background: rgba(119, 189, 251, 0.15); color: #77bdfb; }
.slide-category.control { background: rgba(229, 192, 123, 0.15); color: #e5c07b; }
.slide-category.defer { background: rgba(198, 120, 221, 0.15); color: #c678dd; }

.slide-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.3;
  color: var(--text-primary);
}

.slide-teacher {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.slide-teacher-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: rgba(233, 84, 32, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide-teacher-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.slide-code {
  background: #300a24;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-family: 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #eeeeec;
  overflow-x: auto;
  margin-top: 12px;
  white-space: pre;
}
.slide-code .kw { color: #e95420; }
.slide-code .str { color: #4ab648; }
.slide-code .typ { color: #56b6c2; }
.slide-code .cmt { color: #6a9955; font-style: italic; }
.slide-code .num { color: #e5c07b; }
.slide-code .fn { color: #77bdfb; }

.slide-gotcha {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.2);
  border-radius: var(--radius);
  font-size: 13px;
  color: #f5a623;
  line-height: 1.5;
}
.slide-gotcha-icon { flex-shrink: 0; font-size: 16px; }

/* Dots */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}
.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all 0.25s;
}
.carousel-dot.active {
  background: #e95420;
  width: 24px;
  border-radius: 4px;
}

/* Auto-play progress */
.carousel-wrapper:hover .carousel-slide {
  border-color: rgba(233, 84, 32, 0.15);
}

/* CARD */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

/* PHASE HEADER */
.phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-skip {
  margin-left: auto;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #58a6ff;
  background: rgba(88,166,255,0.08);
  border: 1px solid rgba(88,166,255,0.25);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-skip:hover {
  background: rgba(88,166,255,0.15);
  border-color: rgba(88,166,255,0.5);
}

.btn-skip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--purple);
  color: #fff;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.phase-badge.coding { background: var(--accent); }
.phase-badge.review { background: var(--green); }

/* Gap-fill banner */
.gap-fill-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(86, 182, 194, 0.08), rgba(74, 182, 72, 0.08));
  border: 1px solid rgba(86, 182, 194, 0.25);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  animation: gapFillSlide 0.4s ease;
}
.gap-fill-icon {
  font-size: 28px;
  flex-shrink: 0;
  margin-top: 2px;
}
.gap-fill-content strong {
  color: #56b6c2;
  font-size: 14px;
  display: block;
  margin-bottom: 4px;
}
.gap-fill-content p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}
@keyframes gapFillSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.challenge-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-concept {
  font-weight: 500;
  color: var(--text-secondary);
}

.meta-diff {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

/* MENTAL MODEL */
.mental-model-card h3 {
  font-family: var(--font-read);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--accent);
  letter-spacing: -0.3px;
}

/* PREVIOUS ATTEMPTS MARKER */
.prev-attempts {
  margin-bottom: 16px;
}

.prev-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  flex-wrap: wrap;
}

.prev-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.prev-grade {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}

.prev-grade-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.prev-detail {
  color: var(--text-secondary);
  font-size: 12px;
}

.prev-streak {
  color: var(--green);
  font-weight: 600;
  font-size: 11px;
  padding: 1px 7px;
  background: rgba(63, 185, 80, 0.1);
  border-radius: 4px;
}

.prev-date {
  color: var(--text-muted);
  font-size: 11px;
}

.prev-best {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 14px;
}

.mental-model-question {
  font-family: var(--font-read);
  font-size: 15px;
  line-height: 1.75;
  color: #c9d1d9;
  margin-bottom: 24px;
  padding: 20px 24px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  border-left: 3px solid var(--purple);
}

.mental-model-question .prompt-p {
  margin-bottom: 8px;
  color: #c9d1d9;
}

.mental-model-question .prompt-inline-code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(110, 118, 129, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.bridge-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 24px;
}

.bridge-from, .bridge-to {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}

.bridge-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.bridge-from { border-top: 2px solid var(--yellow); }
.bridge-from .bridge-label { color: var(--yellow); }
.bridge-to { border-top: 2px solid var(--green); }
.bridge-to .bridge-label { color: var(--green); }
.bridge-from p, .bridge-to p { font-family: var(--font-read); font-size: 13px; color: #b1bac4; line-height: 1.65; }
.bridge-arrow {
  font-size: 24px;
  color: var(--text-muted);
  align-self: center;
  padding-top: 20px;
}

/* CODING LAYOUT */
.coding-layout {
  display: grid;
  grid-template-columns: 1fr var(--editor-width, 1fr);
  gap: 20px;
  min-height: 500px;
}

.prompt-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: calc(100vh - 160px);
  padding-right: 8px;
}

.prompt-panel::-webkit-scrollbar { width: 5px; }
.prompt-panel::-webkit-scrollbar-track { background: transparent; }
.prompt-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.prompt-panel h3 {
  font-family: var(--font-read);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 20px;
  color: var(--text-primary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.prompt-text {
  font-family: var(--font-read);
  font-size: 14.5px;
  line-height: 1.7;
  color: #b1bac4;
}

.prompt-text .prompt-p {
  margin-bottom: 14px;
  color: #b1bac4;
}

.prompt-text .prompt-p:last-child { margin-bottom: 0; }

.prompt-text .prompt-inline-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.15);
  padding: 1.5px 6px;
  border-radius: 4px;
  color: #79c0ff;
  word-break: break-word;
}

.prompt-text .prompt-ol {
  margin: 6px 0 18px 0;
  padding-left: 0;
  counter-reset: prompt-step;
  list-style: none;
}

.prompt-text .prompt-li {
  counter-increment: prompt-step;
  position: relative;
  padding: 8px 12px 8px 40px;
  margin-bottom: 4px;
  background: rgba(33, 38, 45, 0.6);
  border-radius: 6px;
  border-left: 2px solid var(--border);
  font-size: 13.5px;
  line-height: 1.65;
  color: #c9d1d9;
  transition: border-color 0.15s;
}

.prompt-text .prompt-li:hover {
  border-left-color: var(--accent);
}

.prompt-text .prompt-li::before {
  content: counter(prompt-step);
  position: absolute;
  left: 12px;
  top: 8px;
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: #0d1117;
  font-size: 11px;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
}

.prompt-text .prompt-objective {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 0 18px 0;
  padding: 12px 16px;
  background: rgba(63, 185, 80, 0.06);
  border: 1px solid rgba(63, 185, 80, 0.15);
  border-radius: 8px;
}

.prompt-text .prompt-objective-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--green);
  background: rgba(63, 185, 80, 0.12);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.prompt-text .prompt-objective-text {
  font-size: 13.5px;
  color: #c9d1d9;
  line-height: 1.6;
}

.prompt-text .prompt-expected {
  margin-top: 20px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(210, 153, 34, 0.2);
}

.prompt-text .prompt-expected-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--yellow);
  padding: 8px 14px;
  background: rgba(210, 153, 34, 0.08);
  border-bottom: 1px solid rgba(210, 153, 34, 0.15);
}

.prompt-text .prompt-expected-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  padding: 12px 16px;
  color: #d2a641;
  background: rgba(210, 153, 34, 0.04);
  margin: 0;
  white-space: pre;
  overflow-x: auto;
}

.hints-section { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

.hints-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.hint-item {
  padding: 10px 14px;
  background: var(--yellow-dim);
  border: 1px solid rgba(210, 153, 34, 0.3);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--yellow);
  animation: fadeIn 0.3s ease;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.tag {
  padding: 3px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   UBUNTU TERMINAL EDITOR
   ═══════════════════════════════════════════════ */

.editor-panel.ubuntu-terminal {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: none;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  position: relative;
}

/* Title bar — Ubuntu Yaru dark */
.ubuntu-titlebar {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  background: linear-gradient(180deg, #3c3c3c 0%, #2d2d2d 100%);
  border-bottom: 1px solid #1a1a1a;
  user-select: none;
  flex-shrink: 0;
}

.ubuntu-window-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ubuntu-btn-close,
.ubuntu-btn-minimize,
.ubuntu-btn-maximize {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  position: relative;
}

.ubuntu-btn-close { background: #e95420; }
.ubuntu-btn-minimize { background: #f5a623; }
.ubuntu-btn-maximize { background: #4ab648; }

.ubuntu-btn-close:hover,
.ubuntu-btn-minimize:hover,
.ubuntu-btn-maximize:hover {
  opacity: 0.85;
  transform: scale(1.15);
}

.ubuntu-btn-close:active,
.ubuntu-btn-minimize:active,
.ubuntu-btn-maximize:active {
  transform: scale(0.9);
}

/* X icon on close */
.ubuntu-btn-close::before,
.ubuntu-btn-close::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 1.5px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.15s;
}
.ubuntu-btn-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.ubuntu-btn-close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.ubuntu-btn-close:hover::before,
.ubuntu-btn-close:hover::after { opacity: 1; }

/* Maximize arrows */
.ubuntu-btn-maximize::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border: 1.5px solid rgba(0, 0, 0, 0.5);
  border-radius: 1px;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s;
}
.ubuntu-btn-maximize:hover::before { opacity: 1; }

/* Minimize dash */
.ubuntu-btn-minimize::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 1.5px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 1px;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s;
}
.ubuntu-btn-minimize:hover::before { opacity: 1; }

.ubuntu-title {
  flex: 1;
  text-align: center;
  font-family: 'Ubuntu Mono', 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: #ddd;
  letter-spacing: 0.3px;
}

.ubuntu-titlebar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ubuntu-size-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #aaa;
  font-family: 'Ubuntu Mono', monospace;
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
  outline: none;
}

.ubuntu-size-select:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ddd;
}

.ubuntu-size-select option {
  background: #2d2d2d;
  color: #ddd;
}

/* Editor area — explicit height so it can shrink and grow */
.code-editor {
  height: 400px;
  min-height: 150px;
  flex-shrink: 0;
}

/* Vertical resize handle (bottom edge) */
.ubuntu-resize-v {
  height: 6px;
  background: linear-gradient(180deg, #2d2d2d, #252525);
  cursor: ns-resize;
  position: relative;
  flex-shrink: 0;
}

.ubuntu-resize-v::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.ubuntu-resize-v:hover {
  background: linear-gradient(180deg, #3a3a3a, #2d2d2d);
}

.ubuntu-resize-v:hover::after {
  border-color: rgba(233, 84, 32, 0.5);
}

/* Horizontal resize handle (left edge) */
.ubuntu-resize-handle-h {
  position: absolute;
  left: -4px;
  top: 36px;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  z-index: 10;
}

.ubuntu-resize-handle-h::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 32px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.15s;
}

.ubuntu-resize-handle-h:hover::after {
  opacity: 1;
  border-color: rgba(233, 84, 32, 0.5);
}

/* Corner resize handle (bottom-left) */
.ubuntu-resize-handle-corner {
  position: absolute;
  left: -4px;
  bottom: -4px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
  z-index: 11;
}

.ubuntu-resize-handle-corner::after {
  content: '';
  position: absolute;
  right: 2px;
  top: 2px;
  width: 8px;
  height: 8px;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  transition: opacity 0.15s;
}

.ubuntu-resize-handle-corner:hover::after {
  opacity: 1;
  border-color: rgba(233, 84, 32, 0.5);
}

/* Status bar */
.ubuntu-statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 14px;
  background: #2d2d2d;
  border-top: 1px solid #1a1a1a;
  font-family: 'Ubuntu Mono', monospace;
  font-size: 11px;
  color: #777;
  flex-shrink: 0;
}

.ubuntu-status-left,
.ubuntu-status-right {
  letter-spacing: 0.3px;
}

/* Editor action buttons */
.editor-actions {
  display: flex;
  gap: 0;
  border-top: 1px solid #1a1a1a;
}

.editor-actions .btn-run {
  flex: 0 0 auto;
  padding: 10px 20px;
  background: linear-gradient(135deg, #4ab648, #2d8a2b);
  color: white;
  border: none;
  border-right: 1px solid #1a1a1a;
  border-radius: 0;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.editor-actions .btn-run:hover {
  background: linear-gradient(135deg, #5cc85a, #3a9d38);
}
.editor-actions .btn-run:disabled {
  opacity: 0.5;
  cursor: wait;
}
.editor-actions .btn-explain {
  flex: 0 0 auto;
  padding: 10px 16px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  border: none;
  border-right: 1px solid #1a1a1a;
  border-radius: 0;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.editor-actions .btn-explain:hover {
  background: linear-gradient(135deg, #818cf8, #6366f1);
}
.editor-actions .btn-explain:disabled {
  opacity: 0.5;
  cursor: wait;
}

.editor-actions .btn-submit {
  flex: 1;
  border-radius: 0 0 10px 0;
  border: none;
}
.editor-actions .btn-run {
  border-radius: 0 0 0 10px;
}

/* Explain panel */
.explain-panel {
  border-top: 1px solid #1a1a1a;
  background: #110d1a;
  max-height: 350px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.explain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1a1228;
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.explain-title {
  font-size: 12px;
  font-weight: 700;
  color: #a5b4fc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.explain-content {
  padding: 0;
}

.explain-line {
  display: grid;
  grid-template-columns: 40px 1fr;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

.explain-line:hover {
  background: rgba(99, 102, 241, 0.06);
}

.explain-line-num {
  padding: 8px 10px;
  font-family: 'Ubuntu Mono', monospace;
  font-size: 12px;
  color: #666;
  text-align: right;
  background: rgba(0, 0, 0, 0.15);
  user-select: none;
}

.explain-line-body {
  padding: 8px 12px;
}

.explain-line-code {
  font-family: 'Ubuntu Mono', monospace;
  font-size: 13px;
  color: #c9d1d9;
  white-space: pre;
  margin-bottom: 4px;
}

.explain-line-text {
  font-size: 12px;
  color: #a5b4fc;
  line-height: 1.5;
}

.explain-line.blank .explain-line-code {
  color: #444;
}

.explain-unavailable {
  padding: 20px;
  text-align: center;
  color: #888;
  font-size: 13px;
}

/* ── Code Visualizer panel ── */

.btn-visualize {
  border: 1px solid var(--purple);
  color: var(--purple);
  background: transparent;
}

.btn-visualize:hover {
  background: rgba(188, 140, 255, 0.10);
}

.viz-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.viz-panel.viz-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-top: none;
  border-radius: 0;
  min-height: 0;
  box-shadow: 0 0 0 9999px var(--overlay-strong, rgba(0, 0, 0, 0.5));
}

.viz-panel.viz-fullscreen .viz-body {
  flex: 1;
  min-height: 0;
}

.viz-panel.viz-fullscreen .viz-info {
  max-height: none;
}

/* Hide page scrolling while the visualizer is fullscreen. */
body.viz-fullscreen-active {
  overflow: hidden;
}

.viz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.viz-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.viz-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.viz-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.viz-header-actions {
  display: flex;
  gap: 6px;
}

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.vz-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.vz-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.viz-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  flex: 1;
  min-height: 380px;
}

.viz-canvas-wrap {
  position: relative;
  overflow: hidden;
  background: var(--bg-code);
}

.viz-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 380px;
}

.viz-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

.viz-empty strong {
  font-size: 14px;
  color: var(--text-secondary);
}

.viz-empty p {
  font-size: 12px;
  max-width: 280px;
  line-height: 1.55;
}

.viz-info {
  border-left: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 14px;
  overflow-y: auto;
  font-size: 12.5px;
  max-height: 440px;
}

.vz-info-empty {
  color: var(--text-muted);
}

.vz-info-empty strong {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 6px;
}

.vz-info-empty p {
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
}

.vz-info-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.vz-info-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #0d1117;
  font-size: 16px;
  flex-shrink: 0;
}

.vz-info-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  word-break: break-word;
}

.vz-info-kind {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}

.vz-info-detail {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 12px 0;
}

.vz-info-row-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 10px 0 4px 0;
}

.vz-info-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vz-info-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.vz-info-bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vz-info-edge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: lowercase;
  opacity: 0.85;
  min-width: 56px;
}

.vz-info-name {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: 11.5px;
  word-break: break-word;
}

@media (max-width: 900px) {
  .viz-body { grid-template-columns: 1fr; }
  .viz-info {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 240px;
  }
}

/* Run output panel */
.run-output-panel {
  border-top: 1px solid #1a1a1a;
  background: #1a0e16;
  max-height: 200px;
  display: flex;
  flex-direction: column;
}

.run-output-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #2d2d2d;
  border-bottom: 1px solid #1a1a1a;
  flex-shrink: 0;
}

.run-output-title {
  font-family: 'Ubuntu Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.run-output-status {
  font-size: 11px;
  font-family: 'Ubuntu Mono', monospace;
  margin-left: auto;
}
.run-output-status.success { color: #4ab648; }
.run-output-status.error { color: #f85149; }
.run-output-status.blocked { color: #f5a623; }
.run-output-status.running { color: #56b6c2; }

.run-output-content {
  padding: 10px 14px;
  font-family: 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #eeeeec;
  overflow: auto;
  flex: 1;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.run-output-content .run-error { color: #f85149; }
.run-output-content .run-warn { color: #f5a623; }

/* Fullscreen mode */
.editor-panel.ubuntu-terminal.fullscreen {
  position: fixed;
  top: 20px;
  left: 260px;
  right: 20px;
  bottom: 80px;
  z-index: 100;
  border-radius: 10px;
}

.editor-panel.ubuntu-terminal.fullscreen .code-editor {
  height: auto;
  min-height: 0;
  flex: 1;
}

.editor-panel.ubuntu-terminal.fullscreen .ubuntu-submit {
  position: fixed;
  bottom: 20px;
  left: 260px;
  right: 20px;
  border-radius: var(--radius);
  z-index: 101;
}

/* TIMER */
.timer-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.3s ease;
}

.timer.timer-paused {
  opacity: 0.45;
  animation: timerBlink 1.2s ease-in-out infinite;
}

@keyframes timerBlink {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.15; }
}

.btn-timer-pause {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.btn-timer-pause:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.btn-timer-pause.paused {
  color: #7ee787;
  border-color: rgba(126, 231, 135, 0.3);
  background: rgba(126, 231, 135, 0.08);
}

.btn-timer-pause.paused:hover {
  background: rgba(126, 231, 135, 0.15);
  border-color: rgba(126, 231, 135, 0.5);
}

.btn-timer-pause .pause-icon {
  font-size: 10px;
  letter-spacing: -2px;
}

/* REVIEW LAYOUT */
.review-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.review-column h4 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-block {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-secondary);
  max-height: 400px;
  overflow-y: auto;
}

.code-block.reference {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
}

/* RATING */
.rating-section {
  text-align: center;
}

.rating-section h4 {
  font-size: 18px;
  margin-bottom: 4px;
}

.rating-instruction {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.rating-btn:hover { border-color: var(--accent); transform: translateY(-2px); }

.rating-btn[data-quality="0"]:hover,
.rating-btn[data-quality="1"]:hover { border-color: var(--red); }
.rating-btn[data-quality="2"]:hover { border-color: var(--orange); }
.rating-btn[data-quality="3"]:hover { border-color: var(--yellow); }
.rating-btn[data-quality="4"]:hover,
.rating-btn[data-quality="5"]:hover { border-color: var(--green); }

.rating-num {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.rating-desc {
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-muted);
}

/* RESULT */
.result-card {
  max-width: 480px;
  margin: 60px auto;
  text-align: center;
}

.result-icon { font-size: 48px; margin-bottom: 16px; }
.result-card h3 { font-size: 22px; margin-bottom: 8px; }
.result-card p { color: var(--text-secondary); margin-bottom: 24px; }

.result-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 28px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}

.result-stat { text-align: center; }
.result-stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.result-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
}

.result-mastered-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  margin: 0 0 20px 0;
  background: linear-gradient(135deg, rgba(63, 185, 80, 0.15), rgba(88, 166, 255, 0.10));
  border: 1px solid rgba(63, 185, 80, 0.4);
  border-radius: var(--radius);
  text-align: left;
}

.result-mastered-icon {
  font-size: 28px;
  color: var(--green);
  line-height: 1;
  flex-shrink: 0;
}

.result-mastered-banner strong {
  display: block;
  color: var(--green);
  font-size: 14px;
  margin-bottom: 4px;
  letter-spacing: 0.2px;
}

.result-mastered-banner p {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}

/* CONCEPT MAP */
.view-subtitle {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

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

.concept-node {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s;
  cursor: default;
}

.concept-node:hover { border-color: var(--border-light); }

.concept-node.locked {
  opacity: 0.5;
  border-style: dashed;
}

.concept-node-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.concept-node-name {
  font-size: 15px;
  font-weight: 600;
}

.concept-node-mastery {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.concept-node-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.concept-progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.concept-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.concept-node-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.concept-prereqs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.prereq-tag {
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  font-size: 10px;
  color: var(--text-muted);
}

.prereq-tag.met { color: var(--green); border: 1px solid var(--green-dim); }

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

.stat-card-value {
  font-size: 36px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.recent-reviews {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.review-quality {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 14px;
}

.review-quality.q-low { background: var(--red-dim); color: var(--red); }
.review-quality.q-mid { background: var(--yellow-dim); color: var(--yellow); }
.review-quality.q-high { background: var(--green-dim); color: var(--green); }

.review-info { flex: 1; }
.review-title { font-size: 14px; font-weight: 500; }
.review-date { font-size: 12px; color: var(--text-muted); }

/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.phase { animation: fadeIn 0.3s ease; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* AUTH SCREEN */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 36px;
}

.auth-logo-title {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.auth-logo-title .brand-logo { height: 56px; }
.auth-logo h1 { font-size: 32px; font-weight: 700; letter-spacing: -1px; margin-bottom: 6px; }
.auth-logo h1.auth-logo-title { margin-bottom: 14px; }
.auth-tagline { color: var(--text-muted); font-size: 14px; }

.auth-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.auth-form h2 { font-size: 20px; margin-bottom: 24px; text-align: center; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input::placeholder { color: var(--text-muted); }

.form-error {
  padding: 10px 14px;
  background: var(--red-dim);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 13px;
  margin-bottom: 16px;
}

.form-error a { color: var(--red); text-decoration: underline; }

/* Neutral counterpart to .form-error, for "check your email" style messages
   that are an expected outcome rather than a failure. */
.form-notice {
  padding: 10px 14px;
  background: var(--accent-dim, rgba(245, 166, 35, 0.12));
  border: 1px solid rgba(245, 166, 35, 0.35);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.form-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted, #8b949e);
}

/* ── Locked / coming-soon feature ── */

.nav-soon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid rgba(245, 166, 35, 0.4);
  border-radius: 999px;
  background: rgba(245, 166, 35, 0.12);
  color: var(--accent, #f5a623);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.nav-soon svg { width: 10px; height: 10px; }

/* Still clickable — it opens the explanatory panel rather than doing nothing. */
.nav-btn-locked .nav-label { opacity: 0.6; }
.nav-btn-locked .nav-icon { opacity: 0.5; }

.practice-soon-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 320px;
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--border, #30363d);
  border-radius: var(--radius-lg, 12px);
  background: var(--bg-elevated, rgba(255, 255, 255, 0.02));
}

.practice-soon-icon {
  width: 44px;
  height: 44px;
  color: var(--accent, #f5a623);
  opacity: 0.85;
}

.practice-soon-panel h2 { margin: 0; font-size: 20px; }

.practice-soon-panel p {
  margin: 0;
  max-width: 46ch;
  color: var(--text-muted, #8b949e);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Activation result banner ── */

.activation-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 12px 20px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

.activation-banner.ok {
  background: rgba(63, 185, 80, 0.15);
  border-bottom: 1px solid rgba(63, 185, 80, 0.4);
  color: var(--green, #3fb950);
}

.activation-banner.err {
  background: var(--red-dim);
  border-bottom: 1px solid rgba(248, 81, 73, 0.4);
  color: var(--red);
}

/* Lead-in under a form heading, for forms that need one sentence of context. */
.auth-form-intro {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: -12px 0 20px;
  text-align: center;
}

/* Password card in Settings: same inputs as the auth forms, capped in width so
   the fields do not stretch across the whole card. */
.settings-password-form { max-width: 420px; }

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-switch a:hover { text-decoration: underline; }

/* LEARN VIEW */
.learn-header { margin-bottom: 24px; }

.learn-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.filter-btn {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--border-light); color: var(--text-primary); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.tips-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tip-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}

.tip-card:hover { border-color: var(--border-light); }

.tip-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}

.tip-card-header:hover { background: rgba(255,255,255,0.02); }

.tip-category-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.tip-category-badge.tip { background: var(--accent); color: #fff; }
.tip-category-badge.gotcha { background: var(--red); color: #fff; }
.tip-category-badge.mental-model { background: var(--purple); color: #fff; }
.tip-category-badge.pattern { background: var(--green); color: #fff; }
.tip-category-badge.deep-dive { background: var(--orange); color: #fff; }

.tip-card-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
}

.tip-card-concept {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.tip-bookmark-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s;
  padding: 4px;
  flex-shrink: 0;
}

.tip-bookmark-btn:hover { opacity: 0.8; }
.tip-bookmark-btn.active { opacity: 1; }

.tip-expand-icon {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.tip-card.expanded .tip-expand-icon { transform: rotate(90deg); }

.tip-card-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

.tip-card.expanded .tip-card-body { display: block; padding-top: 16px; }

.tip-content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin-bottom: 16px;
}

.tip-code-example {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.tip-gotcha {
  padding: 12px 16px;
  background: var(--red-dim);
  border: 1px solid rgba(248, 81, 73, 0.2);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--red);
  line-height: 1.6;
  margin-bottom: 16px;
}

.tip-further-reading {
  font-size: 12px;
  color: var(--text-muted);
}

.tip-further-reading a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.tip-further-reading a:hover { text-decoration: underline; }

.tip-read-badge {
  font-size: 11px;
  color: var(--green);
  flex-shrink: 0;
}

/* ONBOARDING / LANGUAGE CHIPS */
.onboard-languages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.lang-chip:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.lang-chip:has(input:checked) {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
}

.lang-chip input {
  display: none;
}

/* SETTINGS */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 600px;
}

.settings-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

/* BRIDGE SECTIONS (multi-language) */
.bridge-multi {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.bridge-item {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
}

.bridge-item .bridge-lang-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}

.bridge-item .bridge-from,
.bridge-item .bridge-to {
  padding: 12px;
  font-size: 13px;
}

/* LANGUAGE NOTES on tips */
.tip-language-notes {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tip-lang-note {
  padding: 12px 16px;
  background: rgba(88, 166, 255, 0.06);
  border: 1px solid rgba(88, 166, 255, 0.15);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.tip-lang-note-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}

.tip-lang-note-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.tip-lang-note-gotcha {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--red-dim);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--red);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════
   SPARKY: the forge assistant
   A docked launcher plus a hint panel.
   ═══════════════════════════════════════════════ */

.sparky {
  --sparky-ember: #f0883e;
  --sparky-ember-soft: rgba(240, 136, 62, 0.14);
  --sparky-metal: #8b949e;
  --sparky-metal-dark: #6e7681;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  font-family: var(--font-sans);
}
.sparky[hidden] { display: none; }
.sparky > * { pointer-events: auto; }

:root[data-theme="light"] .sparky {
  --sparky-ember: #bc4c00;
  --sparky-ember-soft: rgba(188, 76, 0, 0.10);
  --sparky-metal: #6e7781;
  --sparky-metal-dark: #57606a;
}

/* Avatar (shared by launcher and panel header) */
.sparky-avatar { width: 28px; height: 28px; flex-shrink: 0; }
.sparky-avatar-metal { fill: var(--sparky-metal); }
.sparky-avatar-metal-dark { fill: var(--sparky-metal-dark); }
.sparky-avatar-eye { fill: var(--sparky-ember); transition: fill 0.2s; }
.sparky-avatar-spark { fill: var(--sparky-ember); transform-origin: 8px 5px; }

.sparky.mood-concerned .sparky-avatar-eye { fill: var(--yellow); }
.sparky.mood-happy .sparky-avatar-eye { fill: var(--green); }
.sparky.is-loading .sparky-avatar-spark { animation: sparkySpark 0.9s ease-in-out infinite; }

/* Launcher */
.sparky-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 6px 20px var(--overlay-soft), 0 1px 2px var(--overlay-soft);
  font: 600 13px/1 var(--font-sans);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.sparky-launcher:hover { border-color: var(--sparky-ember); transform: translateY(-1px); }
.sparky-launcher:active { transform: translateY(0); }
.sparky-launcher:focus-visible,
.sparky-icon-btn:focus-visible,
.sparky-btn:focus-visible,
.sparky-line-chip:focus-visible,
.sparky-live input:focus-visible + .sparky-switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sparky-launcher[aria-expanded="true"] { border-color: var(--sparky-ember); }

.sparky-dot {
  position: absolute;
  top: 6px;
  left: 30px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  background: transparent;
  box-sizing: content-box;
}
.sparky.mood-thinking .sparky-dot { background: var(--accent); }
.sparky.mood-concerned .sparky-dot { background: var(--yellow); }
.sparky.mood-happy .sparky-dot { background: var(--green); }

.sparky.entering .sparky-launcher { animation: sparkyEnter 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }

/* Panel */
.sparky-panel {
  width: 360px;
  max-height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px var(--overlay-strong), 0 2px 6px var(--overlay-soft);
  overflow: hidden;
  animation: sparkyPanelIn 0.18s ease-out;
  transform-origin: bottom right;
}
.sparky-panel[hidden] { display: none; }

.sparky-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 12px 14px;
  border-bottom: 1px solid var(--border);
}
.sparky-head-text { flex: 1; min-width: 0; }
.sparky-title { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.2; color: var(--text-primary); }
.sparky-status {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sparky-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
}
.sparky-icon-btn svg { width: 16px; height: 16px; }
.sparky-icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.sparky.is-loading #sparkyRefresh svg { animation: sparkySpin 0.8s linear infinite; }

/* Progress */
.sparky-progress { padding: 10px 14px 12px; border-bottom: 1px solid var(--border); }
.sparky-progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.sparky-progress-track {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}
.sparky-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--sparky-ember);
  border-radius: inherit;
  transition: width 0.35s ease, background-color 0.2s;
}
.sparky.mood-happy .sparky-progress-fill { background: var(--green); }

/* Body */
.sparky-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.sparky-body p { margin: 0 0 10px; }
.sparky-body p:last-child { margin-bottom: 0; }

.sparky-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sparky-step-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--text-primary);
}
.sparky-kw {
  padding: 1px 7px;
  font: 500 12px/1.6 var(--font-mono);
  color: var(--sparky-ember);
  background: var(--sparky-ember-soft);
  border-radius: 4px;
}

.sparky-body code,
.sparky-code {
  font-family: var(--font-mono);
  font-size: 12px;
}
.sparky-body :not(pre) > code {
  padding: 1px 5px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-primary);
}
.sparky-code {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.sparky-code .sparky-blank { color: var(--sparky-ember); font-weight: 600; }

.sparky-block { margin-top: 12px; }
.sparky-block-label {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Your line callout */
.sparky-attempt {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}
.sparky-attempt.is-off { border-color: color-mix(in srgb, var(--yellow) 55%, var(--border)); background: color-mix(in srgb, var(--yellow) 8%, var(--bg-secondary)); }
.sparky-attempt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--text-primary); font-weight: 600; }
.sparky-attempt .sparky-code { background: var(--bg-code); }
.sparky-attempt mark {
  background: none;
  color: inherit;
  text-decoration: underline wavy var(--yellow);
  text-underline-offset: 3px;
}

.sparky-attempt .sparky-note { margin: 8px 0 0; font-size: 12.5px; }

.sparky-line-chip {
  padding: 1px 8px;
  font: 600 12px/1.6 var(--font-mono);
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.sparky-line-chip:hover { text-decoration: underline; }

.sparky-issues { margin: 0; padding-left: 18px; }
.sparky-issues li { margin-bottom: 6px; }

/* Actions */
.sparky-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sparky-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font: 600 12px/1.4 var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.sparky-btn:hover { border-color: var(--border-light); }
.sparky-btn-quiet { background: none; color: var(--text-secondary); }
.sparky-btn-quiet:hover { color: var(--text-primary); }
.sparky-cost { font-weight: 500; color: var(--text-muted); }

.sparky-done {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.sparky-done-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, transparent);
}
.sparky-done-icon svg { width: 14px; height: 14px; }

/* Loading skeleton */
.sparky-skel { height: 10px; margin-bottom: 10px; border-radius: 4px; background: var(--bg-tertiary); animation: sparkyPulse 1.2s ease-in-out infinite; }
.sparky-skel.w60 { width: 60%; height: 14px; }
.sparky-skel.w90 { width: 90%; }
.sparky-skel.w75 { width: 75%; }

/* Footer */
.sparky-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.sparky-live { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-secondary); }
.sparky-live input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sparky-switch {
  position: relative;
  width: 26px;
  height: 14px;
  border-radius: 999px;
  background: var(--border-light);
  transition: background 0.15s;
}
.sparky-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-card);
  transition: transform 0.15s;
}
.sparky-live input:checked + .sparky-switch { background: var(--sparky-ember); }
.sparky-live input:checked + .sparky-switch::after { transform: translateX(12px); }

/* Editor highlight for the line Sparky is talking about */
.monaco-editor .sparky-line-focus { background: rgba(240, 136, 62, 0.10); border-left: 2px solid var(--sparky-ember, #f0883e); }
.monaco-editor .sparky-line-off { text-decoration: underline wavy #d29922; text-underline-offset: 3px; }

@keyframes sparkyPanelIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes sparkyEnter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes sparkySpark {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.35) rotate(45deg); opacity: 0.6; }
}
@keyframes sparkySpin { to { transform: rotate(360deg); } }
@keyframes sparkyPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

@media (max-width: 640px) {
  .sparky { right: 16px; bottom: 16px; left: 16px; align-items: stretch; }
  .sparky-launcher { align-self: flex-end; }
  .sparky-panel { width: auto; max-height: 70vh; }
}

@media (prefers-reduced-motion: reduce) {
  .sparky *, .sparky *::before, .sparky *::after { animation: none !important; transition: none !important; }
}

/* RESPONSIVE */
@media (max-width: 900px) {
  #sidebar { width: 200px; }
  #mainContent { margin-left: 200px; padding: 24px 20px; }
  .coding-layout, .review-layout { grid-template-columns: 1fr; }
  .bridge-section { grid-template-columns: 1fr; }
  .bridge-item { grid-template-columns: 1fr; }
  .bridge-arrow { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .rating-buttons { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════════════════════════════════════════════
   ARENA — MULTIPLAYER BATTLE MODE
   ═══════════════════════════════════════════════ */

/* Nav live dot */
.arena-live-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
  animation: arenaPulse 1.5s infinite;
}
@keyframes arenaPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* Header */
.arena-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}
.arena-title-row h2 {
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.arena-icon { font-size: 28px; }
.arena-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
  display: block;
}
.arena-my-stats {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
}
.my-stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}
.my-stat-value { font-weight: 700; color: var(--text-primary); }
.my-stat-label { color: var(--text-muted); font-size: 12px; }

/* Lobby grid */
.arena-lobby-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  min-height: 400px;
}
.arena-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.arena-section-header h3 { font-size: 16px; font-weight: 600; }
.arena-online-count {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
  padding: 3px 10px;
  background: rgba(63, 185, 80, 0.1);
  border-radius: 12px;
}

/* Player list */
.arena-player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 500px;
  overflow-y: auto;
}
.arena-player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, transform 0.15s;
}
.arena-player-card:hover {
  border-color: #e95420;
  transform: translateX(3px);
}
.arena-player-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e95420, #c7421a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}
.arena-player-details {
  flex: 1;
  min-width: 0;
}
.arena-player-name {
  font-weight: 600;
  font-size: 14px;
  display: block;
}
.arena-player-username {
  font-size: 12px;
  color: var(--text-muted);
}
.arena-challenge-btn {
  background: linear-gradient(135deg, #e95420, #c7421a) !important;
  color: white !important;
  border: none !important;
  font-weight: 600;
  white-space: nowrap;
}
.arena-challenge-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(233, 84, 32, 0.4);
}
.arena-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.arena-empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.arena-empty-sub { font-size: 13px; opacity: 0.6; }

/* Rating badges */
.rating-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Ubuntu Mono', monospace;
}
.rating-iron { background: #555; color: #ccc; }
.rating-bronze { background: #6d4c30; color: #e8c48a; }
.rating-silver { background: #545c6a; color: #c0c7d1; }
.rating-gold { background: #6b5a00; color: #ffd700; }
.rating-diamond { background: #1a3a5c; color: #5ce0d8; }
.rating-gm { background: #5c1a3a; color: #ff6bcb; }

/* Leaderboard */
.arena-leaderboard, .arena-recent {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.arena-leaderboard { margin-bottom: 16px; }
.arena-leaderboard h3, .arena-recent h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.arena-lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
}
.arena-lb-row:nth-child(odd) { background: rgba(255,255,255,0.02); }
.arena-lb-me { background: rgba(233, 84, 32, 0.1) !important; border: 1px solid rgba(233, 84, 32, 0.3); }
.arena-lb-rank { width: 28px; text-align: center; font-weight: 700; }
.arena-lb-name { flex: 1; font-weight: 500; }
.arena-lb-rating { font-weight: 700; font-family: 'Ubuntu Mono', monospace; }
.arena-lb-record { color: var(--text-muted); font-size: 11px; }
.arena-lb-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 20px; }

/* Rules */
.arena-rules { display: flex; flex-direction: column; gap: 8px; }
.arena-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}
.rule-num {
  width: 24px; height: 24px;
  background: linear-gradient(135deg, #e95420, #c7421a);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── BATTLE SCREEN ── */
.battle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.battle-player {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.battle-player-right { flex-direction: row-reverse; text-align: right; }
.battle-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e95420, #c7421a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  color: white;
  flex-shrink: 0;
}
.battle-player-right .battle-avatar {
  background: linear-gradient(135deg, #4ab648, #2d8a2b);
}
.battle-player-info { display: flex; flex-direction: column; gap: 2px; }
.battle-player-name { font-weight: 700; font-size: 16px; }
.battle-player-rating { font-size: 12px; }
.battle-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
.battle-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.4s ease;
  background: linear-gradient(90deg, #e95420, #f5a623);
}
.battle-player-right .battle-progress-fill {
  background: linear-gradient(90deg, #4ab648, #7dd87a);
}
.battle-progress-fill.progress-hot {
  animation: progressGlow 0.5s ease infinite alternate;
}
@keyframes progressGlow {
  from { box-shadow: 0 0 4px rgba(233, 84, 32, 0.5); }
  to { box-shadow: 0 0 12px rgba(233, 84, 32, 0.8); }
}

/* VS / Countdown / Timer */
.battle-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}
.battle-vs {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.battle-countdown {
  display: flex;
  align-items: center;
  justify-content: center;
}
.countdown-num {
  font-size: 64px;
  font-weight: 900;
  color: #e95420;
  font-family: 'Ubuntu Mono', monospace;
  text-shadow: 0 0 20px rgba(233, 84, 32, 0.5);
  line-height: 1;
}
.countdown-pop {
  animation: countdownPop 0.6s ease;
}
@keyframes countdownPop {
  0% { transform: scale(1.8); opacity: 0.5; }
  50% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.battle-timer {
  font-size: 28px;
  font-weight: 700;
  font-family: 'Ubuntu Mono', monospace;
  color: var(--text-primary);
}
.battle-timer.timer-urgent { color: #f5a623; }
.battle-timer.timer-critical {
  color: #f85149;
  animation: timerFlash 0.5s ease infinite alternate;
}
@keyframes timerFlash {
  from { opacity: 1; }
  to { opacity: 0.4; }
}

/* Challenge info bar */
.battle-challenge-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.battle-challenge-title {
  font-weight: 600;
  font-size: 15px;
}

/* Prompt bar */
.battle-prompt-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
}
.battle-prompt-label {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.battle-prompt-text {
  flex: 1;
  color: var(--text-secondary);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.battle-prompt-bar.prompt-expanded .battle-prompt-text {
  max-height: 200px;
}

/* Editor area */
.battle-editor-area {
  max-width: 100%;
}
.battle-editor-area .ubuntu-terminal { margin-bottom: 0; }

/* ── RESULT SCREEN ── */
.arena-result-card {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 32px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 16px;
  text-align: center;
}
.arena-result-card.victory {
  border-color: #ffd700;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.15);
}
.arena-result-card.defeat {
  border-color: #f85149;
  box-shadow: 0 0 40px rgba(248, 81, 73, 0.1);
}
.arena-result-card.draw {
  border-color: #8b949e;
}
.result-crown { font-size: 64px; margin-bottom: 8px; }
.result-verdict {
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 24px;
}
.victory .result-verdict { color: #ffd700; }
.defeat .result-verdict { color: #f85149; }
.draw .result-verdict { color: #8b949e; }

.result-players-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.result-player-summary {
  flex: 1;
  min-width: 200px;
  max-width: 280px;
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.result-player-summary.is-winner {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.05);
}
.result-player-summary.is-me {
  box-shadow: 0 0 0 2px rgba(233, 84, 32, 0.3);
}
.result-summary-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e95420, #c7421a);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  margin-bottom: 6px;
}
.result-summary-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}
.result-rating-delta {
  margin-top: 8px;
  font-family: 'Ubuntu Mono', monospace;
  font-weight: 700;
  font-size: 16px;
}
.rating-up { color: #4ab648; }
.rating-down { color: #f85149; }

.result-code-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
  text-align: left;
}
.result-code-compare-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 900px) {
  .result-code-compare,
  .result-code-compare-3 { grid-template-columns: 1fr; }
}
.result-code-col h4 { font-size: 13px; margin-bottom: 6px; color: var(--text-muted); }
.result-code-col .code-block {
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
}

.result-actions {
  margin-top: 16px;
}

.arena-tiers-title { margin-top: 18px; }
.arena-tier-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* ── CHALLENGE MODAL ── */
.arena-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}
.arena-modal {
  background: var(--bg-secondary);
  border: 2px solid #e95420;
  border-radius: 16px;
  padding: 40px 32px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  animation: modalSlam 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalSlam {
  0% { transform: scale(0.3) rotate(-5deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.arena-modal-icon { font-size: 56px; margin-bottom: 12px; }
.arena-modal-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.arena-modal-text { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.arena-modal-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ── TOAST ── */
.arena-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.arena-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.arena-toast-info { background: #1a3a5c; color: #79c0ff; border: 1px solid #264f78; }
.arena-toast-warn { background: #4a3000; color: #f5a623; border: 1px solid #6b4500; }
.arena-toast-error { background: #5c1a1a; color: #f85149; border: 1px solid #7a2020; }

/* ── PRACTICE PAGE ── */

.practice-header { margin-bottom: 32px; }
.practice-header h2 { font-size: 24px; font-weight: 600; margin-bottom: 6px; }

.practice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.practice-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.practice-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.practice-card-diff {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.practice-card-diff[data-diff="1"] { background: var(--green); }
.practice-card-diff[data-diff="2"] { background: var(--yellow); }
.practice-card-diff[data-diff="3"] { background: var(--red); }

.practice-card-title {
  font-family: var(--font-read);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.practice-card-desc {
  font-family: var(--font-read);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.practice-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.practice-card-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.practice-card-badge.diff-1 { background: rgba(63,185,80,0.15); color: #3fb950; }
.practice-card-badge.diff-2 { background: rgba(210,153,34,0.15); color: #d29922; }
.practice-card-badge.diff-3 { background: rgba(248,81,73,0.15); color: #f85149; }

.practice-card-hours {
  font-size: 11px;
  color: var(--text-muted);
}

.practice-card-progress {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.practice-card-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.practice-card-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--green);
  transition: width 0.3s;
}

.practice-card-progress-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.practice-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.practice-card-tag {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-muted);
}

.practice-card-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 12px;
  padding: 4px 12px;
  border-radius: 6px;
}

.practice-card-status.active { background: rgba(88,166,255,0.12); color: #58a6ff; }
.practice-card-status.completed { background: rgba(63,185,80,0.12); color: #3fb950; }

/* Practice Workspace */

.practice-ws-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.practice-ws-title h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 2px;
}

.practice-ws-session {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.practice-ws-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  min-height: 600px;
}

/* Milestone sidebar */

.practice-milestones {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.practice-ms-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.practice-ms-item:hover { background: var(--bg-tertiary); }
.practice-ms-item.active { background: var(--bg-tertiary); border-color: var(--accent); }
.practice-ms-item.locked { opacity: 0.4; cursor: not-allowed; }

.practice-ms-num {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--border);
  color: var(--text-muted);
}

.practice-ms-item.completed .practice-ms-num {
  background: var(--green);
  border-color: var(--green);
  color: #0d1117;
}

.practice-ms-item.active .practice-ms-num {
  border-color: var(--accent);
  color: var(--accent);
}

.practice-ms-item.in_progress .practice-ms-num {
  border-color: var(--yellow);
  color: var(--yellow);
}

.practice-ms-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.practice-ms-item.locked .practice-ms-label { color: var(--text-muted); }

.practice-ms-check {
  margin-left: auto;
  font-size: 14px;
}

/* Work area */

.practice-work-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.practice-ms-detail {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
}

.practice-ms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.practice-ms-header h3 {
  font-family: var(--font-read);
  font-size: 17px;
  font-weight: 600;
}

.practice-ms-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}

.practice-ms-status.available { background: rgba(88,166,255,0.12); color: #58a6ff; }
.practice-ms-status.in_progress { background: rgba(210,153,34,0.12); color: #d29922; }
.practice-ms-status.completed { background: rgba(63,185,80,0.12); color: #3fb950; }
.practice-ms-status.locked { background: rgba(139,148,158,0.12); color: #8b949e; }

.practice-ms-desc {
  font-family: var(--font-read);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.practice-ms-objectives {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.practice-ms-obj {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--font-read);
  font-size: 13px;
  line-height: 1.5;
  color: #b1bac4;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
}

.practice-ms-obj-num {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.practice-ms-hints-section { margin-top: 8px; }

.practice-ms-hints {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.practice-ms-hint {
  font-family: var(--font-read);
  font-size: 13px;
  color: #d29922;
  padding: 8px 12px;
  background: rgba(210,153,34,0.08);
  border-radius: 6px;
  border-left: 3px solid #d29922;
}

/* Practice Editor */

.practice-editor-area {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.practice-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1c1c1c;
  border-bottom: 1px solid var(--border);
}

.practice-editor-file {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.practice-editor-actions {
  display: flex;
  gap: 8px;
}

.practice-editor {
  height: 400px;
  min-height: 300px;
}

.practice-output {
  border-top: 1px solid var(--border);
}

.practice-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #1c1c1c;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.practice-output-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

.practice-output-content {
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: #c9d1d9;
  background: #0d1117;
  max-height: 200px;
  overflow-y: auto;
  margin: 0;
  white-space: pre-wrap;
}

/* Test Results */

.practice-test-results {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.practice-test-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.practice-test-header .test-pass { color: var(--green); }
.practice-test-header .test-fail { color: var(--red); }

.practice-test-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.practice-test-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.practice-test-item.passed {
  background: rgba(63,185,80,0.08);
  border: 1px solid rgba(63,185,80,0.2);
}

.practice-test-item.failed {
  background: rgba(248,81,73,0.08);
  border: 1px solid rgba(248,81,73,0.2);
}

.practice-test-icon {
  font-size: 16px;
  min-width: 20px;
  text-align: center;
}

.practice-test-body {
  flex: 1;
}

.practice-test-desc {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.practice-test-detail {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Responsive */

@media (max-width: 768px) {
  .practice-ws-layout {
    grid-template-columns: 1fr;
  }
  .practice-milestones {
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 8px;
  }
  .practice-ms-item {
    flex-shrink: 0;
    min-width: 120px;
  }
}

/* ── LEARN PAGE ── */

.learn-page-header { margin-bottom: 32px; }
.learn-page-header h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.3px; }

.learn-progress-overview {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.learn-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.learn-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.4s;
}

.learn-progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── COURSE SHELF ── */

.learn-shelf-header { margin-bottom: 28px; }
.learn-shelf-header h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.3px; }

.learn-shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.learn-shelf-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.learn-shelf-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.learn-shelf-empty h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.learn-shelf-empty p { font-size: 14px; max-width: 400px; margin: 0 auto; }

.learn-course-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  outline: none;
}
.learn-course-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  border-color: var(--border-light);
}
.learn-course-card:focus-visible {
  box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(0,0,0,0.4);
}

.learn-course-cover {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.learn-course-cover.new { background: linear-gradient(135deg, #1a2a3a 0%, #2a3a4a 50%, #1a3a2a 100%); }
.learn-course-cover.in-progress { background: linear-gradient(135deg, #1a2a4a 0%, #2a3a5a 50%, #4a2a1a 100%); }
.learn-course-cover.completed { background: linear-gradient(135deg, #1a3a1a 0%, #2a4a2a 50%, #1a2a1a 100%); }

.learn-course-cover-icon { font-size: 42px; opacity: 0.85; }
.learn-course-cover-label {
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.5);
}

.learn-course-cover-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.learn-course-body { padding: 14px 16px 16px; }

.learn-course-title {
  font-family: var(--font-read, 'IBM Plex Sans', sans-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.learn-course-author {
  font-size: 12px;
  color: var(--text-secondary);
  margin: -2px 0 6px;
}

.learn-course-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

/* Byline under the course title in the section browser. */
.learn-course-byline {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 6px;
}

.learn-course-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}
.learn-course-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}
.learn-course-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s ease;
}
.learn-course-progress span {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.learn-course-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 0;
}
.learn-course-status.completed { color: var(--green); }
.learn-course-status.in-progress { color: var(--accent); }
.learn-course-status.new { color: var(--text-muted); }

.learn-course-last-opened {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.learn-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.learn-section-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.learn-section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  cursor: pointer;
  transition: background 0.15s;
}

.learn-section-head:hover { background: var(--bg-tertiary); }

.learn-section-num {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--accent);
  color: #0d1117;
}

.learn-section-info { flex: 1; }

.learn-section-title {
  font-family: var(--font-read, 'IBM Plex Sans', sans-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.learn-section-desc {
  font-size: 12.5px;
  color: var(--text-muted);
}

.learn-section-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.learn-section-progress-ring {
  width: 28px;
  height: 28px;
}

.learn-section-progress-ring circle {
  fill: none;
  stroke-width: 3;
}

.learn-section-progress-ring .ring-bg { stroke: var(--bg-tertiary); }
.learn-section-progress-ring .ring-fill { stroke: var(--green); transition: stroke-dashoffset 0.4s; }

.learn-section-chevron {
  font-size: 14px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.learn-section-card.expanded .learn-section-chevron { transform: rotate(90deg); }

.learn-section-lessons {
  display: none;
  border-top: 1px solid var(--border);
}

.learn-section-card.expanded .learn-section-lessons { display: block; }

.learn-lesson-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px 12px 36px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(48,54,61,0.4);
}

.learn-lesson-item:last-child { border-bottom: none; }
.learn-lesson-item:hover { background: rgba(88,166,255,0.04); }

.learn-lesson-check {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
}

.learn-lesson-check.done {
  background: var(--green);
  border-color: var(--green);
  color: #0d1117;
}

.learn-lesson-title {
  flex: 1;
  font-family: var(--font-read, 'IBM Plex Sans', sans-serif);
  font-size: 14px;
  color: var(--text-primary);
}

.learn-lesson-dur {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Learn Reader */

.learn-reader-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.learn-reader-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.learn-reader-section {
  font-size: 12px;
  color: var(--text-muted);
}

.learn-reader-author {
  font-size: 12px;
  color: var(--text-secondary);
}
.learn-reader-author::after {
  content: '·';
  margin-left: 12px;
  color: var(--text-muted);
}

.learn-reader-duration {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 10px;
  background: var(--bg-tertiary);
  border-radius: 10px;
}

.learn-reader-body {
  max-width: 760px;
  margin: 0 auto;
}

.learn-article {
  font-family: var(--font-read, 'IBM Plex Sans', sans-serif);
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-article);
}

.learn-article h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin: 0 0 20px 0;
  color: var(--text-primary);
}

.learn-article h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 32px 0 12px 0;
  color: var(--text-primary);
}

.learn-article p {
  margin: 0 0 16px 0;
}

.learn-article figure.learn-figure {
  margin: 20px 0;
  text-align: center;
}

.learn-article figure.learn-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.learn-article figure.learn-figure figcaption {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-muted, #8b949e);
}

.learn-article pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 16px 0 20px 0;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
}

.learn-article pre code.hljs {
  background: transparent;
  padding: 0;
}

.learn-article pre {
  position: relative;
}

.learn-article pre::before {
  content: 'zig';
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 10px;
  font-weight: 600;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'JetBrains Mono', monospace;
}

.learn-article code {
  font-family: 'JetBrains Mono', 'Ubuntu Mono', monospace;
  font-size: 0.88em;
}

.learn-article p code, .learn-article li code {
  background: rgba(110,118,129,0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--text-primary);
}

.learn-article pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.learn-article ul, .learn-article ol {
  margin: 0 0 16px 0;
  padding-left: 24px;
}

.learn-article li {
  margin-bottom: 6px;
}

.learn-callout {
  padding: 14px 18px;
  margin: 16px 0 20px 0;
  border-radius: 8px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-article);
}

.learn-callout strong { color: var(--accent); }

.learn-callout.warn {
  background: rgba(210,153,34,0.10);
  border-left-color: var(--yellow);
}

.learn-callout.warn strong { color: var(--yellow); }

.learn-key-point {
  padding: 14px 18px;
  margin: 16px 0 20px 0;
  border-radius: 8px;
  background: rgba(63,185,80,0.10);
  border-left: 3px solid var(--green);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-article);
}

.learn-key-point strong { color: var(--green); }

/* ── Unpublished Learn course ──
   The card stays on the shelf so people can see what is coming, dimmed and
   badged, with the cover ribbon reading "Coming soon". */

.learn-course-card.coming-soon .learn-course-cover { filter: grayscale(0.8); opacity: 0.55; }
.learn-course-card.coming-soon .learn-course-title { opacity: 0.7; }
.learn-course-card.coming-soon { cursor: default; }

.learn-course-soon {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 5px 0;
  text-align: center;
  background: rgba(245, 166, 35, 0.92);
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.learn-course-soon-note {
  margin-top: 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent, #f5a623);
  border-radius: 6px;
  background: rgba(245, 166, 35, 0.10);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted, #8b949e);
}

/* ── Lesson extras: bridges, gotchas, practice links ──
   Appended after the lesson body by renderLessonExtras(). */

.learn-extras {
  margin: 28px 0 8px 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.learn-extras h3 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Blue: "here is how this maps to what you already know" */
.learn-bridge {
  position: relative;
  padding: 14px 18px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: rgba(88, 166, 255, 0.08);
  border-left: 3px solid var(--blue, #58a6ff);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-article);
}

.learn-bridge p { margin: 0 0 8px 0; }
.learn-bridge p:last-child { margin-bottom: 0; }

.learn-bridge-lang {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(88, 166, 255, 0.18);
  color: var(--blue, #58a6ff);
  font-size: 11px;
  font-weight: 600;
}

/* Amber: "this is where people trip" */
.learn-gotcha {
  padding: 14px 18px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: rgba(245, 166, 35, 0.10);
  border-left: 3px solid var(--accent, #f5a623);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-article);
}

.learn-gotcha strong { color: var(--accent, #f5a623); }
.learn-gotcha p { margin: 6px 0 0 0; }

.learn-further { font-size: 12px; }
.learn-further a {
  color: var(--text-muted);
  text-decoration: underline;
  margin-right: 10px;
  word-break: break-all;
}
.learn-further a:hover { color: var(--blue, #58a6ff); }

.learn-practice-intro {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.learn-challenge-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.learn-challenge-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text-article);
}

.learn-challenge-list li.done { opacity: 0.6; }

.learn-chal-dot {
  width: 16px;
  flex: 0 0 16px;
  color: var(--green);
  font-size: 12px;
}

.learn-chal-title { flex: 1; }

.learn-chal-diff {
  flex: 0 0 auto;
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--accent, #f5a623);
}

/* ── Memorize It? ── */

.memorize-wrapper {
  position: relative;
  margin: 16px 0 20px 0;
}

.memorize-wrapper > pre {
  margin: 0;
}

.memorize-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.memorize-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-code, 'JetBrains Mono', monospace);
  font-size: 11.5px;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.memorize-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.memorize-btn.active {
  color: var(--yellow);
  border-color: var(--yellow);
  background: rgba(210,153,34,0.08);
}

.memorize-btn svg {
  opacity: 0.7;
}

.memorize-editor {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-code);
  overflow: hidden;
}

.memorize-textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 16px 18px;
  background: var(--bg-code);
  color: var(--text-primary);
  border: none;
  outline: none;
  font-family: 'JetBrains Mono', 'Ubuntu Mono', monospace;
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
}

.memorize-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.memorize-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.memorize-check-btn,
.memorize-reveal-btn,
.memorize-cancel-btn {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}

.memorize-check-btn {
  background: var(--green);
  color: var(--text-on-accent);
  border-color: var(--green);
}

.memorize-check-btn:hover {
  filter: brightness(1.1);
}

.memorize-reveal-btn {
  background: transparent;
  color: var(--yellow);
  border-color: var(--yellow);
}

.memorize-reveal-btn:hover {
  background: rgba(210,153,34,0.1);
}

.memorize-cancel-btn {
  background: transparent;
  color: var(--text-secondary);
}

.memorize-cancel-btn:hover {
  background: rgba(139,148,158,0.1);
}

.memorize-result {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.memorize-score {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.memorize-score.perfect {
  background: rgba(63,185,80,0.12);
  color: var(--green);
}

.memorize-score.great {
  background: rgba(63,185,80,0.10);
  color: var(--green);
}

.memorize-score.okay {
  background: rgba(210,153,34,0.10);
  color: var(--yellow);
}

.memorize-score.needs-work {
  background: rgba(248,81,73,0.10);
  color: var(--red);
}

.memorize-score-icon {
  font-size: 20px;
}

.memorize-score-pct {
  font-size: 22px;
  font-family: 'JetBrains Mono', monospace;
}

.memorize-score-text {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.85;
}

.memorize-diff {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-family: 'JetBrains Mono', 'Ubuntu Mono', monospace;
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 320px;
  overflow-y: auto;
}

.diff-line {
  display: flex;
  padding: 1px 12px;
  white-space: pre;
}

.diff-line.match {
  color: var(--text-secondary);
}

.diff-line.ws {
  color: #d29922;
  background: rgba(210,153,34,0.04);
}

.diff-line.missing {
  background: rgba(63,185,80,0.06);
}

.diff-line.extra {
  background: rgba(248,81,73,0.06);
}

.diff-line.wrong {
  background: rgba(248,81,73,0.08);
}

.diff-line.expected {
  background: rgba(63,185,80,0.06);
}

.diff-num {
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
  margin-right: 12px;
  user-select: none;
}

.diff-code {
  flex: 1;
}

.diff-code.diff-expected {
  color: var(--green);
}

.diff-code.diff-expected::before {
  content: '+ ';
  color: var(--green);
  opacity: 0.6;
}

.diff-code.diff-yours {
  color: var(--red);
}

.diff-code.diff-yours::before {
  content: '- ';
  color: var(--red);
  opacity: 0.6;
}

.diff-hint {
  font-size: 10px;
  color: var(--yellow);
  opacity: 0.7;
  margin-left: 8px;
}

.learn-reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.learn-nav-btns {
  display: flex;
  gap: 8px;
}

.learn-complete-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: rgba(63,185,80,0.1);
  border: 1px solid rgba(63,185,80,0.3);
  border-radius: 8px;
  color: #3fb950;
  font-size: 13px;
  font-weight: 600;
}

/* ── PREMIUM PRACTICE ── */

.premium-section {
  margin-top: 48px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.premium-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.premium-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.premium-section-title h3 {
  font-family: var(--font-read);
  font-size: 20px;
  font-weight: 600;
}

.premium-badge-icon {
  color: #f0b429;
  font-size: 20px;
}

.premium-badge-icon.large {
  font-size: 36px;
}

.premium-section-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.premium-price {
  font-size: 28px;
  font-weight: 700;
  color: #f0b429;
  font-family: var(--font-sans);
}

.premium-price-note {
  font-size: 12px;
  color: var(--text-muted);
}

.premium-section-desc {
  font-family: var(--font-read);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 700px;
}

.premium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.premium-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(240,180,41,0.2);
  border-radius: 12px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  opacity: 0.85;
  transition: opacity 0.2s, border-color 0.2s;
}

.premium-card:hover { opacity: 1; border-color: rgba(240,180,41,0.4); }

.premium-card.unlocked {
  opacity: 1;
  border-color: var(--border);
  cursor: pointer;
}

.premium-card.unlocked:hover { border-color: var(--accent); }

.premium-card-lock {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 16px;
  opacity: 0.5;
}

.premium-card-title {
  font-family: var(--font-read);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  padding-right: 28px;
}

.premium-card-desc {
  font-family: var(--font-read);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.premium-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.premium-card-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: rgba(240,180,41,0.12);
  color: #f0b429;
}

.premium-card-hours {
  font-size: 11px;
  color: var(--text-muted);
}

.premium-card-milestones {
  font-size: 11px;
  color: var(--text-muted);
}

.premium-card-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.premium-card-tag {
  font-size: 10px;
  padding: 2px 7px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-muted);
}

.premium-cta {
  text-align: center;
  padding: 20px 0 8px 0;
}

.premium-cta-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

.btn-premium {
  background: linear-gradient(135deg, #f0b429 0%, #d4940a 100%);
  color: #0d1117;
  font-weight: 700;
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.2px;
}

.btn-premium:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(240,180,41,0.3);
}

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

.premium-unlocked-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
  padding: 10px 16px;
  background: rgba(240,180,41,0.08);
  border: 1px solid rgba(240,180,41,0.2);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #f0b429;
}

/* Premium Modal */

.premium-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.premium-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.premium-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  z-index: 1;
  padding: 4px 8px;
  line-height: 1;
}

.premium-modal-close:hover { color: var(--text-primary); }

.premium-modal-header {
  text-align: center;
  padding: 32px 24px 20px;
  background: linear-gradient(180deg, rgba(240,180,41,0.08) 0%, transparent 100%);
}

.premium-modal-header h2 {
  font-family: var(--font-read);
  font-size: 22px;
  font-weight: 600;
  margin-top: 8px;
  margin-bottom: 6px;
}

.premium-modal-price {
  font-size: 32px;
  font-weight: 700;
  color: #f0b429;
}

.premium-modal-price span {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.premium-modal-body {
  padding: 0 28px 28px;
}

.premium-modal-features {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.premium-modal-feature {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.pmf-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  background: rgba(63,185,80,0.15);
  color: #3fb950;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.premium-modal-feature strong {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.premium-modal-feature p {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.premium-form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.premium-payment-options {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.premium-pay-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: border-color 0.15s, background 0.15s;
}

.premium-pay-option input { display: none; }

.premium-pay-option.selected,
.premium-pay-option:has(input:checked) {
  border-color: #f0b429;
  background: rgba(240,180,41,0.06);
  color: var(--text-primary);
}

.premium-pay-icon { font-size: 18px; }

.premium-modal-secure {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
}

.btn-block { width: 100%; }

/* ── GUIDE PAGE ── */
.guide-page {
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 0 80px 0;
}

.guide-hero {
  text-align: center;
  margin-bottom: 48px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.guide-hero-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.guide-hero h1 {
  font-family: var(--font-read);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}

.guide-hero-sub {
  font-family: var(--font-read);
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-section {
  display: flex;
  gap: 24px;
  margin-bottom: 48px;
}

.guide-section-num {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--accent);
  color: #0d1117;
  font-size: 15px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.guide-section-body {
  flex: 1;
}

.guide-section-body h2 {
  font-family: var(--font-read);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}

.guide-section-body > p {
  font-family: var(--font-read);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.guide-step-icon {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  min-width: 64px;
  text-align: center;
}

.guide-step p {
  font-family: var(--font-read);
  font-size: 13.5px;
  line-height: 1.6;
  color: #c9d1d9;
  margin: 0;
}

.guide-ratings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-rating {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-read);
  font-size: 13.5px;
  color: #b1bac4;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
}

.guide-rating strong {
  color: var(--text-primary);
  min-width: 80px;
}

.guide-rating-num {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-levels {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-level {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.guide-level p {
  font-family: var(--font-read);
  font-size: 13.5px;
  line-height: 1.6;
  color: #b1bac4;
  margin: 0;
}

.guide-level-badge {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border: 1.5px solid;
  border-radius: 4px;
  white-space: nowrap;
  min-width: 80px;
  text-align: center;
}

.guide-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-list-item {
  font-family: var(--font-read);
  font-size: 13.5px;
  line-height: 1.65;
  color: #b1bac4;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border-left: 3px solid var(--border);
}

.guide-list-item strong {
  color: var(--text-primary);
}

.guide-bridge-demo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
}

.guide-bridge-box {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border-top: 2px solid;
  font-family: var(--font-read);
  font-size: 13px;
  color: #b1bac4;
  line-height: 1.6;
}

.guide-bridge-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.guide-bridge-arrow {
  font-size: 22px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.guide-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-tool {
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.guide-tool-name {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.guide-tool p {
  font-family: var(--font-read);
  font-size: 13px;
  line-height: 1.6;
  color: #b1bac4;
  margin: 0;
}

.guide-footer {
  text-align: center;
  margin-top: 48px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.guide-footer p {
  font-family: var(--font-read);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

@media (max-width: 600px) {
  .guide-section { flex-direction: column; gap: 12px; }
  .guide-bridge-demo { flex-direction: column; }
  .guide-bridge-arrow { transform: rotate(90deg); }
}

/* ── Theme toggle ── */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.2s;
}

.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  background: var(--bg-tertiary);
}

.theme-toggle:active {
  transform: scale(0.92);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

/* Hide the icon that does not match the active theme. */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Auth screen toggle: floats top-right of the auth screen. */
.auth-theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10;
}

/* Hide the floating auth toggle once the main app is visible. */
body.app-active .auth-theme-toggle { display: none; }

/* Sidebar toggle: sits in the sidebar header next to the logo. */
.sidebar-theme-toggle {
  margin-left: auto;
}

/* Settings appearance card. */
.appearance-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.appearance-option {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.appearance-option:hover {
  border-color: var(--border-light);
}

.appearance-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.appearance-option-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.appearance-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.appearance-option-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
}

/* Light-theme polish: a few specific places that need tuning beyond plain
   variable swaps. The variable-driven defaults work for most of the UI; the
   rules below are the targeted adjustments. */

:root[data-theme="light"] .learn-article p code,
:root[data-theme="light"] .learn-article li code {
  background: rgba(175, 184, 193, 0.20);
  color: var(--text-primary);
}

/* Highlight.js writes its own colors. We use github-dark.min.css by default
   and swap to github.min.css via JS when the theme flips. The rules below
   keep the wrapper readable in both themes regardless of which sheet
   loaded first. */
:root[data-theme="light"] .learn-article pre code.hljs,
:root[data-theme="light"] .memorize-textarea {
  background: transparent;
}

/* ── PASSWORD STRENGTH METER (register form) ───────────────────────────── */

.pw-meter {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.pw-meter-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  transition: background 0.2s ease;
}
/* Colour comes from the score on the container, so all filled segments match
   rather than shading from red to green across the row. */
.pw-meter[data-score="1"] .pw-meter-bar.is-filled { background: var(--red); }
.pw-meter[data-score="2"] .pw-meter-bar.is-filled { background: var(--orange); }
.pw-meter[data-score="3"] .pw-meter-bar.is-filled { background: var(--yellow); }
.pw-meter[data-score="4"] .pw-meter-bar.is-filled { background: var(--green); }

.pw-strength-row { min-height: 18px; margin-top: 6px; }
#pwStrengthLabel { font-weight: 600; }
#pwStrengthLabel[data-score="1"] { color: var(--red); }
#pwStrengthLabel[data-score="2"] { color: var(--orange); }
#pwStrengthLabel[data-score="3"] { color: var(--yellow); }
#pwStrengthLabel[data-score="4"] { color: var(--green); }

.pw-rules {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--text-secondary);
}
.pw-rules li {
  position: relative;
  padding-left: 18px;
  line-height: 1.7;
}
.pw-rules li::before {
  content: "○";
  position: absolute;
  left: 0;
  color: var(--text-muted);
}
.pw-rules li.is-met { color: var(--green); }
.pw-rules li.is-met::before { content: "✓"; color: var(--green); }
.pw-rules li.is-unmet::before { content: "×"; color: var(--red); }

/* ── ADMIN PANEL (settings view) ───────────────────────────────────────── */

.admin-card { border-color: var(--accent); }
.admin-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}
.admin-subhead {
  margin: 22px 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.admin-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}
.admin-toggle-desc {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.switch { flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  display: block;
  width: 44px;
  height: 24px;
  padding: 2px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  transition: background 0.2s ease;
}
.switch-thumb {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform 0.2s ease, background 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--green-dim); border-color: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: var(--green); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}
.admin-stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.admin-stat-label { font-size: 12px; color: var(--text-secondary); }
.admin-stat-hint { font-size: 11px; color: var(--yellow); }

.admin-spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 48px;
  margin-top: 10px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}
.admin-spark-bar {
  flex: 1;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  opacity: 0.75;
}

.admin-recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  margin-bottom: 6px;
  font-size: 13px;
}
.admin-recent-who { flex: 1; min-width: 0; }
.admin-recent-who strong { display: block; }
.admin-recent-username { color: var(--text-muted); font-size: 12px; }
.admin-recent-date { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.admin-empty { color: var(--text-secondary); font-size: 13px; }

.admin-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.admin-pill.is-ok { background: var(--green-dim); color: var(--green); }
.admin-pill.is-pending { background: var(--yellow-dim); color: var(--yellow); }

@media (max-width: 560px) {
  .admin-recent-row { flex-wrap: wrap; }
  .admin-recent-date { width: 100%; }
}
