/* ═══════════════════════════════════════════════════════════════
   TICKET UP — Trades Edition
   Warm charcoal. Copper accent. No gradients. No glass. No AI.
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ─── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:        #07111f;
  --surface:   #0f1b2d;
  --surface-2: #16243a;
  --surface-3: #203149;

  /* Copper accent */
  --copper:        #126BFF;
  --copper-light:  #55A0FF;
  --copper-dim:    rgba(18,107,255,0.12);
  --copper-border: rgba(18,107,255,0.30);

  /* Status */
  --green:   #16A34A;
  --red:     #DC2626;
  --amber:   #D97706;
  --blue:    #126BFF;
  --navy:    #071426;
  --danger:  #DC2626;
  --warning: #D97706;

  /* Text */
  --text:       #DCE6F4;
  --text-muted: rgba(220,230,244,0.66);
  --text-faint: rgba(220,230,244,0.38);
  --white:      #F8FBFF;

  /* Borders */
  --border:       rgba(210,225,247,0.10);
  --border-mid:   rgba(210,225,247,0.18);
  --shadow-premium: 0 18px 50px rgba(0,0,0,0.28);

  /* Type scale */
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   17px;
  --text-xl:   22px;
  --text-2xl:  28px;
  --text-3xl:  36px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  /* Sidebar */
  --sidebar-w: 252px;
}

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(circle at 18% -10%, rgba(18,107,255,0.18), transparent 34%),
    radial-gradient(circle at 90% 4%, rgba(22,163,74,0.10), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; background: transparent; }
a { color: var(--copper-light); text-decoration: none; }

/* ─── App shell ──────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.brand-mark-svg {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.22);
}

.brand-block h1 {
  color: var(--white);
  font-size: 17px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.brand-block p {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
  margin-top: 4px;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 14px 28px;
  background: rgba(7,17,31,0.86);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-logo {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
}

.topbar-title {
  color: var(--white);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.topbar-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  margin-top: 3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trust-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255,255,255,0.055);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.dashboard-strip {
  display: grid;
  grid-template-columns: 1.35fr repeat(3, minmax(150px, 1fr));
  gap: 14px;
  padding: 24px 28px 0;
}

.dashboard-card {
  display: grid;
  gap: 7px;
  min-height: 118px;
  padding: 18px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(15,27,45,0.78);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-premium);
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  border-color: var(--copper-border);
  background: rgba(22,36,58,0.94);
}

.dashboard-primary {
  background:
    linear-gradient(135deg, rgba(18,107,255,0.22), rgba(15,27,45,0.82)),
    rgba(15,27,45,0.9);
  border-color: rgba(85,160,255,0.30);
}

.dash-label {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.dashboard-card strong {
  color: var(--white);
  font-size: 23px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.dashboard-card span:last-child {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════════ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(10,22,38,0.98);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.brand-icon {
  width: 32px; height: 32px;
  background: var(--copper);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.brand-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.4px;
}
.brand-sub {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.2px;
  margin-top: 1px;
}
.brand-logo { display: none; }

/* XP block */
.xp-block {
  margin: 0 12px 10px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.xp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}
.xp-level {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--copper-light);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.xp-pts {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
}
.xp-bar-track {
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  height: 4px;
}
.xp-bar-fill {
  background: var(--copper);
  border-radius: 99px;
  height: 4px;
  width: 0%;
  transition: width 0.7s ease;
}
.xp-sub {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 5px;
}

/* Stat chips */
.stat-chips {
  display: flex;
  gap: 6px;
  margin: 0 12px 14px;
}
.streak-chip, .acc-chip {
  flex: 1;
  border-radius: var(--r-sm);
  padding: 8px 10px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.chip-num {
  font-size: 16px;
  font-weight: 800;
  color: var(--white);
  line-height: 1.2;
}
.streak-chip .chip-num { color: var(--copper-light); }
.acc-chip .chip-num { color: var(--green); }
.chip-lbl {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 2px;
  font-weight: 500;
}

/* Hidden legacy elements */
.meter { display: none; }

/* Weak box */
.weak-box {
  margin: 0 12px 12px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.weak-box strong {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.weak-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.weak-item:last-child { border-bottom: 0; }
.weak-item strong {
  display: inline;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--amber);
  margin: 0;
}

/* Section nav label */
.section-nav-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 18px;
  margin-bottom: 4px;
}

/* Section list */
.section-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 8px;
}

