/* ============================================================
   AI Enablement Hub — design system
   Dark theme default, light via [data-theme="light"].
   ============================================================ */

:root {
  --bg: #0b0f1a;
  --bg-soft: #0e1322;
  --surface: #151a2b;
  --surface-2: #1c2338;
  --surface-3: #232c46;
  --border: #262f4a;
  --border-strong: #33406366;
  --text: #e7eaf4;
  --text-dim: #97a1bc;
  --text-faint: #6b7692;

  --accent: #6366f1;
  --accent-2: #a855f7;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);

  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.15);
  --blue: #38bdf8;
  --blue-soft: rgba(56, 189, 248, 0.15);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lift: 0 4px 12px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
  --sidebar-w: 232px;
  --speed: 150ms;

  --heat-0: #1b2236;
  --heat-1: #3b3a86;
  --heat-2: #5b52c9;
  --heat-3: #8168ee;
  --heat-4: #b18cff;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f5fb;
  --bg-soft: #eceff8;
  --surface: #ffffff;
  --surface-2: #f2f4fb;
  --surface-3: #e8ebf6;
  --border: #e2e6f2;
  --border-strong: #cdd4e6;
  --text: #1b2237;
  --text-dim: #5a6480;
  --text-faint: #8b94ad;
  --accent-soft: rgba(99, 102, 241, 0.1);
  --shadow: 0 1px 2px rgba(23, 30, 60, 0.06), 0 8px 24px rgba(23, 30, 60, 0.07);
  --shadow-lift: 0 4px 12px rgba(23, 30, 60, 0.1), 0 14px 34px rgba(23, 30, 60, 0.12);
  --heat-0: #e5e9f4;
  --heat-1: #c7c5f4;
  --heat-2: #a29bee;
  --heat-3: #8172e6;
  --heat-4: #6350dd;
  color-scheme: light;
}

/* ---------------- base ---------------- */

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(139, 92, 246, 0.14), transparent 60%),
    radial-gradient(900px 420px at -10% 20%, rgba(56, 189, 248, 0.07), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 0.4em; line-height: 1.25; font-weight: 700; }
p { margin: 0 0 0.7em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: none;
}

::selection { background: var(--accent-soft); }

/* ---------------- layout ---------------- */

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  color: var(--text);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 92, 246, 0.45);
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 500;
  transition: background var(--speed) ease, color var(--speed) ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-link.active .nav-ico { color: var(--accent); }
.nav-ico { width: 19px; height: 19px; flex: none; }

.sidebar-foot { padding: 10px 12px 2px; }
.sidebar-foot-text { font-size: 12px; color: var(--text-faint); }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 20px; margin: 0; letter-spacing: -0.015em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform var(--speed) ease;
}
.pill:hover { text-decoration: none; transform: translateY(-1px); }
.pill b { color: var(--text); }
.pill-accent { background: var(--accent-soft); border-color: transparent; color: var(--text); }
.pill-flame { filter: grayscale(1); opacity: 0.75; }
.pill-flame.lit { filter: none; opacity: 1; }

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 3px 10px rgba(124, 92, 246, 0.4);
}

.view {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 28px 90px;
  outline: none;
}
.view-intro { margin-bottom: 14px; }

/* ---------------- generic components ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform var(--speed) ease, box-shadow var(--speed) ease,
    border-color var(--speed) ease;
}

.panel { padding: 20px 22px; margin-bottom: 18px; }
.panel-plain { margin-bottom: 18px; }
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 17px; margin: 0; }
.link-dim { font-size: 13px; color: var(--text-dim); }
.link-dim:hover { color: var(--accent); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  transition: transform var(--speed) ease, box-shadow var(--speed) ease,
    background var(--speed) ease, opacity var(--speed) ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 92, 246, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(124, 92, 246, 0.5); }
.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--text-dim);
  border: 1px solid transparent;
  transition: background var(--speed) ease, color var(--speed) ease,
    transform var(--speed) ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); }

#theme-btn { border: 1px solid var(--border); background: var(--surface); }
[data-theme="light"] .ico-moon { display: block; }
[data-theme="light"] .ico-sun { display: none; }
.ico-moon { display: none; }
.ico-sun { display: block; }

.input {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-faint); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-muted { background: var(--surface-2); color: var(--text-dim); }

.status { font-size: 12px; font-weight: 600; }
.status-completed { color: var(--green); }
.status-progress { color: var(--amber); }
.status-none { color: var(--text-faint); }
.status.big { font-size: 14px; padding: 8px 4px; }

.meta-dim { color: var(--text-dim); font-size: 13px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: all var(--speed) ease;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}
.chip-static { cursor: default; }
.chip-static:hover { transform: none; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip-diff.diff-beginner.active { background: var(--green-soft); border-color: var(--green); }
.chip-diff.diff-intermediate.active { background: var(--amber-soft); border-color: var(--amber); }
.chip-diff.diff-advanced.active { background: var(--red-soft); border-color: var(--red); }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--gradient);
  transition: width 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------------- toasts ---------------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 340px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 250ms ease, transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-error { border-color: var(--red); }

.toast-xp {
  background: var(--gradient);
  border: none;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(124, 92, 246, 0.55);
}
.toast-xp .xp-label { font-weight: 400; opacity: 0.9; font-size: 13px; }
.xp-sparkle { animation: sparkle 1.2s ease infinite; display: inline-block; }
@keyframes sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.35) rotate(12deg); }
}

/* ---------------- skeletons / empty / boot ---------------- */

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.sk-line { height: 13px; }
.w30 { width: 30%; } .w40 { width: 40%; } .w60 { width: 60%; } .w80 { width: 80%; }

.boot-loading { text-align: center; padding: 30px 0 20px; color: var(--text-dim); }
.boot-logo {
  font-size: 34px;
  animation: pulse 1.2s ease-in-out infinite;
  display: inline-block;
}
@keyframes pulse { 50% { transform: scale(1.2); opacity: 0.7; } }

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-dim);
}
.empty-state h3 { color: var(--text); font-size: 18px; }
.empty-state .btn { margin-top: 12px; }
.empty-icon { font-size: 42px; margin-bottom: 12px; }
.retry-screen { max-width: 420px; margin: 40px auto; }

