:root{--lms-build:'2026-08-21-contents-3'}  /* build marker — see the diagnostic in CONTENTS_STUCK.md */
/* CarGen AI Learning Centre — design system ported from prototype */
*{box-sizing:border-box;margin:0;padding:0}
:root{
  /* ── Legacy palette ────────────────────────────────────────────────────────
     Kept because views and inline styles across the app reference these names
     directly. Themes override them too, so nothing looks half-changed. */
  --navy:#0f1e3c;--navy2:#1a2e52;--navy3:#243a65;
  --gold:#e8a020;--gold2:#f5b835;
  --teal:#0d7a6e;--green:#1a7a4a;--red:#c0392b;
  --slate:#3d5a80;--light:#f0f4f9;--white:#fff;
  --muted:#8896aa;--border:#d0d9e8;
  --text:#1a2433;--text2:#4a5568;
  --sidebar:240px;

  /* ── Semantic tokens ───────────────────────────────────────────────────────
     --navy did two unrelated jobs: it was the dark chrome AND the heading
     text colour. That is fine while both happen to be navy, but it makes a
     light-sidebar or dark-mode theme impossible — you cannot lighten the
     sidebar without also bleaching every heading off the page.

     Split by ROLE below. Defaults are the exact previous values, so the stock
     look is unchanged; themes then move each role independently. */

  --surface-dark:  var(--navy);   /* dark chrome: hero, video, table head */
  --surface-dark2: var(--navy2);
  --surface-dark3: var(--navy3);
  --on-dark:       #fff;          /* text ON a dark surface */
  --heading:       var(--navy);   /* heading / emphasis text */
  --accent:        var(--gold);   /* primary accent */
  --accent2:       var(--gold2);
  --on-accent:     var(--navy);   /* text ON the accent colour */
  --accent-soft:   rgba(232,160,32,.12);
  /* The accent again, but for use ON --surface-dark. Gold happens to read on
     both navy and white, which hid the fact that these are two different jobs.
     A dark accent (Crimson's #b4232f) vanishes on its own chrome, so any theme
     whose accent is dark must supply a light counterpart here. Defaults to
     --accent, so themes that don't need it can ignore it. */
  --accent-on-dark:var(--accent);

  --bg:      #f0f4f9;   /* page background */
  --surface: #fff;      /* cards, inputs, panels */
  --fill:    #f0f4f9;   /* subtle fill inside a card */
  --fill-2:  #f5f8ff;
  --fill-3:  #f8f8f8;
  --fill-hover:#f1f4fa;

  /* Sidebar, as its own scale — a light sidebar needs every one of these to
     move together, which is exactly why they were unusable as baked-in rgba. */
  --sidebar-bg:          var(--surface-dark);
  --sidebar-text:        #fff;
  --sidebar-text-dim:    rgba(255,255,255,.65);
  --sidebar-label:       rgba(255,255,255,.35);
  --sidebar-hover:       rgba(255,255,255,.06);
  --sidebar-border:      rgba(255,255,255,.08);
  --sidebar-active-bg:   var(--accent-soft);
  --sidebar-active-text: var(--accent);

  /* Status tints, previously hardcoded hex scattered through the file. */
  --tint-success:#e8f5f0;
  --tint-danger: #fde8e8;
  --tint-warn:   #fff3cd;
  --tint-warn-ink:#856404;
  --tint-info:   #cce5ff;
  --tint-accent: #fffbf0;

  /* Typography. Themes swap these; every rule below inherits. */
  --font-body:'Segoe UI',system-ui,-apple-system,sans-serif;
  --font-heading:var(--font-body);
  --heading-weight:700;
  --heading-spacing:normal;
  /* Fallback initials chip, shown only when no logo has been uploaded. It was
     hardcoded red, which clashes under every palette that isn't navy. */
  --logo-chip:#c0392b;
  --logo-chip-ink:#fff;
  --radius:10px;
}
body{font-family:var(--font-body);background:var(--bg);color:var(--text);font-size:14px;overflow:hidden;height:100vh}