.section-button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text-muted);
  text-align: left;
  transition: background 100ms, color 100ms;
  font-size: 13px;
  position: relative;
}
.section-button:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.section-button.active {
  color: var(--white);
  background: linear-gradient(90deg, rgba(18,107,255,0.20), rgba(18,107,255,0.06));
  border: 1px solid rgba(85,160,255,0.18);
}
.section-button.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--copper);
  border-radius: 0 2px 2px 0;
}
.section-button.locked { color: var(--text-faint); }
.section-button.locked:hover { background: rgba(255,255,255,0.02); }

.section-title {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.section-score {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  white-space: nowrap;
}
.section-button.active .section-score { color: var(--copper-light); }
.section-score.score-done    { color: var(--green) !important; }
.section-score.score-partial { color: var(--copper-light) !important; }

/* Sidebar nav tools */
.sidebar-nav-tools {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 12px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
}
.sidebar-tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: background 100ms, color 100ms;
}
.sidebar-tool-btn:hover,
.sidebar-tool-btn.active {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════
   WORKBENCH / MAIN
═══════════════════════════════════════════════════════════════ */
.workbench {
  min-width: 0;
  background: transparent;
}

/* ─── Lesson hero ─────────────────────────────────────────────── */
.lesson-band {
  margin: 24px 28px 0;
  background: rgba(15,27,45,0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-premium);
  position: relative;
  overflow: hidden;
}
.lesson-image {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.16;
  filter: saturate(0.75) contrast(1.05);
}
.lesson-band::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(7,17,31,0.92), rgba(7,17,31,0.62) 52%, rgba(7,17,31,0.22));
}
.lesson-overlay {
  position: relative;
  z-index: 1;
  padding: 36px 38px 32px;
  color: var(--white);
}
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--copper-light);
  margin-bottom: 10px;
}
.lesson-overlay h2 {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--white);
  max-width: 680px;
  margin-bottom: 14px;
}
.lesson-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.diff-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.diff-1 { background: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.diff-2 { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.diff-3 { background: rgba(239,68,68,0.15);  color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.lesson-progress { font-size: 12px; font-weight: 600; color: var(--text-faint); }

/* ─── Module nav ─────────────────────────────────────────────── */
.module-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 28px 0;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15,27,45,0.74);
}
.module-steps { display: flex; align-items: center; gap: 6px; flex: 1; }
.module-step {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: all 0.15s;
}
.module-step.active {
  color: var(--copper-light);
  border-color: var(--copper-border);
  background: var(--copper-dim);
}
.module-step.done {
  color: var(--green);
  border-color: rgba(34,197,94,0.25);
  background: rgba(34,197,94,0.07);
}
.module-step-arrow { color: var(--text-faint); font-size: 11px; }
.module-lesson-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ─── Content grid ───────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  padding: 18px 28px 32px;
}

/* ─── Lesson panel ───────────────────────────────────────────── */
.lesson-panel {
  background: rgba(248,251,255,0.98);
  border: 1px solid var(--border);
  border-radius: 18px;
  min-height: 460px;
  overflow: hidden;
  color: #132033;
  box-shadow: var(--shadow-premium);
}

.tool-surface {
  background: rgba(248,251,255,0.98);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  color: #132033;
  box-shadow: var(--shadow-premium);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  background: var(--copper);
  color: #fff;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: var(--text-sm);
  transition: background 100ms;
  white-space: nowrap;
}
.primary-button:hover { background: var(--copper-light); }
.primary-button:active { opacity: 0.9; }

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  transition: background 100ms;
  white-space: nowrap;
}
.tool-button:hover { background: var(--surface-3); }