/* ---------------- modal ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 7, 16, 0.66);
  backdrop-filter: blur(4px);
  animation: fadeIn 180ms ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: var(--shadow-lift);
  animation: popIn 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
body.modal-open { overflow: hidden; }

/* ---------------- dashboard ---------------- */

.greeting { font-size: 21px; margin-bottom: 16px; letter-spacing: -0.01em; }
.greeting b { font-weight: 700; }

.due-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent-soft), rgba(168, 85, 247, 0.12));
  border: 1px solid var(--accent);
  color: var(--text);
  transition: transform var(--speed) ease, box-shadow var(--speed) ease;
}
.due-banner:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.due-icon { font-size: 22px; }
.due-cta { margin-left: auto; font-weight: 700; color: var(--accent); white-space: nowrap; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi { display: flex; gap: 14px; align-items: center; padding: 18px; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kpi-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  font-size: 22px;
  border-radius: 12px;
  background: var(--surface-2);
}
.kpi-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.kpi-value { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-label { font-size: 12.5px; color: var(--text-dim); }
.kpi .progress-track { margin-top: 6px; }
.kpi-streak .flame { filter: grayscale(1); opacity: 0.6; }
.kpi-streak.lit .flame {
  filter: none;
  opacity: 1;
  background: var(--amber-soft);
  animation: flicker 1.6s ease-in-out infinite;
}
@keyframes flicker { 50% { transform: scale(1.08) rotate(-3deg); } }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(300px, 5fr) minmax(300px, 7fr);
  gap: 18px;
  align-items: stretch;
}
.dash-grid .panel { margin-bottom: 18px; }

.rings-row {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 12px;
  padding: 6px 0;
}
.goal-ring { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.ring-fg {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dasharray 600ms cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-value { fill: var(--text); font-size: 20px; font-weight: 800; }
.ring-sub { fill: var(--text-dim); font-size: 11px; }
.goal-ring-label {
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}
.goal-ring-label span { font-weight: 400; font-size: 12px; color: var(--text-dim); }

.heatmap {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}
.heat-cell {
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--heat-0);
  transition: transform var(--speed) ease;
  min-width: 14px;
}
.heat-cell:hover { transform: scale(1.15); }
.heat-cell.l1 { background: var(--heat-1); }
.heat-cell.l2 { background: var(--heat-2); }
.heat-cell.l3 { background: var(--heat-3); }
.heat-cell.l4 { background: var(--heat-4); }
.heat-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.heat-legend .heat-cell { width: 13px; min-width: 13px; height: 13px; flex: none; }
.heat-legend .heat-cell:hover { transform: none; }

.cat-bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 210px) 1fr 52px;
  align-items: center;
  gap: 14px;
  padding: 7px 0;
}
.cat-bar-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar-count { font-size: 12.5px; color: var(--text-dim); text-align: right; }

.continue-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px;
  margin-bottom: 18px;
  background:
    radial-gradient(500px 200px at 100% 0%, rgba(168, 85, 247, 0.15), transparent 60%),
    var(--surface);
}
.continue-card:hover { box-shadow: var(--shadow-lift); }
.continue-kicker {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}
.continue-info h2 { font-size: 19px; }
.continue-info p { color: var(--text-dim); max-width: 52ch; }

/* ---------------- topics ---------------- */

.filters-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.search-wrap { position: relative; max-width: 460px; }
.search-ico {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.search-input { padding-left: 40px; }

.topic-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  cursor: pointer;
}
.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--border-strong);
}
.topic-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.topic-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  font-size: 21px;
  border-radius: 11px;
  background: var(--surface-2);
}
.topic-card-title { font-size: 15.5px; margin: 0; }
.topic-card-title a { color: var(--text); }
.topic-card-title a:hover { color: var(--accent); text-decoration: none; }
.topic-card-summary {
  color: var(--text-dim);
  font-size: 13.5px;
  margin: 0;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}
.bookmark-btn.active { color: var(--amber); }
.bookmark-btn:hover { color: var(--amber); }

/* ---------------- topic detail ---------------- */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.crumb-current { color: var(--text); font-weight: 600; }

.topic-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  padding: 22px 24px;
  margin-bottom: 18px;
}
.topic-header h2 { font-size: 22px; letter-spacing: -0.015em; }
.topic-summary { color: var(--text-dim); max-width: 62ch; }
.action-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.prose { max-width: 72ch; }
.prose h2 { font-size: 18px; margin-top: 1.2em; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 15.5px; margin-top: 1em; }
.prose p { margin-bottom: 0.85em; }
.prose ul { margin: 0 0 0.9em; padding-left: 22px; }
.prose li { margin-bottom: 0.3em; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}

.key-concepts { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.kc-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-btn {
  padding: 9px 15px;
  border-radius: 9px 9px 0 0;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition: color var(--speed) ease, border-color var(--speed) ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count {
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  margin-left: 2px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp 200ms ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

.link-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.link-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 36px 14px 16px;
  color: var(--text);
}
.link-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--accent);
}
.link-card-title { font-weight: 600; font-size: 14px; }
.link-card-sub { font-size: 12.5px; color: var(--text-dim); }
.link-card-ext {
  position: absolute;
  top: 12px;
  right: 13px;
  color: var(--text-faint);
  font-size: 14px;
  transition: color var(--speed) ease, transform var(--speed) ease;
}
.link-card:hover .link-card-ext { color: var(--accent); transform: translate(2px, -2px); }

.notes-ta { resize: vertical; min-height: 110px; font-family: inherit; }
.notes-ind { font-size: 12.5px; }
.notes-ind.saving { color: var(--amber); }
.notes-ind.saved { color: var(--green); }
.notes-ind.error { color: var(--red); }