/* ── APP SHELL ── */
.app{display:flex;height:100vh;overflow:hidden}
.sidebar{width:var(--sidebar);background:var(--sidebar-bg);display:flex;flex-direction:column;flex-shrink:0;overflow-y:auto;transition:width .3s}
.main-area{flex:1;overflow-y:auto;display:flex;flex-direction:column}
.app.sidebar-collapsed .sidebar{width:0;overflow:hidden}
.app.focus-mode .sidebar{width:0;overflow:hidden}
.app.focus-mode .topbar{display:none}
.sb-toggle{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border:1px solid var(--border);background:var(--surface);border-radius:9px;cursor:pointer;font-size:16px;color:var(--heading);flex:none;transition:background .12s}
.sb-toggle:hover{background:var(--fill-hover)}
.focus-exit{position:fixed;top:12px;left:12px;z-index:60;display:none !important;align-items:center;gap:7px;background:var(--surface-dark);color:var(--on-dark);border:none;border-radius:10px;padding:9px 14px;font-size:13px;font-weight:600;cursor:pointer;box-shadow:0 6px 18px rgba(14,27,51,.3);transition:background .12s}
.focus-exit:hover{background:var(--surface-dark2)}
.app.focus-mode .focus-exit{display:inline-flex !important}
.focus-hint{position:fixed;top:12px;left:50%;transform:translateX(-50%);z-index:60;display:none !important;align-items:center;gap:10px;background:rgba(14,27,51,.92);color:#fff;border-radius:10px;padding:8px 10px 8px 14px;font-size:12.5px;box-shadow:0 6px 18px rgba(14,27,51,.3)}
.app.focus-mode .focus-hint{display:flex !important}
.focus-hint kbd{display:inline-block;background:var(--surface);color:var(--heading);border-radius:5px;padding:1px 7px;font-size:11px;font-weight:700;font-family:inherit;box-shadow:0 1px 0 rgba(0,0,0,.3)}
.focus-hint button{background:transparent;border:none;color:#aab8d4;font-size:16px;line-height:1;cursor:pointer;padding:0 2px}
.focus-hint button:hover{color:#fff}
.focus-hint.dismissed{display:none !important}

/* ── SIDEBAR ── */
.sb-logo{padding:18px 16px;border-bottom:1px solid var(--sidebar-border);display:flex;align-items:center;gap:10px;cursor:pointer}
.sb-logo-icon{width:38px;height:38px;background:var(--logo-chip);border-radius:9px;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:900;color:var(--logo-chip-ink);flex-shrink:0}
.sb-logo-text{color:var(--sidebar-text);font-size:12px;font-weight:700;line-height:1.3}
.sb-logo-sub{color:var(--sidebar-active-text);font-size:9px;opacity:.85}
.sb-user{padding:12px 16px;border-bottom:1px solid var(--sidebar-border);display:flex;align-items:center;gap:10px}
.sb-avatar{width:34px;height:34px;border-radius:50%;background:var(--accent);display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;color:var(--on-accent);flex-shrink:0}
.sb-uname{color:var(--sidebar-text);font-size:11px;font-weight:600}
.sb-urole{color:var(--sidebar-text-dim);font-size:10px}
.nav-section{padding:8px 0}
.nav-label{padding:6px 16px 3px;color:var(--sidebar-label);font-size:9px;text-transform:uppercase;letter-spacing:.8px}
.nav-item{display:flex;align-items:center;gap:9px;padding:7px 16px;cursor:pointer;color:var(--sidebar-text-dim);font-size:11.5px;border-left:3px solid transparent;transition:all .15s;user-select:none}
.nav-item:hover{background:var(--sidebar-hover);color:var(--sidebar-text)}
.nav-item.active{background:var(--sidebar-active-bg);color:var(--sidebar-active-text);border-left-color:var(--sidebar-active-text)}
.nav-icon{font-size:14px;flex-shrink:0;width:16px;text-align:center}
.nav-badge{margin-left:auto;background:var(--accent);color:var(--on-accent);border-radius:10px;padding:1px 6px;font-size:9px;font-weight:700}

/* ── TOP BAR ── */
.topbar{background:var(--surface);border-bottom:1px solid var(--border);padding:10px 24px;display:flex;align-items:center;gap:12px;flex-shrink:0}
.topbar-title{font-size:15px;font-weight:var(--heading-weight);font-family:var(--font-heading);letter-spacing:var(--heading-spacing);color:var(--heading);flex:1}
.topbar-search{background:var(--fill);border:1px solid var(--border);border-radius:8px;padding:6px 12px;font-size:12px;width:220px;outline:none;color:var(--text)}
.topbar-search:focus{border-color:var(--accent)}
.btn{padding:7px 14px;border-radius:7px;font-size:12px;font-weight:600;cursor:pointer;border:none;transition:all .15s}
.btn-primary{background:var(--surface-dark);color:var(--accent-on-dark)}
.btn-primary:hover{background:var(--surface-dark2)}
.btn-gold{background:var(--accent);color:var(--on-accent)}
.btn-gold:hover{background:var(--accent2)}
.btn-outline{background:transparent;border:1px solid var(--border);color:var(--text2)}
.btn-outline:hover{background:var(--fill)}
.btn-sm{padding:4px 10px;font-size:11px}

/* ── VIEWS ── */
.view{display:none;padding:24px;animation:fadeIn .2s ease}
.view.active{display:block}
@keyframes fadeIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}

/* ── REGISTRATION ── */
.reg-wrap{min-height:100vh;background:var(--surface-dark);display:flex;align-items:center;justify-content:center;padding:20px}
.reg-card{background:var(--surface);border-radius:16px;width:100%;max-width:520px;overflow:hidden}
.reg-header{background:var(--surface-dark);padding:28px 32px;text-align:center}
.reg-header h1{font-size:22px;font-family:var(--font-heading);font-weight:var(--heading-weight);letter-spacing:var(--heading-spacing);color:var(--on-dark)}
.reg-header p{font-size:12px;color:var(--accent-on-dark);margin-top:4px}
.reg-body{padding:28px 32px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:12px}
.form-group{margin-bottom:12px}
.form-label{font-size:11px;font-weight:600;color:var(--text2);margin-bottom:4px;display:block}
.form-input{width:100%;padding:9px 12px;border:1px solid var(--border);border-radius:7px;font-size:12px;outline:none;color:var(--text);background:var(--surface)}
.form-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
.form-select{width:100%;padding:9px 12px;border:1px solid var(--border);border-radius:7px;font-size:12px;outline:none;color:var(--text);background:var(--surface)}
.reg-submit{width:100%;padding:12px;background:var(--surface-dark);color:var(--accent-on-dark);border:none;border-radius:9px;font-size:14px;font-weight:700;cursor:pointer;margin-top:8px}
.reg-submit:hover{background:var(--surface-dark2)}

/* ── GRID LAYOUTS ── */
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px}
.grid4{display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:12px}

/* ── CARDS ── */
.card{background:var(--surface);border-radius:10px;border:1px solid var(--border);padding:18px}
.card-sm{background:var(--surface);border-radius:8px;border:1px solid var(--border);padding:14px}
.stat-card{background:var(--surface);border-radius:10px;border:1px solid var(--border);padding:16px}
.stat-num{font-size:26px;font-family:var(--font-heading);font-weight:var(--heading-weight);color:var(--heading)}
.stat-label{font-size:11px;color:var(--muted);margin-top:2px}
.stat-change{font-size:10px;margin-top:4px;font-weight:600}
.pos{color:var(--green)}.neg{color:var(--red)}

/* ── PROGRESS BAR ── */
.prog-wrap{margin:6px 0}
.prog-label{display:flex;justify-content:space-between;font-size:11px;color:var(--muted);margin-bottom:3px}
.prog-bar{height:7px;background:var(--fill);border-radius:4px;overflow:hidden}
.prog-fill{height:100%;border-radius:4px;background:var(--accent);transition:width .8s ease}
.prog-fill.green{background:var(--green)}
.prog-fill.teal{background:var(--teal)}
.prog-fill.red{background:var(--red)}

/* ── COURSE CARDS ── */
.course-card{background:var(--surface);border-radius:12px;border:1px solid var(--border);overflow:hidden;cursor:pointer;transition:transform .15s,box-shadow .15s}
.course-card:hover{transform:translateY(-2px);box-shadow:0 6px 24px rgba(0,0,0,.08)}
.course-thumb{height:120px;display:flex;align-items:center;justify-content:center;font-size:48px;position:relative}
.course-info{padding:14px}
.course-level{font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:.6px;padding:2px 7px;border-radius:12px;display:inline-block;margin-bottom:6px}
.l1{background:var(--tint-success);color:var(--teal)}.l2{background:var(--tint-warn);color:var(--tint-warn-ink)}.l3{background:var(--tint-info);color:var(--surface-dark2)}.l4{background:var(--surface-dark);color:var(--accent-on-dark)}
.course-title{font-size:13px;font-family:var(--font-heading);font-weight:var(--heading-weight);color:var(--heading);margin-bottom:4px}
.course-meta{font-size:11px;color:var(--muted)}
.course-footer{display:flex;align-items:center;justify-content:space-between;margin-top:10px;padding-top:10px;border-top:1px solid var(--border)}
.course-status{font-size:10px;font-weight:600}
.status-not-started{color:var(--muted)}
.status-in-progress{color:var(--accent)}
.status-completed{color:var(--green)}

/* ── LESSON VIEW ── */
.lesson-layout{display:grid;grid-template-columns:1fr 300px;gap:20px;height:calc(100vh - 140px)}

/* ── Auto-hiding module contents ───────────────────────────────────────────
   The contents panel is a NAVIGATION aid on a READING page: useful when you
   want it, a third of the screen the rest of the time. So it slides away and
   comes back on hover at the right edge.

   RIGHT edge, not left, on purpose: the main app navigation already owns the
   left edge and has its own hover/toggle behaviour there. Two panels reacting
   to the same corner of the screen is how you end up opening the wrong one.

   Applied by a class on the layout, so the state is one flag rather than rules
   scattered across both panes. */
.lesson-layout.contents-hidden{grid-template-columns:1fr}

.lesson-layout.contents-hidden .lesson-sidebar{
  position:fixed; top:96px; right:0; bottom:20px; width:320px; z-index:850;
  overflow-y:auto; padding:0 14px 0 4px;
  transform:translateX(calc(100% - 6px));   /* a 6px sliver stays on screen: an
                                               edge you cannot see is an edge
                                               nobody discovers */
  background:var(--bg); border-left:1px solid var(--border);

  /* 260ms out, on a curve that overshoots very slightly at the end — that is
     what gives the panel weight instead of it simply appearing. Past roughly
     300ms a reveal stops reading as polish and starts reading as latency. */
  transition:transform .26s cubic-bezier(.22,1.1,.36,1), box-shadow .26s ease;
  box-shadow:-4px 0 14px rgba(0,0,0,.04);
  will-change:transform;   /* own layer, so the slide never repaints the lesson */
}

/* Revealed: the shadow deepens as it comes forward. Letting the shadow do the
   work keeps this "polished" rather than "flashy" — nothing about the panel
   changes, it just lifts off the page. */
.lesson-layout.contents-hidden .lesson-sidebar:hover,
.lesson-layout.contents-hidden .lesson-sidebar:focus-within,
.lesson-layout.contents-hidden .lesson-sidebar.peek-open{
  box-shadow:-14px 0 40px rgba(0,0,0,.16);
}

/* Hiding is FASTER than revealing — 180ms against 260ms. You wait for a reveal,
   so it can afford to be graceful; you have already moved on when it hides, so
   lingering there feels like the panel is in the way. */
.lesson-layout.contents-hidden .lesson-sidebar:not(:hover):not(.peek-open){
  transition-duration:.18s;
  transition-timing-function:cubic-bezier(.4,0,1,1);
}
.lesson-layout.contents-hidden .lesson-sidebar:hover,
.lesson-layout.contents-hidden .lesson-sidebar:focus-within,
.lesson-layout.contents-hidden .lesson-sidebar.peek-open{transform:translateX(0)}

/* Pressing Hide leaves the cursor ON the panel, so :hover immediately holds it
   open and the button looks broken. `dismissing` overrides hover until the
   pointer leaves once — set on click, cleared on mouseleave. */
.lesson-layout.contents-hidden .lesson-sidebar.dismissing{transform:translateX(calc(100% - 6px)) !important}

/* The tab is the discoverable part. Hover alone is invisible until you happen
   to brush the edge, and it does nothing at all on a touch screen — so the tab
   is also the tap target and the keyboard target. */
/* An invisible strip down the panel's left edge, so revealing does not depend on
   hitting a narrow tab exactly. This is most of what makes the interaction feel
   smooth — the animation was never the hard part, finding the trigger was.
   Only present while hidden, so it can never sit over the lesson. */
.contents-hotzone{position:fixed; right:0; top:60px; bottom:0; width:52px; z-index:849; display:none}
.lesson-layout.contents-hidden ~ .contents-hotzone{display:block}

.contents-tab{
  transition:transform .22s cubic-bezier(.22,1.1,.36,1), color .18s ease,
             border-color .18s ease, box-shadow .22s ease;
  position:fixed; right:0; top:50%; transform:translateY(-50%);
  z-index:851; display:none; align-items:center; gap:6px;
  background:var(--surface); border:1px solid var(--border); border-right:none;
  border-radius:9px 0 0 9px; padding:11px 9px; cursor:pointer;
  font-size:11px; font-weight:700; color:var(--heading);
  writing-mode:vertical-rl; letter-spacing:.04em;
  box-shadow:-4px 0 14px rgba(0,0,0,.07);
}
.lesson-layout.contents-hidden ~ .contents-tab,
.contents-tab.is-on{display:flex}
.contents-tab:hover{
  color:var(--accent); border-color:var(--accent);
  transform:translateY(-50%) translateX(-3px);      /* leans out to meet the cursor */
  box-shadow:-8px 0 22px rgba(0,0,0,.12);
}

/* A "slightly flashy" transition is a nice touch for most people and a genuine
   problem for anyone with vestibular sensitivity, so motion is REMOVED when the
   OS asks for it — not merely shortened. */
@media (prefers-reduced-motion: reduce){
  .lesson-layout.contents-hidden .lesson-sidebar,
  .contents-tab{transition:none !important}
}

/* Toggle sits with the panel heading, so "hide this" is where the thing to hide
   is — not in a toolbar somewhere else. */
/* The guide note that replaced the "previous block" button. Quiet on purpose:
   it is a hint, and a hint styled like a button becomes the third thing
   competing for the same click. */
.block-guide{
  /* Plain block, NOT flex. As a flex container each inline child became its own
     flex item, so the sentence broke into three ragged columns. */
  font-size:11px; color:var(--muted); line-height:1.65; max-width:460px;
  padding-top:4px;
}
/* Second sentence on its own line and a shade lighter: it is the secondary
   instruction, and running both together at this size reads as a wall. */
.block-guide-sub{display:block; margin-top:3px; opacity:.85}
.block-guide strong{color:var(--accent); letter-spacing:.03em}
@media (max-width:860px){
  /* On a phone the contents panel sits BELOW the lesson, so telling someone to
     look right is wrong. */
  /* Only the SECOND sentence is hidden, not the whole note.
     The Next button below exists on a phone, so that instruction is still true
     and useful. "Use the menu on the right" is not — the contents panel is
     stacked below the lesson at this width, and there is no CONTENTS tab. */
  .block-guide-sub{display:none}
}

/* Gate progress strip. Quiet by default — it is reassurance, not an alarm. */
/* Gate progress header. Centred, count first — the number is what gets glanced
   at, so it leads; the sentence explains underneath in small type. */
.gate-strip{padding:14px 16px 12px;border-bottom:1px solid var(--border);
  background:var(--fill);text-align:center}

.gate-count{display:flex;align-items:baseline;justify-content:center;gap:3px;margin-bottom:9px}
.gate-n{font-size:22px;font-weight:800;color:var(--accent);line-height:1}
.gate-of{font-size:13px;font-weight:700;color:var(--muted);line-height:1}
.gate-label{font-size:10.5px;color:var(--muted);text-transform:uppercase;
  letter-spacing:.08em;margin-left:5px}

.gate-bar{height:5px;border-radius:3px;background:var(--border);overflow:hidden}
.gate-bar span{display:block;height:5px;background:var(--accent);border-radius:3px;
  transition:width .45s cubic-bezier(.22,1.1,.36,1)}
.gate-text{font-size:10.5px;color:var(--muted);line-height:1.5;margin-top:8px}

/* Unlocked: amber becomes green throughout, so the state reads at a glance from
   colour alone without needing the sentence. */
.gate-strip.is-unlocked{background:var(--tint-success)}
.gate-strip.is-unlocked .gate-n,
.gate-strip.is-unlocked .gate-text{color:var(--green)}
.gate-strip.is-unlocked .gate-bar span{background:var(--green)}

/* Completed blocks in the contents list. Only the row tint here — the tick
   itself is styled inline in the view, matching what the module list already
   does. A duplicate .done-icon rule here would lose to that inline style and
   sit in the file misleading whoever reads it next. */
.module-item.block-done{background:var(--tint-success)}
/* Brief flash when a block completes while the learner is on the page, so the
   thing they just earned is visible without a reload. */
.gate-strip.gate-just-completed{animation:gatePulse 1.1s ease}
@keyframes gatePulse{0%{background:var(--fill)}35%{background:var(--tint-accent)}100%{background:var(--fill)}}
@media (prefers-reduced-motion: reduce){
  .gate-strip.gate-just-completed{animation:none}
  .gate-bar span{transition:none}
}

/* A block that ticks "done" while the learner is still on the page (rather
   than at the next reload) gets the same brief flash treatment as the gate
   strip, on just that one row — consistent language for "you just earned
   this" wherever it happens. */
.module-item.block-done{transition:background .3s ease}
.module-item.block-just-done{animation:rowPulse 1.1s ease}
@keyframes rowPulse{0%{background:var(--fill)}35%{background:var(--tint-success)}100%{background:var(--tint-success)}}
@media (prefers-reduced-motion: reduce){ .module-item.block-just-done{animation:none} }

/* Full-page interactive content blocks render in their own iframe rather than
   being spliced into this page (see module.blade.php) — a light frame and
   consistent radius keeps that boundary visible but unobtrusive. */
/* Full-page interactive content blocks render in their own iframe rather than
   being spliced into this page (see module.blade.php) — the iframe already
   carries its own border-radius directly (iframes are replaced elements, so
   that alone rounds their corners), so this wrapper does NOT also clip with
   overflow:hidden. A course page commonly pins its own Next/Prev controls to
   the bottom of ITS OWN viewport with position:fixed — exactly the kind of
   content that sits right at the edge of the box, and exactly what an
   overflow:hidden wrapper would crop first if its rendered height ever came
   out even a pixel shorter than the iframe's. That silent clipping — not a
   script failure — was what "lost" a course's own internal navigation. */
.content-embed{border-radius:8px;box-shadow:0 1px 3px rgba(20,20,30,.06)}
.content-embed iframe{vertical-align:top}

.contents-toggle{
  background:none; border:none; cursor:pointer; color:var(--muted);
  font-size:15px; line-height:1; padding:2px 4px; border-radius:5px;
}
.contents-toggle:hover{color:var(--accent); background:var(--fill)}
.lesson-main{display:flex;flex-direction:column;gap:16px;overflow-y:auto}
.lesson-sidebar{overflow-y:auto}
.video-box{background:var(--surface-dark);border-radius:14px;aspect-ratio:16/9;display:flex;flex-direction:column;align-items:center;justify-content:center;position:relative;overflow:hidden;padding:8px}
.video-placeholder{text-align:center;color:var(--on-dark)}
.video-placeholder .play-btn{width:64px;height:64px;background:var(--accent);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:24px;cursor:pointer;margin:0 auto 12px;transition:transform .2s}
.video-placeholder .play-btn:hover{transform:scale(1.1)}
.video-placeholder h3{font-size:14px;font-weight:700}
.video-placeholder p{font-size:11px;color:rgba(255,255,255,.6);margin-top:4px}
.video-controls{position:absolute;bottom:0;left:0;right:0;background:linear-gradient(transparent,rgba(0,0,0,.7));padding:12px 16px}
.vid-progress{height:4px;background:rgba(255,255,255,.3);border-radius:2px;cursor:pointer;margin-bottom:8px}
.vid-fill{height:100%;background:var(--accent);border-radius:2px;width:0%;transition:width .3s}
.vid-controls-row{display:flex;align-items:center;gap:10px;color:var(--on-dark);font-size:11px}
.vid-btn{background:none;border:none;color:var(--on-dark);font-size:16px;cursor:pointer;padding:2px}
.content-tabs{display:flex;gap:0;border-bottom:2px solid var(--border);margin-bottom:16px}
.content-tab{padding:8px 16px;font-size:12px;font-weight:600;color:var(--muted);cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:all .15s}
.content-tab.active{color:var(--heading);border-bottom-color:var(--accent)}
.tab-panel{display:none}.tab-panel.active{display:block}
.illustration{background:var(--surface-dark);border-radius:12px;padding:24px;margin:16px 0;text-align:center;position:relative;overflow:hidden}
.illus-title{color:var(--accent-on-dark);font-size:13px;font-weight:700;margin-bottom:16px}
.illus-diagram{display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap}
.illus-node{background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.2);border-radius:8px;padding:10px 14px;color:var(--on-dark);font-size:10px;text-align:center;min-width:80px}
.illus-node.highlight{background:var(--accent-soft);border-color:var(--accent-on-dark);color:var(--accent-on-dark)}
.illus-arrow{color:var(--accent-on-dark);font-size:18px}
.quiz-question{background:var(--fill);border-radius:10px;padding:16px;margin-bottom:14px}
.quiz-q{font-size:13px;font-weight:600;color:var(--heading);margin-bottom:10px}
.quiz-option{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:7px;border:1px solid var(--border);margin-bottom:6px;cursor:pointer;background:var(--surface);font-size:12px;transition:all .15s}
.quiz-option:hover{border-color:var(--accent);background:var(--tint-accent)}
.quiz-option.selected{border-color:var(--accent);background:var(--tint-accent)}
.quiz-option.correct{border-color:var(--green);background:var(--tint-success);color:var(--green)}
.quiz-option.wrong{border-color:var(--red);background:var(--tint-danger);color:var(--red)}
.module-list .module-item{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;cursor:pointer;font-size:12px;color:var(--text2);border-bottom:1px solid var(--border);transition:background .15s}
.module-list .module-item:hover{background:var(--fill)}
.module-list .module-item.active{background:var(--tint-accent);color:var(--heading);font-weight:600}
.module-list .module-item.done{color:var(--green)}
.mod-icon{width:28px;height:28px;border-radius:6px;display:flex;align-items:center;justify-content:center;font-size:13px;flex-shrink:0}
.mod-icon.done-icon{background:var(--tint-success)}
.mod-icon.active-icon{background:var(--tint-accent)}
.mod-icon.locked-icon{background:var(--fill)}