.card-tool-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background: var(--copper-dim);
  color: var(--copper-light);
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: var(--text-sm);
  border: 1px solid var(--copper-border);
  transition: background 100ms;
}
.card-tool-button:hover { background: rgba(212,124,58,0.2); }

.wide-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  background: var(--copper);
  color: #fff;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: var(--text-sm);
  transition: background 100ms;
}
.wide-button:hover { background: var(--copper-light); }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 15px;
  border: 1px solid var(--border);
  transition: background 100ms;
}
.icon-button:hover { background: var(--surface-3); color: var(--text); }

.outline-btn {
  padding: 10px 16px;
  background: transparent;
  color: var(--copper-light);
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid var(--copper-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 100ms;
  flex: 1;
}
.outline-btn:hover { background: var(--copper-dim); }

/* ─── Code badge ─────────────────────────────────────────────── */
.code-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: 4px;
  background: #eef5ff;
  color: #0f5ed7;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid #cfe0ff;
  cursor: pointer;
  transition: background 100ms;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.code-badge:hover { background: #e2efff; color: #071426; }

/* ─── Card-based lesson ──────────────────────────────────────── */
.lesson-card-wrap {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  height: 100%;
}

/* Top progress bar on card (replaces dots) */
.lesson-card-wrap::before {
  content: '';
  display: block;
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}

.lesson-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px 12px;
  border-bottom: 1px solid rgba(19,32,51,0.10);
  flex-shrink: 0;
}
.card-icon-wrap { display: none; }  /* removed icon box */
.card-section-label {
  font-size: var(--text-xs);
  font-weight: 800;
  color: #126BFF;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex: 1;
}

/* Dot progress — kept but restyled */
.card-progress-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.card-dot {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,0.1);
  transition: background 0.2s, width 0.2s;
}
.card-dot.active { background: var(--copper); width: 18px; }
.card-dot.done   { background: var(--green); }
.card-counter {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}

.lesson-card-body {
  padding: 24px 20px 20px;
  flex: 1;
  overflow-y: auto;
  line-height: 1.8;
  font-size: var(--text-lg);
  color: #1d2b3d;
  background: #fff;
}
.lesson-card-body p { margin: 0 0 16px; }
.lesson-card-body p:last-child { margin-bottom: 0; }
.lesson-card-body ul { padding-left: 22px; margin: 0 0 16px; }
.lesson-card-body li { margin-bottom: 8px; }

.lesson-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid rgba(19,32,51,0.10);
  gap: 10px;
  flex-shrink: 0;
  background: #f7faff;
}
.lesson-card-footer .card-next-btn { flex: 1; }
.lesson-card-footer .card-ref-btn  { flex-shrink: 0; }
.lesson-card-footer .card-prev-btn { flex-shrink: 0; }

.card-next-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  background: var(--copper);
  color: #fff;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 14px;
  transition: background 100ms;
  border: none;
  cursor: pointer;
}
.card-next-btn:hover { background: var(--copper-light); }
.card-next-btn:active { opacity: 0.9; }

.card-prev-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 14px;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--border);
  transition: all 100ms;
  cursor: pointer;
}
.card-prev-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Video card ─────────────────────────────────────────── */
.lesson-card-video .lesson-card-body { padding: 0; }
.video-card-body { display: flex; flex-direction: column; gap: 0; }
.video-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.video-tab-btn {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.video-tab-btn.active {
  color: var(--copper-light);
  border-bottom-color: var(--copper);
}
.video-tab-btn:hover { color: var(--text); }
.video-embed-wrap { padding: 16px; }
.video-embed-wrap.hidden { display: none; }
.video-embed-wrap iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: var(--r-sm);
  background: #000;
  display: block;
}
.video-channel { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ─── Loading ────────────────────────────────────────────────── */
.loading-lesson {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 24px;
  color: var(--text-muted);
  font-size: 14px;
}
.loading-lesson .spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--copper);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Quiz ───────────────────────────────────────────────────── */
.quiz-progress-bar {
  height: 3px;
  background: var(--border);
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: var(--copper);
  transition: width 0.35s ease;
}