.comments-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comment {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.comment p { margin: 0 0 3px; }
.comment-date { font-size: 12px; }
.comment-del { flex: none; width: 30px; height: 30px; font-size: 14px; }
.comment-del:hover { color: var(--red); background: var(--red-soft); }
.comment-form { display: flex; gap: 10px; }
.comments-empty { padding: 4px 0; }

/* ---------------- quiz ---------------- */

.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.quiz-progress { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.quiz-track { margin-bottom: 18px; }
.quiz-q { font-size: 18px; margin-bottom: 16px; }
.quiz-options { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.quiz-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14.5px;
  transition: all var(--speed) ease;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); transform: translateX(3px); }
.quiz-opt:disabled { cursor: default; opacity: 0.85; }
.opt-key {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
.quiz-opt.correct { border-color: var(--green); background: var(--green-soft); opacity: 1; }
.quiz-opt.correct .opt-key { background: var(--green); color: #fff; }
.quiz-opt.wrong { border-color: var(--red); background: var(--red-soft); animation: shake 300ms ease; }
.quiz-opt.wrong .opt-key { background: var(--red); color: #fff; }
@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.quiz-feedback {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 14px;
  animation: fadeUp 200ms ease;
}
.quiz-feedback.ok { background: var(--green-soft); border: 1px solid var(--green); }
.quiz-feedback.bad { background: var(--red-soft); border: 1px solid var(--red); }
.quiz-foot { display: flex; justify-content: flex-end; }

.quiz-results { text-align: center; padding: 10px 4px; }
.quiz-results-emoji { font-size: 46px; margin-bottom: 8px; animation: pop 400ms cubic-bezier(0.22, 1.4, 0.36, 1); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }
.quiz-results h3 { font-size: 22px; }
.quiz-results p { color: var(--text-dim); }
.quiz-results-btns { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

/* ---------------- roadmap ---------------- */

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(var(--accent), var(--accent-2));
  opacity: 0.4;
}
.timeline-item { position: relative; margin-bottom: 22px; }
.timeline-marker {
  position: absolute;
  left: -26px;
  top: 18px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 800;
  font-size: 14px;
  z-index: 1;
}
.timeline-item.is-complete .timeline-marker {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}
.phase-card { padding: 22px 24px; margin-left: 24px; }
.phase-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}
.phase-weeks {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}
.phase-head h2 { font-size: 18px; margin-bottom: 4px; }
.phase-desc { color: var(--text-dim); max-width: 64ch; }
.phase-progress { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; }
.phase-progress .progress-track { flex: 1; }
.phase-topics { list-style: none; margin: 0; padding: 0; }
.phase-topic {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 4px;
  border-bottom: 1px dashed var(--border);
}
.phase-topic:last-child { border-bottom: none; }
.phase-topic a { color: var(--text); flex: 1; }
.phase-topic a:hover { color: var(--accent); text-decoration: none; }
.phase-topic.is-done a { color: var(--text-dim); text-decoration: line-through; }
.check {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  flex: none;
  border-radius: 7px;
  border: 1.5px solid var(--border-strong);
  font-size: 12px;
  color: transparent;
}
.check.done { background: var(--green); border-color: var(--green); color: #fff; }
.check.half { border-color: var(--amber); color: var(--amber); }
.milestones { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.milestones h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); }
.milestones ul { list-style: none; margin: 0; padding: 0; }
.milestones li { padding: 3px 0; font-size: 14px; }
.cert-btn { flex: none; }

/* ---------------- certificate ---------------- */

.cert-page { max-width: 820px; margin: 0 auto; }
.cert-actions { display: flex; justify-content: space-between; margin-bottom: 20px; }
.certificate {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 6px;
  padding: 12px;
  box-shadow: var(--shadow-lift);
}
.cert-inner {
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  text-align: center;
  padding: 48px 40px 40px;
  background:
    radial-gradient(400px 160px at 50% 0%, var(--accent-soft), transparent 70%);
}
.cert-seal { font-size: 44px; margin-bottom: 10px; }
.cert-brand {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-dim);
}
.cert-title {
  font-size: 30px;
  letter-spacing: -0.01em;
  margin: 6px 0 22px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.cert-line { color: var(--text-dim); margin-bottom: 4px; }
.cert-name {
  font-size: 30px;
  font-weight: 800;
  margin: 6px 0 14px;
  border-bottom: 1px solid var(--border-strong);
  display: inline-block;
  padding: 0 30px 8px;
}
.cert-phase { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.cert-weeks { color: var(--text-dim); font-size: 13px; }
.cert-footer {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  margin-top: 46px;
  font-size: 13px;
  color: var(--text-dim);
}
.cert-sig, .cert-date { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.cert-sig-line { display: block; width: 100%; max-width: 200px; border-top: 1px solid var(--border-strong); }

/* ---------------- glossary ---------------- */

.glossary-view .filters-bar { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.glossary-view .search-wrap { flex: 1; min-width: 220px; }
.term-group { margin-bottom: 22px; }
.term-letter {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.term-card { margin-bottom: 8px; overflow: hidden; }
.term-card summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
.term-card summary::-webkit-details-marker { display: none; }
.term-card summary:hover { background: var(--surface-2); }
.term-name { flex: 1; }
.term-caret { color: var(--text-faint); transition: transform var(--speed) ease; }
.term-card[open] .term-caret { transform: rotate(180deg); }
.term-body { padding: 2px 16px 14px; color: var(--text-dim); animation: fadeUp 180ms ease; }
.term-body p { margin-bottom: 6px; }
.term-example { font-size: 13.5px; border-left: 3px solid var(--accent); padding-left: 12px; }

/* flashcards */

.review-session { max-width: 560px; margin: 0 auto; }
.review-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.review-track { margin-bottom: 26px; }
.review-loading { text-align: center; padding: 60px 0; }

.flip-scene { perspective: 1200px; margin-bottom: 22px; }
.flip-card {
  position: relative;
  width: 100%;
  min-height: 300px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: block;
}
.flip-inner {
  position: relative;
  width: 100%;
  min-height: 300px;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px;
  border-radius: 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lift);
  text-align: center;
}
.flip-front {
  background:
    radial-gradient(400px 200px at 50% 0%, var(--accent-soft), transparent 70%),
    var(--surface);
}
.flip-back { background: var(--surface); transform: rotateY(180deg); }
.flip-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.flip-term { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.flip-def { font-size: 15.5px; margin: 0; }
.flip-example { font-size: 13.5px; color: var(--text-dim); margin: 0; font-style: italic; }
.flip-hint { font-size: 12.5px; }

.rate-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; animation: fadeUp 200ms ease; }
.rate-btn { border: 1px solid var(--border); font-weight: 700; }
.rate-again { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.rate-hard { background: var(--amber-soft); color: var(--amber); border-color: var(--amber); }
.rate-good { background: var(--blue-soft); color: var(--blue); border-color: var(--blue); }
.rate-easy { background: var(--green-soft); color: var(--green); border-color: var(--green); }

.review-summary { text-align: center; max-width: 480px; margin: 30px auto; padding: 40px 30px; }
.summary-stats { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------------- workbooks / projects ---------------- */

.wb-list { display: flex; flex-direction: column; gap: 14px; }
.wb-card { overflow: hidden; }
.wb-card summary {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 22px 24px;
  cursor: pointer;
  list-style: none;
}
.wb-card summary::-webkit-details-marker { display: none; }
.wb-card summary:hover { background: var(--surface-2); }
.wb-sum-main { flex: 1; min-width: 220px; }
.wb-sum-main h2 { font-size: 16.5px; margin-bottom: 3px; }
.wb-sum-main p { margin: 0; }
.wb-sum-side { display: flex; align-items: center; gap: 12px; }
.wb-track { position: absolute; left: 22px; right: 22px; bottom: 10px; height: 5px; }
.wb-detail { padding: 6px 22px 20px; border-top: 1px solid var(--border); animation: fadeUp 200ms ease; }
.wb-section h3, .pj-skills h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 16px 0 8px;
}
.task-list { list-style: none; margin: 0; padding: 0; }
.task {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 7px 0;
}
.task input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  flex: none;
  margin: 2px 0 0;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--speed) ease;
}
.task input[type="checkbox"]:checked {
  background: var(--gradient);
  border-color: transparent;
}
.task input[type="checkbox"]:checked::after {
  content: "✓";
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.task label { cursor: pointer; }
.task.is-done label { color: var(--text-dim); text-decoration: line-through; }
.step-num { color: var(--accent); margin-right: 2px; }
.pj-skills { margin-bottom: 4px; }

/* ---------------- settings ---------------- */

.settings-view { max-width: 640px; }
.settings-form .field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field-row { display: flex; gap: 10px; margin-bottom: 8px; }
.goals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 12px;
}
.theme-row { display: flex; gap: 12px; }
.theme-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
  transition: all var(--speed) ease;
}
.theme-opt:hover { transform: translateY(-1px); }
.theme-opt.active { border-color: var(--accent); background: var(--accent-soft); }
.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
}
.swatch-dark { background: linear-gradient(135deg, #0b0f1a 50%, #6366f1 50%); }
.swatch-light { background: linear-gradient(135deg, #ffffff 50%, #6366f1 50%); }

/* ---------------- responsive ---------------- */

@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    inset: auto 0 0 0;
    width: 100%;
    height: 62px;
    flex-direction: row;
    align-items: center;
    padding: 0 6px;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .brand, .sidebar-foot { display: none; }
  .nav {
    flex-direction: row;
    width: 100%;
    overflow-x: auto;
    gap: 0;
    justify-content: space-around;
    -webkit-overflow-scrolling: touch;
  }
  .nav-link {
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    font-size: 10.5px;
    border-radius: 10px;
    flex: none;
  }
  .nav-link.active { box-shadow: none; }
  .main { margin-left: 0; }
  .view { padding: 18px 16px 110px; }
  .topbar { padding: 12px 16px; }
  .page-title { font-size: 17px; }
  #streak-pill { display: none; }
  .continue-card { flex-direction: column; align-items: flex-start; }
  .cat-bar-row { grid-template-columns: 1fr; gap: 5px; }
  .cat-bar-count { text-align: left; }
  .heatmap { grid-template-columns: repeat(10, 1fr); }
  .comment-form { flex-direction: column; }
  .goals-grid { grid-template-columns: 1fr; }
  .rate-row { grid-template-columns: repeat(2, 1fr); }
  .cert-inner { padding: 30px 18px; }
  .cert-title { font-size: 23px; }
  .cert-name { font-size: 23px; }
  .cert-footer { flex-direction: column; gap: 22px; }
  .timeline { padding-left: 18px; }
  .phase-card { margin-left: 14px; }
  .wb-track { bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------- print (certificate) ---------------- */

@media print {
  body { background: #fff !important; }
  .sidebar, .topbar, .toasts, .cert-actions, .no-print,
  .preview-banner-slot { display: none !important; }
  .main { margin: 0 !important; }
  .view { padding: 0 !important; max-width: none !important; }
  .certificate {
    border-color: #6366f1;
    box-shadow: none;
    background: #fff;
    color: #1b2237;
  }
  .cert-inner { background: #fff; }
  .cert-title { -webkit-text-fill-color: #6366f1; color: #6366f1; }
  .cert-name, .cert-phase { color: #1b2237; }
  .cert-line, .cert-brand, .cert-weeks, .cert-footer { color: #5a6480; }
}

/* ============================================================
   VIDEO PLAYER — inline YouTube embeds with resume + watch history
   (player cards in topic resources, "Continue watching" on dashboard)
   ============================================================ */

/* ---- topic view: player cards ---- */

.video-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.video-extra-links { margin-top: 12px; }

.video-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.video-card:hover { box-shadow: var(--shadow-lift); border-color: var(--border-strong); }

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.video-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  padding: 0;
  overflow: hidden;
}
.video-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.92;
  transition: transform var(--speed) ease, opacity var(--speed) ease;
}
.video-thumb:hover .video-thumb-img { transform: scale(1.04); opacity: 1; }

.video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  transition: transform var(--speed) ease, box-shadow var(--speed) ease;
}
.video-play-btn svg { margin-left: 3px; }
.video-thumb:hover .video-play-btn {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 8px 26px rgba(99, 102, 241, 0.65);
}

/* resume / watched chips overlaid on the thumbnail */
.video-chips {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
}
.video-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(11, 15, 26, 0.72);
  backdrop-filter: blur(4px);
}
.video-chip-done { color: var(--green); }

/* slim watched-timeline bar under the frame */
.video-timeline {
  height: 4px;
  background: var(--surface-3);
  overflow: hidden;
  flex: none;
}
.video-timeline-fill {
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: var(--gradient);
  transition: width 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.video-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
}
.video-title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.video-channel { font-size: 12.5px; }

/* embedded IFrame player fills the frame */
.video-embed,
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* loading spinner while the IFrame API boots */
.video-frame.video-loading .video-play-btn { visibility: hidden; }
.video-frame.video-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: video-spin 0.8s linear infinite;
}
@keyframes video-spin { to { transform: rotate(360deg); } }

/* fallback when the IFrame API cannot load (offline / blocked) */
.video-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 34px 16px 16px;
  color: var(--text);
  font-size: 13.5px;
  background: var(--surface-2);
}
.video-fallback:hover { text-decoration: none; background: var(--surface-3); }
.video-fallback-icon { font-size: 20px; color: var(--accent); }
.video-fallback-text { display: flex; flex-direction: column; gap: 1px; }
.video-fallback-text .meta-dim { font-size: 12px; }

/* ---- dashboard: "Continue watching" cards ---- */

.watch-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.watch-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
}
.watch-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--accent);
}

.watch-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #000;
}
.watch-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* progress bar overlaid on the bottom edge of the thumbnail */
.watch-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  display: block;
  background: rgba(255, 255, 255, 0.28);
}
.watch-bar-fill {
  display: block;
  height: 100%;
  background: var(--gradient);
}

.watch-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 13px;
}
.watch-title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.watch-topic { font-size: 12.5px; }

/* ============================================================
   VIDEO THEATER — large overlay player (opens on tile click)
   ============================================================ */
.video-theater { position: fixed; inset: 0; z-index: 220; display: none; }
.video-theater.open { display: block; }
body.vt-open { overflow: hidden; }

.vt-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 6, 14, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: vtFade var(--speed) ease;
}