/* ── BADGES ── */
.badge-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}
.badge-card{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:14px;text-align:center}
.badge-icon{font-size:36px;margin-bottom:6px}
.badge-name{font-size:11px;font-weight:700;color:var(--heading)}
.badge-desc{font-size:10px;color:var(--muted);margin-top:2px}
.badge-card.earned{border-color:var(--accent);background:var(--tint-accent)}
.badge-card.locked{opacity:.45}

/* ── DASHBOARD CHARTS ── */
.chart-bar-wrap{display:flex;align-items:flex-end;gap:8px;height:120px;padding:8px 0}
.chart-bar{flex:1;background:var(--accent);border-radius:4px 4px 0 0;min-height:4px;position:relative;transition:height .8s ease}
.chart-bar span{position:absolute;top:-18px;left:50%;transform:translateX(-50%);font-size:9px;font-weight:600;color:var(--heading);white-space:nowrap}
.chart-label{font-size:9px;color:var(--muted);text-align:center;margin-top:4px}
.dept-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-bottom:1px solid var(--border);font-size:12px}
.dept-name{width:130px;font-weight:600;color:var(--heading);flex-shrink:0}
.dept-bar{flex:1}
.dept-pct{width:35px;text-align:right;font-size:11px;font-weight:600;color:var(--accent)}
.leaderboard-row{display:flex;align-items:center;gap:10px;padding:8px 12px;border-radius:7px;margin-bottom:4px;font-size:12px}
.lr-1{background:var(--tint-accent);border:1px solid var(--accent)}
.lr-2{background:var(--fill-2);border:1px solid var(--border)}
.lr-3{background:var(--fill-3);border:1px solid var(--border)}
.lr-rank{width:22px;height:22px;border-radius:50%;background:var(--surface-dark);color:var(--accent-on-dark);font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.lr-avatar{width:28px;height:28px;border-radius:50%;background:var(--slate);color:#fff;font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.lr-name{flex:1;font-weight:600;color:var(--heading)}
.lr-pts{font-size:11px;font-weight:700;color:var(--accent)}

/* ── TAGS ── */
.tag{display:inline-block;padding:2px 8px;border-radius:10px;font-size:9px;font-weight:700}
.tag-new{background:var(--tint-success);color:var(--green)}
.tag-hot{background:var(--tint-danger);color:var(--red)}
.tag-required{background:var(--tint-accent);color:var(--accent)}

/* ── ADMIN TABLE ── */
.admin-table{width:100%;border-collapse:collapse;font-size:12px}
.admin-table th{background:var(--surface-dark);color:var(--on-dark);padding:8px 12px;text-align:left;font-size:11px;font-weight:600}
.admin-table td{padding:8px 12px;border-bottom:1px solid var(--border)}
.admin-table tr:hover td{background:var(--fill)}
.status-pill{padding:2px 8px;border-radius:10px;font-size:10px;font-weight:700}
.sp-active{background:var(--tint-success);color:var(--green)}
.sp-progress{background:var(--tint-accent);color:var(--tint-warn-ink)}
.sp-notstarted{background:var(--fill);color:var(--muted)}

/* ── NOTIFICATION ── */
.notif{position:fixed;top:20px;right:20px;background:var(--green);color:#fff;padding:12px 18px;border-radius:9px;font-size:13px;font-weight:600;z-index:9999;animation:slideIn .3s ease;box-shadow:0 4px 16px rgba(0,0,0,.15)}
@keyframes slideIn{from{opacity:0;transform:translateX(30px)}to{opacity:1;transform:translateX(0)}}

/* ── HERO ── */
.hero{background:linear-gradient(135deg,var(--surface-dark),var(--surface-dark3));border-radius:14px;padding:24px 28px;color:var(--on-dark);margin-bottom:20px;position:relative;overflow:hidden}
.hero::after{content:'AI';position:absolute;right:20px;top:50%;transform:translateY(-50%);font-size:96px;font-weight:900;opacity:.06;color:var(--on-dark)}
.hero h1{font-size:20px;font-family:var(--font-heading);font-weight:var(--heading-weight);letter-spacing:var(--heading-spacing);margin-bottom:4px}
.hero p{font-size:12px;opacity:.75;margin-bottom:14px}
.hero-stats{display:flex;gap:24px}
.hero-stat{text-align:center}
.hero-stat .n{font-size:22px;font-weight:700;color:var(--accent-on-dark)}
.hero-stat .l{font-size:10px;opacity:.65}

/* ── SCROLLBAR ── */
::-webkit-scrollbar{width:5px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}

/* ── SECTION HEADER ── */
.section-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}
.section-title{font-size:15px;font-family:var(--font-heading);font-weight:var(--heading-weight);letter-spacing:var(--heading-spacing);color:var(--heading)}
.section-sub{font-size:11px;color:var(--muted);margin-top:1px}

/* ── THEME: headings inherit the theme face ── */
h1,h2,h3,h4,h5,h6{font-family:var(--font-heading);letter-spacing:var(--heading-spacing)}

/* ── Topbar Help button ────────────────────────────────────────────────────
   Sits left of the search field. Themed via tokens, so it follows whichever
   theme the organisation is on rather than only looking right on the default. */
.topbar-help{flex-shrink:0}
.topbar-help.is-on{border-color:var(--accent);color:var(--accent);background:var(--tint-accent)}
/* The search field is the element that must survive a narrow window, so the
   Help label collapses to its icon before the search box starts shrinking. */
@media (max-width:900px){
  .topbar-help-label{display:none}
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE / TABLET
   ═══════════════════════════════════════════════════════════════════════════

   The desktop layout is a flex row: a fixed-width sidebar beside the content.
   That does not shrink usefully — on a 375px phone a 240px sidebar leaves 135px
   for everything else, which is the unusable view.

   So below 860px the sidebar stops being a COLUMN and becomes a DRAWER: taken
   out of the flow, slid off-screen, and floated over the content when opened.
   The content then gets the full width at every size.
   ═════════════════════════════════════════════════════════════════════════ */

@media (max-width:860px){

  /* 100dvh, not 100vh. On mobile Safari and Chrome, 100vh is the height with the
     address bar HIDDEN, so a 100vh app is permanently taller than the visible
     area — the bottom is cut off and the whole page rubber-bands. dvh tracks the
     bar as it shows and hides. */
  .app{height:100dvh}

  /* ── The drawer ──────────────────────────────────────────────────────── */
  .sidebar{
    position:fixed; top:0; left:0; bottom:0;
    width:min(82vw, 300px);          /* never full width: the strip of visible
                                        content behind it is what tells you the
                                        drawer is temporary and tappable-away */
    z-index:1100;
    transform:translateX(-100%);
    transition:transform .26s ease;
    box-shadow:0 0 40px rgba(0,0,0,.3);
    /* Notch and home-indicator insets, which matter once installed as a PWA
       because there is no browser chrome to absorb them. */
    padding-left:env(safe-area-inset-left);
    padding-bottom:env(safe-area-inset-bottom);
  }
  .app.sidebar-open .sidebar{transform:translateX(0)}

  /* The desktop collapse rules set width:0. Off-canvas, width is what makes the
     drawer usable, so those have to be neutralised or the drawer opens empty. */
  .app.sidebar-collapsed .sidebar,
  .app.focus-mode .sidebar{width:min(82vw, 300px); overflow-y:auto}

  /* Backdrop. Also the thing that makes "tap anywhere to close" discoverable. */
  .sb-backdrop{
    position:fixed; inset:0; background:rgba(10,15,25,.45);
    z-index:1090; opacity:0; pointer-events:none; transition:opacity .26s ease;
  }
  .app.sidebar-open .sb-backdrop{opacity:1; pointer-events:auto}

  .main-area{width:100%; min-width:0}   /* min-width:0 stops a wide child (a
                                           table, a long word) forcing the whole
                                           column wider than the screen */

  /* ── Topbar ──────────────────────────────────────────────────────────── */
  .topbar{
    padding:8px 12px; gap:8px;
    padding-top:calc(8px + env(safe-area-inset-top));
    position:sticky; top:0; z-index:900;   /* the menu button stays reachable
                                              without scrolling back up */
  }
  .topbar-title{font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

  /* The search box is the first thing to go: it is 220px of fixed width for a
     feature nobody uses one-handed, and keeping it squeezes everything else. */
  .topbar-search{display:none}

  .sb-toggle{width:40px; height:40px; font-size:18px}  /* 40px is about the
                                                          smallest reliable
                                                          thumb target */

  /* ── Content ─────────────────────────────────────────────────────────── */
  .view{padding:14px 12px !important}
  .card{padding:14px; border-radius:10px}
  .card-sm{padding:11px 13px}

  /* Multi-column grids become single column. Two 50% columns on a phone give
     two unreadable columns rather than one readable one. */
  .grid2, .grid3{grid-template-columns:1fr; gap:12px}

  .hero{padding:18px 16px; border-radius:12px}
  .hero h1{font-size:17px}
  .hero::after{display:none}          /* the giant watermark eats the space the
                                         text needs at this width */
  .hero-stats{gap:14px; flex-wrap:wrap}

  /* ── Tables ──────────────────────────────────────────────────────────── */
  /* Admin tables have 5–7 columns and cannot honestly fit. Rather than shrink
     the text to unreadable, they scroll sideways inside their own box — the
     page itself never scrolls horizontally, which is what feels broken. */
  .table-scroll{overflow-x:auto; -webkit-overflow-scrolling:touch; margin:0 -12px; padding:0 12px}
  .admin-table{font-size:11.5px; min-width:560px}
  .admin-table th, .admin-table td{padding:7px 9px; white-space:nowrap}

  /* ── Forms ───────────────────────────────────────────────────────────── */
  /* 16px is not a style choice: iOS Safari zooms the page in on focus for any
     input under 16px, and does not zoom back out. */
  .form-input, .form-select, textarea, input[type=text], input[type=email],
  input[type=password], input[type=number], input[type=date], input[type=file]{
    font-size:16px; padding:10px 12px;
  }
  .form-label{font-size:12px}

  .btn{padding:9px 14px; font-size:13px}
  .btn-sm{padding:7px 11px; font-size:12px}

  /* ── Nav ─────────────────────────────────────────────────────────────── */
  .nav-item{padding:11px 14px; font-size:13.5px}   /* taller rows: a drawer is
                                                      driven by thumb, not mouse */

  /* Anything absolutely positioned to a corner tends to end up off-screen. */
  .modal, .panel{max-width:calc(100vw - 24px)}

  /* ── The lesson page ─────────────────────────────────────────────────── */
  /* `1fr 300px` never collapses: on a 390px screen the 300px column takes most
     of the width and the CONTENT is squeezed to about 60px — one word per line.
     That is the strip of vertical text in the lesson view. */
  .lesson-layout{
    grid-template-columns:1fr;      /* content first, contents list under it */
    height:auto;                    /* calc(100vh - 140px) assumed a desktop
                                       header; on a phone it cut the page off */
    gap:14px;
  }
  /* Both panes scrolled independently, which on a phone means two nested scroll
     areas fighting the page scroll. One page, one scroll. */
  .lesson-main, .lesson-sidebar{overflow:visible; height:auto}

  /* The module contents list moves BELOW the lesson. Someone on a phone came to
     read this step, not to browse the list — and the list is long. */
  .lesson-sidebar{order:2}
  .lesson-main{order:1}

  /* Hide-and-peek is a mouse idea. On a phone the contents already sit below
     the lesson, and a panel flying in from the edge over a small screen is
     worse than scrolling to it. Neutralise the whole thing here. */
  .lesson-layout.contents-hidden{grid-template-columns:1fr}
  .lesson-layout.contents-hidden .lesson-sidebar{
    position:static; width:auto; transform:none; box-shadow:none;
    border-left:none; padding:0; background:none;
  }
  .contents-tab{display:none !important}

  /* ── Focus mode chrome ───────────────────────────────────────────────── */
  /* "Exit focus" and the F11 hint are both fixed at top:12px, so on a narrow
     screen they sit on top of each other — which is what makes that corner
     unreadable. Stack them, and shrink the exit button to its icon. */
  .focus-exit{top:8px; left:8px; padding:8px 11px; font-size:12px}

  /* The exit button is position:fixed, so it sits ON the content rather than
     above it — on desktop there is margin to spare, on a phone it lands on the
     lesson title. Push the content down by the button's height in focus mode. */
  .app.focus-mode .view{padding-top:52px !important}

  /* F11 does nothing on a phone: there is no keyboard and no windowed browser
     to make full-screen. Showing the tip is worse than showing nothing, so it
     is hidden rather than repositioned. */
  .app.focus-mode .focus-hint{display:none !important}

  /* The org-context bar is useful but it is platform-staff chrome, and at this
     width it was pushing the lesson itself below the fold. */
  /* !important is needed, not laziness: the partial sets display:flex as an
     INLINE style, and an inline style beats any stylesheet rule without it.
     Without !important this rule silently does nothing. */
  .app.focus-mode .org-context-bar{display:none !important}
}

/* ── Small phones ──────────────────────────────────────────────────────── */
@media (max-width:420px){
  .view{padding:12px 10px !important}
  .card{padding:12px}
  .topbar-title{font-size:13px}
  .hero{padding:16px 13px}
  .hero h1{font-size:16px}
  /* Points/streak chip: keep it, but stop it competing with the title. */
  .btn-gold.btn-sm{padding:6px 9px; font-size:11px}
}

/* ── Installed PWA ─────────────────────────────────────────────────────── */
/* No browser chrome in standalone mode, so the safe-area insets are the only
   thing keeping content clear of the notch and the home indicator. */
@media (display-mode: standalone){
  .topbar{padding-top:calc(10px + env(safe-area-inset-top))}
  .view{padding-bottom:calc(20px + env(safe-area-inset-bottom)) !important}
}

/* Landscape phones are short, not narrow — reclaim vertical space. */
@media (max-height:500px) and (orientation:landscape){
  .hero{padding:12px 16px}
  .hero p{display:none}
  .topbar{padding-top:6px; padding-bottom:6px}
}


/* No hover and coarse pointer = a touch device. F11 is meaningless there
   whatever the screen width, including a large tablet. */
@media (hover:none) and (pointer:coarse){
  .app.focus-mode .focus-hint{display:none !important}
}