.quiz-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px 0;
}
.quiz-counter {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.quiz-timer {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.quiz-body { padding: 20px; }

.quiz-question-text {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.45;
  color: #071426;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

/* Answer grid */
.answer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
#moduleQuiz .answer-grid { grid-template-columns: 1fr; }

.answer-button {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 13px 15px;
  background: #f7faff;
  border: 1px solid #dce7f5;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #132033;
  cursor: pointer;
  text-align: left;
  transition: border-color 100ms, background 100ms;
  line-height: 1.45;
}
.answer-button:hover:not(:disabled) {
  border-color: #9ec5ff;
  background: #eef5ff;
}
.answer-button:disabled { cursor: default; }

.answer-key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 4px;
  background: #eaf2fb;
  border: 1px solid #d5e4f4;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
  color: #51627a;
  transition: all 0.12s;
}
.answer-button.correct {
  border-color: rgba(34,197,94,0.4);
  background: rgba(22,163,74,0.10);
  color: #166534;
}
.answer-button.correct .answer-key {
  background: rgba(22,163,74,0.16);
  border-color: rgba(22,163,74,0.35);
  color: #166534;
}
.answer-button.wrong {
  border-color: rgba(220,38,38,0.35);
  background: rgba(220,38,38,0.08);
  color: #991b1b;
}
.answer-button.wrong .answer-key {
  background: rgba(220,38,38,0.14);
  border-color: rgba(220,38,38,0.3);
  color: #991b1b;
}

/* Quiz feedback */
.quiz-feedback {
  margin-top: 16px;
  border-radius: 14px;
  border: 1px solid #dce7f5;
  overflow: hidden;
  animation: slideIn 0.2s ease;
}
.quiz-feedback.correct { border-color: rgba(22,163,74,0.25); background: rgba(22,163,74,0.06); }
.quiz-feedback.wrong   { border-color: rgba(220,38,38,0.22); background: rgba(220,38,38,0.05); }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.feedback-verdict {
  padding: 10px 14px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #132033;
}
.quiz-feedback.correct .feedback-verdict { color: #166534; }
.quiz-feedback.wrong   .feedback-verdict { color: #991b1b; }
.feedback-explanation {
  padding: 8px 14px 14px;
  font-size: var(--text-sm);
  line-height: 1.65;
  color: #304156;
}

.quiz-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

.next-q-btn {
  width: 100%;
  padding: 12px 20px;
  background: var(--copper);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 100ms;
}
.next-q-btn:hover { background: var(--copper-light); }

.explain-btn {
  width: 100%;
  padding: 9px 16px;
  background: transparent;
  color: var(--copper-light);
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid var(--copper-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 100ms;
}
.explain-btn:hover { background: var(--copper-dim); }
.explain-btn:disabled { opacity: 0.4; cursor: default; }

/* ─── Score ──────────────────────────────────────────────────── */
.score-display {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.score-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-align: center;
  padding-bottom: 20px;
}
.score-ring-wrap { margin: 24px auto 12px; display: flex; justify-content: center; }
.score-ring-wrap svg { display: block; }
.score-circle {
  width: 100px; height: 100px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 24px auto 0;
  border: 3px solid var(--border-mid);
  background: var(--surface-3);
}
.score-circle.grade-pass { border-color: var(--green); }
.score-circle.grade-mid  { border-color: var(--amber); }
.score-circle.grade-fail { border-color: var(--red); }
.score-number { font-size: 28px; font-weight: 800; line-height: 1; color: var(--white); }
.score-pct { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.grade-pass .score-number { color: #4ade80; }
.grade-mid  .score-number { color: #fbbf24; }
.grade-fail .score-number { color: #f87171; }
.score-message {
  padding: 12px 20px 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}
.score-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

/* ─── Side panel ─────────────────────────────────────────────── */
.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.tool-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: #071426;
  letter-spacing: -0.2px;
}
.small-stat { font-size: 12px; font-weight: 700; color: #64748b; }
.tool-desc { font-size: 12px; color: #64748b; margin-bottom: 10px; line-height: 1.5; }
.side-tool-btns { display: flex; gap: 8px; margin-top: 8px; }
.badge-dot-inline {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-left: 4px;
  vertical-align: middle;
}

/* Weak card */
.weak-card .weak-item { border-bottom-color: rgba(19,32,51,0.10); color: #64748b; }
.weak-card .weak-item strong { color: var(--red); font-size: 12px; font-weight: 700; }

/* Search */
.search-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.search-form input {
  height: 36px;
  padding: 0 11px;
  background: #f7faff;
  border: 1px solid #dce7f5;
  border-radius: var(--r-sm);
  color: #132033;
  font-size: var(--text-sm);
  transition: border-color 100ms;
  min-width: 0;
}
.search-form input:focus { outline: none; border-color: var(--copper-border); }
.search-form input::placeholder { color: #8a99ad; }
.search-form .primary-button { height: 36px; padding: 0 14px; border-radius: var(--r-sm); }
.result-box { margin-top: 12px; font-size: 13px; line-height: 1.65; color: #52657c; white-space: pre-wrap; }

/* ─── Profile dialog ─────────────────────────────────────────── */
.profile-dialog {
  width: min(600px, calc(100vw - 32px));
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  padding: 32px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}
.profile-dialog::backdrop { background: rgba(0,0,0,0.75); }
.profile-dialog h2 { font-size: 22px; font-weight: 800; color: var(--white); margin-bottom: 6px; letter-spacing: -0.3px; }
.profile-dialog p { color: var(--text-muted); font-size: 14px; margin-bottom: 4px; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.mode-card {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100px; padding: 18px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  color: var(--text);
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: border-color 100ms, background 100ms;
}
.mode-card:hover {
  border-color: var(--copper-border);
  background: var(--copper-dim);
  color: var(--white);
}
.mode-card span { display: block; margin-top: 5px; font-size: 11px; font-weight: 500; color: var(--text-muted); }

/* ─── Source panel ───────────────────────────────────────────── */
.source-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(420px,100vw);
  padding: 24px;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--border-mid);
  box-shadow: -8px 0 40px rgba(0,0,0,0.5);
  transform: translateX(105%);
  transition: transform 200ms ease;
  z-index: 20;
}
.source-panel.open { transform: translateX(0); }
.source-panel h3 { font-size: 15px; font-weight: 700; color: var(--white); margin-bottom: 4px; margin-right: 44px; }
#sourceText { margin-top: 14px; font-size: 13px; line-height: 1.65; color: var(--text-muted); white-space: pre-wrap; }

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 12px 16px;
  background: var(--surface-3);
  color: var(--text);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid var(--border-mid);
  opacity: 0; transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ─── Ready button ───────────────────────────────────────────── */
.ready-button {
  display: block;
  width: calc(100% - 40px);
  margin: 4px 20px 24px;
  padding: 14px 24px;
  background: var(--copper);
  color: #fff;
  font-size: 15px; font-weight: 700;
  border: none; border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 100ms;
}
.ready-button:hover { background: var(--copper-light); }

/* ─── Diagram ────────────────────────────────────────────────── */
.diagram-wrap {
  margin-top: 16px; padding: 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.diagram-wrap svg { display: block; width: 100%; height: auto; }
.diagram-caption { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

/* ─── Bottom nav ─────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: 60px;
}
.bottom-nav-inner { display: flex; height: 100%; }
.nav-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; background: transparent; border: 0;
  color: var(--text-faint);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.04em; cursor: pointer;
  padding: 6px 4px; transition: color 100ms;
}
.nav-tab .nav-icon { font-size: 19px; line-height: 1; }
.nav-tab.active { color: var(--copper-light); }
.nav-badge { position: relative; display: inline-block; }
.badge-dot {
  position: absolute; top: -2px; right: -6px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--surface);
}

/* ─── Exam ───────────────────────────────────────────────────── */
.quiz-panel > p, .exam-panel > p { font-size: 14px; line-height: 1.6; color: var(--text); margin-bottom: 14px; }
.exam-progress { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  :root { --sidebar-w: 220px; }
  .content-grid { grid-template-columns: minmax(0,1fr) 270px; }
  .dashboard-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .dashboard-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workbench { padding-bottom: 60px; }
  .bottom-nav { display: flex; }
  .app-topbar { padding: 12px 14px; min-height: 64px; }
  .topbar-logo { width: 34px; height: 34px; flex-basis: 34px; }
  .topbar-title { font-size: 16px; }
  .topbar-subtitle { display: none; }
  .topbar-actions { gap: 6px; }
  .trust-pill { min-height: 26px; padding: 0 8px; font-size: 11px; }
  .dashboard-strip { grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 12px 0; }
  .dashboard-card { min-height: 98px; padding: 13px; border-radius: 12px; }
  .dashboard-card strong { font-size: 18px; }
  .dashboard-card span:last-child { font-size: 12px; }
  .lesson-band { margin: 12px 12px 0; border-radius: 14px; }
  .lesson-overlay { padding: 22px; }
  .lesson-overlay h2 { font-size: var(--text-xl); }
  .module-nav { margin: 12px 12px 0; overflow-x: auto; }
  .content-grid { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .answer-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
}
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(60px + env(safe-area-inset-bottom)); }
  .workbench { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
}

/* ─── Media Hub page ──────────────────────────────────────── */
.media-hub-header {
  padding: 28px 28px 16px;
}
.media-hub-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--white);
  margin: 0 0 4px;
}
.media-hub-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.media-tabs-bar {
  display: flex;
  gap: 6px;
  padding: 0 28px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.media-tab-btn {
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 8px 20px;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.media-tab-btn.active {
  background: var(--copper-dim);
  border-color: var(--copper-border);
  color: var(--copper);
}

/* Video categories */
#mediaContent {
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.media-category {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-md);
  overflow: hidden;
}
.media-cat-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--surface);
  border: none;
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.media-cat-header:hover,
.media-cat-header.open { background: var(--surface-2); }
.media-cat-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}
.media-cat-arrow { font-size: 0.7rem; color: var(--text-muted); }
.media-cat-body { display: none; padding: 16px; background: var(--surface); }
.media-cat-body.open { display: block; }

/* Video grid */
.media-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.media-video-item {
  background: var(--surface-2);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
  transition: border-color 0.15s;
}
.media-video-item:hover { border-color: var(--copper-border); }
.media-thumb-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
  overflow: hidden;
}
.media-thumb-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.media-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}
.media-video-item:hover .media-thumb { opacity: 0.8; }
.media-play-btn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.3);
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.media-thumb-wrap:hover .media-play-btn { opacity: 1; }
.media-video-info { padding: 10px 12px; }
.media-video-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.media-video-channel {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0;
}

/* Podcast grid */
.podcast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.podcast-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s;
}
.podcast-card:hover { border-color: var(--copper-border); }
.podcast-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.podcast-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}
.podcast-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--white);
  margin: 0 0 3px;
}
.podcast-host {
  font-size: 0.75rem;
  color: var(--copper);
  margin: 0;
}
.podcast-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}
.podcast-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.podcast-topic {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.podcast-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}
.podcast-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.15s;
}
.podcast-link-btn:hover { border-color: var(--copper-border); color: var(--copper); }
.podcast-link-btn.spotify:hover { border-color: #1db954; color: #1db954; }
.podcast-link-btn.apple:hover { border-color: #fc3c44; color: #fc3c44; }

/* ─── Diagram card (Hot Water section) ───────────────────── */
.diagram-card-body {
  padding: 16px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.diagram-wrap {
  width: 100%;
  background: var(--surface-3);
  border-radius: var(--r-md);
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.06);
}
.diagram-wrap svg {
  width: 100%;
  height: auto;
}
.diagram-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
  font-style: italic;
}