.vt-panel {
  position: relative;
  margin: 4vh auto 0;
  width: min(1150px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 14px 14px 16px;
  animation: vtUp 220ms ease;
}

.vt-close {
  position: absolute; top: 22px; right: 22px; z-index: 5;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(8, 11, 22, 0.6);
  color: #fff;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--speed), transform var(--speed);
}
.vt-close:hover { background: rgba(8, 11, 22, 0.9); transform: scale(1.06); }

.vt-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.vt-stage .video-embed,
.vt-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vt-stage.video-loading::after {
  content: "";
  position: absolute; top: 50%; left: 50%;
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: vtSpin 0.8s linear infinite;
}
.vt-stage .video-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

.vt-meta {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 12px;
  padding: 12px 4px 0;
}
.vt-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.vt-titles .video-title { font-size: 15.5px; font-weight: 650; }
.vt-meta .video-timeline { flex-basis: 100%; margin-top: 4px; }

.vt-strip { padding: 12px 4px 0; }
.vt-strip-label {
  display: block;
  font-size: 12px; font-weight: 650;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.vt-strip-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.vt-tile {
  flex: 0 0 190px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  padding: 0 0 9px;
  color: var(--text);
  transition: border-color var(--speed), transform var(--speed);
}
.vt-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.vt-tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.vt-tile img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.vt-tile-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px; line-height: 1.35;
  padding: 8px 10px 0;
}

@keyframes vtFade { from { opacity: 0; } }
@keyframes vtUp { from { opacity: 0; transform: translateY(16px); } }
@keyframes vtSpin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .vt-panel {
    margin: 0; width: 100%;
    max-height: 100vh; max-height: 100dvh;
    height: 100vh; height: 100dvh;
    border-radius: 0; border: 0;
  }
  .vt-close { top: 12px; right: 12px; }
}

/* ============================================================
   Learning hours (curriculum stats)
   ============================================================ */

.chip-hours {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 2px;
}
.chip.active .chip-hours { color: var(--text-dim); background: var(--surface-3); }

.roadmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 22px;
  margin-bottom: 22px;
}
.roadmap-header h2 { margin: 2px 0 4px; font-size: 20px; }
.roadmap-header p { margin: 0; }
.roadmap-header-stats { display: flex; gap: 8px; flex-wrap: wrap; }

.phase-hours { display: block; font-size: 12.5px; margin-top: 2px; }

/* ============================================================
   Ask the Instructor
   ============================================================ */

.instructor-panel { position: relative; }
.instructor-panel .panel-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.instructor-head-ico {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gradient);
  color: #fff;
  flex: none;
}

.chat-levels { margin-bottom: 6px; }
.chat-level-hint { font-size: 12.5px; margin: 0 0 12px; }

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 2px 10px;
  scroll-behavior: smooth;
}

.chat-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 6px;
  font-size: 14px;
}
.chat-empty-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}

.chat-msg { display: flex; gap: 10px; max-width: 92%; }
.chat-msg-user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-assistant { align-self: flex-start; }

.chat-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  flex: none;
  margin-top: 2px;
  box-shadow: 0 3px 10px rgba(124, 92, 246, 0.35);
}

.chat-bubble-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chat-msg-user .chat-bubble-wrap { align-items: flex-end; }

.chat-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.chat-bubble > :first-child { margin-top: 0; }
.chat-bubble > :last-child, .chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble h2, .chat-bubble h3 { font-size: 14.5px; margin: 0.6em 0 0.3em; }
.chat-bubble ul { margin: 0.3em 0; padding-left: 20px; }
.chat-bubble code {
  background: var(--surface-3);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12.5px;
}

.chat-msg-user .chat-bubble {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-assistant .chat-bubble { border-bottom-left-radius: 4px; }

.chat-msg-meta {
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}
.chat-offline-badge { font-size: 10.5px; padding: 1px 7px; text-transform: uppercase; letter-spacing: 0.04em; }

/* typing indicator */
.typing-dots { display: inline-flex; gap: 4px; padding: 3px 2px; }
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: chat-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* composer */
.chat-composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 160px;
  line-height: 1.45;
}
.chat-send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  flex: none;
}

/* floating chat button (topic pages) */
.chat-fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--gradient);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(124, 92, 246, 0.5);
  transition: transform var(--speed) ease, box-shadow var(--speed) ease;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(124, 92, 246, 0.6); }
.chat-fab svg { width: 18px; height: 18px; }

.chat-clear-confirm h3 { margin-bottom: 6px; }
.chat-clear-confirm .quiz-results-btns { margin-top: 16px; }

@media (max-width: 640px) {
  .chat-fab-label { display: none; }
  .chat-fab { padding: 14px; }
  .chat-msg { max-width: 100%; }
}

/* ============================================================
   Tracks (SPEC-V2 §2) — filter chips, badges, switchers
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.nav-tag {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--gradient);
}

/* small track pill on a topic card */
.track-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.track-badge-engineering { color: var(--blue); background: var(--blue-soft); border-color: transparent; }
.track-badge-business { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.track-badge-prompt { color: var(--accent-2); background: var(--accent-soft); border-color: transparent; }

.topic-card-top { align-items: center; }

/* track filter row above the category chips */
.track-filter-row {
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.track-chips { margin-bottom: 6px; }
.track-filter-note { margin: 0; font-size: 12.5px; }

.chip-count {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--surface-3);
}
.chip.active .chip-count { color: var(--text); background: color-mix(in srgb, var(--accent) 24%, transparent); }

.track-chip-engineering.active { background: var(--blue-soft); border-color: var(--blue); }
.track-chip-business.active { background: var(--amber-soft); border-color: var(--amber); }
.track-chip-prompt.active { background: var(--accent-soft); border-color: var(--accent-2); }

/* compact switcher (roadmap header) */
.track-switch-bar { padding: 12px 16px; margin-bottom: 18px; }
.track-switcher { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.track-switcher-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-right: 2px;
}
.track-pill-mine {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
  background: var(--green-soft);
}

/* dashboard "your track" chip */
.dash-track-row { margin: -4px 0 16px; align-items: center; }
.track-chip-mine {
  gap: 8px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 7px 8px 7px 14px;
}
.track-chip-mine:hover { text-decoration: none; border-color: var(--accent); }
.track-chip-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.track-chip-edit {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}
.track-chip-empty { border-style: dashed; }
.track-chip-lab { color: var(--text); font-weight: 600; }
.track-chip-lab:hover { text-decoration: none; border-color: var(--accent-2); }

/* roadmap phase groups */
.phase-groups { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.phase-group { position: relative; padding-left: 12px; border-left: 2px solid var(--border); }
.phase-group-core { border-left-color: var(--accent); }
.phase-group-engineering { border-left-color: var(--blue); }
.phase-group-business { border-left-color: var(--amber); }
.phase-group-prompt { border-left-color: var(--accent-2); }
.phase-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.phase-group-icon { font-size: 14px; text-transform: none; }
.phase-group-hint {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  background: var(--surface-2);
}
.phase-group-meta { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.phase-groups .phase-topics { margin: 0; }

/* category sub-headings inside a phase group (only the ones the track covers) */
.phase-cat + .phase-cat { margin-top: 10px; }
.phase-cat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
}
.phase-cat-name { color: var(--text-dim); }
.phase-cat-meta { margin-left: auto; font-weight: 500; }

/* settings: opt-in switch */
.opt-in-row { display: flex; align-items: center; gap: 14px; padding: 6px 0 10px; }
.opt-in-icon { font-size: 26px; line-height: 1; }
.opt-in-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.opt-in-title { font-weight: 700; }
.opt-in-sub { font-size: 13px; }

.switch {
  flex: none;
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background var(--speed) ease, border-color var(--speed) ease;
}
.switch.on { background: var(--gradient); border-color: transparent; }
.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform var(--speed) cubic-bezier(0.22, 1, 0.36, 1);
}
.switch.on .switch-knob { transform: translateX(22px); }

/* ============================================================
   Prompt Lab (SPEC-V3 §7)
   ============================================================ */

.promptlab { max-width: 1080px; }

.pl-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  margin-bottom: 18px;
}
.pl-header-main h2 { margin: 2px 0 4px; font-size: 21px; letter-spacing: -0.01em; }
.pl-header-main p { margin: 0; max-width: 62ch; }
.pl-header-side { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.pl-spark { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.pl-spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pl-spark-dot { fill: var(--accent-2); stroke: var(--surface); stroke-width: 1.5; }
.pl-spark-label { font-size: 11px; }

/* --- exercise picker --- */
.pl-picker .panel-head { margin-bottom: 12px; }
.pl-ex-grid { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }

.pl-ex-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  text-align: left;
  border: 1px solid var(--border);
  transition: transform var(--speed) ease, border-color var(--speed) ease, box-shadow var(--speed) ease;
}
.pl-ex-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-lift); }
.pl-ex-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pl-ex-top .track-badge { margin-left: 0; margin-right: 0; }
.pl-ex-title { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.pl-ex-scenario {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pl-ex-cta { margin-top: auto; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.pl-ex-free { border-style: dashed; }

.pl-best-badge {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-3);
}
.pl-best-badge.pl-band-expert { color: var(--green); background: var(--green-soft); }
.pl-best-badge.pl-band-strong { color: var(--blue); background: var(--blue-soft); }
.pl-best-badge.pl-band-developing { color: var(--amber); background: var(--amber-soft); }
.pl-best-badge.pl-band-basic { color: var(--red); background: var(--red-soft); }

.pl-warming .empty-state { padding: 34px 20px; }
.pl-warm-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* --- composer --- */
.pl-composer-head { margin-bottom: 12px; }

.pl-brief {
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}
.pl-brief-free { border-left-color: var(--blue); }
.pl-brief-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.pl-brief-top .track-badge { margin-left: 0; margin-right: 0; }
.pl-brief h3 { margin: 0 0 4px; font-size: 16px; }
.pl-brief-scenario { margin: 0; font-size: 14px; color: var(--text-dim); }

.pl-hints { margin-top: 10px; }
.pl-hints summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
.pl-hints summary::-webkit-details-marker { display: none; }
.pl-hints summary:hover { text-decoration: underline; }
.pl-hints ul { margin: 8px 0 0; padding-left: 20px; font-size: 13px; color: var(--text-dim); }
.pl-hints li { margin-bottom: 4px; }

.pl-textarea {
  min-height: 190px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
}
.pl-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.pl-wordcount b { color: var(--text); font-size: 15px; }

.pl-inline-error {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--amber);
  background: var(--amber-soft);
}

/* --- score dial --- */
.pl-score-row {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 24px;
  align-items: start;
}
.pl-dial-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pl-dial { overflow: visible; }
.pl-dial-bg { fill: none; stroke: var(--surface-3); stroke-width: 12; }
.pl-dial-fg {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(124, 92, 246, 0.45));
}
.pl-dial-value {
  fill: var(--text);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.pl-dial-unit { fill: var(--text-faint); font-size: 12px; font-weight: 600; }

.pl-band-label {
  padding: 4px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pl-band-expert .pl-band-label { color: var(--green); background: var(--green-soft); }
.pl-band-strong .pl-band-label { color: var(--blue); background: var(--blue-soft); }
.pl-band-developing .pl-band-label { color: var(--amber); background: var(--amber-soft); }
.pl-band-basic .pl-band-label { color: var(--red); background: var(--red-soft); }

/* --- dimension bars --- */
.pl-dims { display: flex; flex-direction: column; gap: 8px; }

.pl-dim {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color var(--speed) ease;
}
.pl-dim[open] { border-color: var(--border-strong); }
.pl-dim-head {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(80px, 2fr) 62px 16px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}
.pl-dim-head::-webkit-details-marker { display: none; }
.pl-dim-head:hover { background: var(--surface-3); }
.pl-dim-name { font-size: 13.5px; font-weight: 600; }
.pl-dim-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.pl-dim-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--gradient);
  transition: width 700ms cubic-bezier(0.22, 1, 0.36, 1);
}
.pl-dim-good .pl-dim-fill { background: linear-gradient(90deg, var(--accent), var(--green)); }
.pl-dim-mid .pl-dim-fill { background: linear-gradient(90deg, var(--accent), var(--amber)); }
.pl-dim-low .pl-dim-fill { background: linear-gradient(90deg, var(--accent), var(--red)); }
.pl-dim-score { font-size: 14px; font-weight: 800; text-align: right; }
.pl-dim-score .meta-dim { font-size: 12px; font-weight: 600; }
.pl-dim-caret { color: var(--text-faint); font-size: 12px; transition: transform var(--speed) ease; }
.pl-dim[open] .pl-dim-caret { transform: rotate(180deg); }

.pl-dim-body {
  padding: 4px 14px 14px;
  border-top: 1px solid var(--border);
  animation: fadeUp 180ms ease;
}
.pl-chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.pl-chip-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-right: 2px;
}
.pl-chip {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.pl-chip-found { color: var(--green); background: var(--green-soft); }
.pl-chip-missing { color: var(--red); background: var(--red-soft); }
.pl-tip {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--accent-soft);
}

.pl-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* --- improved prompt + diff --- */
.pl-improved { border-color: var(--accent); }
.pl-diff-legend { display: flex; gap: 10px; font-size: 12px; font-weight: 700; }
.pl-legend-ins { color: var(--green); }
.pl-legend-del { color: var(--red); }

.pl-diff {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 460px;
  overflow: auto;
}
.pl-diff ins {
  text-decoration: none;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25) inset;
  padding: 1px 0;
}
.pl-diff del {
  text-decoration: line-through;
  text-decoration-color: rgba(239, 68, 68, 0.7);
  color: var(--red);
  background: var(--red-soft);
  border-radius: 3px;
  opacity: 0.85;
  padding: 1px 0;
}

.pl-improved-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.pl-improvements { margin-top: 20px; }
.pl-improvements h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.pl-improvements ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 14px; }
.pl-improvement-dim {
  display: inline-block;
  padding: 2px 10px;
  margin-bottom: 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-soft);
}
.pl-improvement-pair {
  display: grid;
  grid-template-columns: 1fr 20px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.pl-before, .pl-after {
  display: block;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.pl-before { color: var(--text-dim); border-left: 3px solid var(--red); }
.pl-after { color: var(--text); border-left: 3px solid var(--green); }
.pl-ba-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 2px;
}
.pl-arrow { text-align: center; color: var(--accent); font-weight: 800; }
.pl-improvement-why { margin: 6px 0 0; font-size: 12.5px; }

/* --- side-by-side comparison --- */
.pl-delta-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), rgba(168, 85, 247, 0.08));
  border: 1px solid var(--accent);
  font-size: 14px;
}
.pl-delta-icon { font-size: 18px; }
.pl-delta-text { flex: 1; min-width: 220px; }
.pl-delta-text b { color: var(--accent-2); }
.pl-delta-score {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--surface-2);
}

.pl-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.pl-answer {
  padding: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.pl-answer-basic { border-left: 4px solid var(--border-strong); opacity: 0.92; }
.pl-answer-improved {
  border-left: 4px solid var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow);
}
.pl-answer-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.pl-answer-tag { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.pl-answer-improved .pl-answer-tag { color: var(--accent); }
.pl-answer-body {
  padding: 14px 16px;
  font-size: 14px;
  max-height: 520px;
  overflow: auto;
}
.pl-answer-body h2, .pl-answer-body h3 { font-size: 15px; margin: 0.9em 0 0.35em; }
.pl-answer-body > :first-child { margin-top: 0; }
.pl-answer-body ul { padding-left: 20px; margin: 0.4em 0; }
.pl-answer-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  font-size: 12.5px;
}

@media (max-width: 900px) {
  .pl-score-row { grid-template-columns: 1fr; justify-items: center; }
  .pl-dims { width: 100%; }
  .pl-compare-grid { grid-template-columns: 1fr; }
  .pl-improvement-pair { grid-template-columns: 1fr; }
  .pl-arrow { transform: rotate(90deg); }
  .pl-dim-head { grid-template-columns: 1fr 56px 16px; }
  .pl-dim-bar { grid-column: 1 / -1; order: 3; }
}

/* ============================================================
   Access codes & preview mode (SPEC-V4)
   ============================================================ */

/* ---------------- preview banner ---------------- */

/* The slot is always in the DOM and collapses to nothing when empty, so
   showing/hiding the banner never reflows the topbar or the view. */
.preview-banner-slot { position: relative; z-index: 25; }
.preview-banner-slot[hidden] { display: none; }

.preview-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 28px;
  color: #fff;
  background: var(--gradient);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 6px 20px rgba(124, 92, 246, 0.22);
  animation: previewSlide 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes previewSlide { from { opacity: 0; transform: translateY(-6px); } }

.preview-banner-badge {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  white-space: nowrap;
}
.preview-banner-text {
  flex: 1;
  margin: 0;
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.45;
}
.preview-banner .btn.preview-banner-cta {
  flex: none;
  background: #fff;
  color: #4c3ad6;
  box-shadow: 0 3px 10px rgba(8, 10, 30, 0.22);
}
.preview-banner .btn.preview-banner-cta:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(8, 10, 30, 0.3);
}
.preview-banner-close {
  flex: none;
  width: 28px;
  height: 28px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}
.preview-banner-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* ---------------- lock chip + muted cards ---------------- */

.lock-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  white-space: nowrap;
}

.topic-card-locked { border-style: dashed; }
.topic-card-locked .topic-card-title a,
.topic-card-locked .topic-card-summary { color: var(--text-dim); }
.topic-card-locked .topic-icon,
.topic-card-locked .badge,
.topic-card-locked .status { opacity: 0.6; }
.topic-card-locked:hover { border-color: var(--accent); border-style: solid; }

.phase-topic-locked a { color: var(--text-dim); }
.phase-topic-locked a:hover { color: var(--accent); }
.check-locked {
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  opacity: 0.75;
}

.term-card-locked summary .term-name { color: var(--text-dim); }
.term-locked { margin: 0; font-size: 13.5px; }
.link-btn {
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
}

/* ---------------- locked card (compact + full) ---------------- */

.locked-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  border-style: dashed;
  background:
    linear-gradient(135deg, var(--accent-soft), transparent 62%),
    var(--surface);
}
.locked-card-icon { font-size: 26px; flex: none; line-height: 1; }
.locked-card-body { flex: 1; min-width: 0; }
.locked-card-body h3 { font-size: 15.5px; margin: 0 0 3px; }
.locked-card-body p { margin: 0; font-size: 13.5px; color: var(--text-dim); }
.locked-card .btn { flex: none; }

/* Full-lesson stand-in on the topic detail view. */
.unlock-lesson {
  text-align: center;
  border-style: dashed;
  background:
    radial-gradient(600px 220px at 50% -30%, var(--accent-soft), transparent 70%),
    var(--surface);
  padding: 34px 24px;
}
.unlock-lesson-icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 12px;
  border-radius: 14px;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 6px 18px rgba(124, 92, 246, 0.4);
}
.unlock-lesson h2 { font-size: 19px; }
.unlock-lesson-pitch {
  max-width: 52ch;
  margin: 0 auto 16px;
  color: var(--text-dim);
}
.unlock-lesson-note { margin: 12px 0 0; font-size: 12.5px; }
.topic-locked-head { margin-bottom: 8px; }
.topic-detail-locked .topic-summary { color: var(--text-dim); }
.continue-card-locked { border-style: dashed; }

/* ---------------- redeem form (modal + full page) ---------------- */

.redeem-modal { position: relative; }
.redeem-close { position: absolute; top: -6px; right: -6px; }

.redeem-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.redeem-head h2 { font-size: 20px; margin: 0 0 4px; }
.redeem-head h3 { font-size: 17px; margin: 0 0 3px; }
.redeem-head p { margin: 0; font-size: 13.5px; }
.redeem-lock {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 5px 16px rgba(124, 92, 246, 0.4);
}

.redeem-perks {
  list-style: none;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
}
.redeem-perks li { display: flex; align-items: flex-start; gap: 9px; }
.redeem-perks span { flex: none; }

.redeem-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.redeem-input {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-align: center;
  padding: 13px 14px;
}
.redeem-input::placeholder { letter-spacing: 0.14em; font-weight: 500; }
.input-error, .input-error:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.redeem-msg { margin: 8px 0 0; min-height: 20px; font-size: 13px; color: var(--text-dim); }
.redeem-msg-error { color: var(--red); font-weight: 600; }
.redeem-msg-hint { color: var(--amber); }
.redeem-msg-info { color: var(--text-dim); }

.redeem-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.redeem-submit.is-loading { opacity: 0.75; }
.redeem-help { margin: 14px 0 0; font-size: 12.5px; }
.redeem-help code {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-3);
  font-size: 12px;
}

.redeem-page { max-width: 560px; margin: 24px auto; }
.redeem-page .redeem-body { padding: 26px 26px 22px; }

.redeem-success { text-align: center; padding: 18px 6px 6px; }
.redeem-success-mark {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  border-radius: 50%;
  font-size: 27px;
  font-weight: 700;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 6px 20px rgba(124, 92, 246, 0.45);
  animation: popIn 300ms cubic-bezier(0.22, 1, 0.36, 1);
}
.redeem-success h3 { font-size: 19px; }
.redeem-success-sub { font-size: 12.5px; margin-bottom: 0; }

@media (max-width: 720px) {
  .preview-banner { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .preview-banner-text { flex: 1 1 100%; order: 3; font-size: 12.5px; }
  .preview-banner-close { order: 2; margin-left: auto; }
  .locked-card { flex-direction: column; align-items: flex-start; }
  .redeem-actions { flex-direction: column-reverse; }
  .redeem-actions .btn { width: 100%; }
  .redeem-input { font-size: 17px; letter-spacing: 0.1em; }
}

/* ---------------- email updates (subscriptions) ----------------
   The first-sign-in ask reuses the track-chooser's full-view shape; the
   Settings section reuses the same .sub-choices list. */

.sub-ask {
  max-width: 620px;
  margin: 0 auto;
  padding: 20px 0 40px;
  text-align: center;
}
.sub-ask-head h2 {
  font-size: 26px;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.sub-ask-head p {
  max-width: 520px;
  margin: 0 auto 24px;
  color: var(--text-dim);
}

.sub-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.sub-choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--speed) ease, background var(--speed) ease;
}
.sub-choice:hover { border-color: var(--accent); }
.sub-choice:has(input:checked) {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), transparent 70%), var(--surface);
}
.sub-choice input[type="checkbox"] {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.sub-choice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sub-choice-title { font-weight: 700; font-size: 14.5px; }
.sub-choice-sub { font-size: 13px; color: var(--text-dim); }

.sub-ask-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}
.sub-later {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 9px;
}
.sub-later:hover { color: var(--text); background: var(--surface-2); }
.sub-note {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

@media (max-width: 720px) {
  .sub-ask-actions { flex-direction: column-reverse; gap: 8px; }
  .sub-ask-actions .btn { width: 100%; }
}
