/* ========================================
   Zipgo Learn — ported from zipgo.ai styles.css
   (same tokens/components, adapted to app layouts)
   ======================================== */
:root {
  --primary: #00f0ff;
  --primary-dark: #00a8b3;
  --secondary: #8b5cf6;
  --accent: #f0f;
  --bg-dark: #000000;
  --bg-darker: #050508;
  --bg-card: rgba(255, 255, 255, 0.02);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  --border: rgba(255, 255, 255, 0.1);
  --glow: 0 0 20px rgba(0, 240, 255, 0.3);
  /* course themes override these two */
  --course-accent: var(--primary);
  --course-accent2: var(--secondary);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* Site-wide themed scrollbars (page, sidebar, module nav, logs) */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.35) rgba(255, 255, 255, 0.04);
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.04); }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.45), rgba(139, 92, 246, 0.45));
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--primary); }
html, body { height: 100%; }
body {
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
  font-size: 1.05rem;
  /* Flex column so the topbar takes its real height and the content fills the
     rest exactly — prevents a phantom scroll when everything already fits. */
  min-height: 100dvh; display: flex; flex-direction: column;
}
body > .layout, body > .main, body > #root { flex: 1 0 auto; min-height: 0; }
body > #root { display: flex; flex-direction: column; }

/* Deep-space nebula wash — sits beneath the starfield, quieter than it */
body::before {
  content: '';
  position: fixed; inset: -25%;
  z-index: -2; pointer-events: none;
  background:
    radial-gradient(42% 34% at 22% 28%, rgba(139, 92, 246, 0.17) 0%, transparent 70%),
    radial-gradient(36% 30% at 78% 64%, rgba(0, 240, 255, 0.10) 0%, transparent 70%),
    radial-gradient(26% 22% at 62% 15%, rgba(255, 0, 255, 0.06) 0%, transparent 70%),
    radial-gradient(48% 40% at 38% 88%, rgba(64, 66, 160, 0.15) 0%, transparent 70%),
    var(--bg-dark);
  animation: nebula-drift 90s ease-in-out infinite alternate;
}
@keyframes nebula-drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to { transform: translate3d(1.5%, 1.5%, 0) scale(1.07); }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

/* FTL starfield canvas (drawn by app.js) — above the nebula, behind content.
   Explicit width/height: a <canvas> is a replaced element, so inset:0 alone
   would render it at its intrinsic (DPR-scaled) buffer size anchored top-left
   instead of filling the viewport, throwing the animation's center off-screen
   on high-DPI phones. */
#warp {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: -1; pointer-events: none;
}
h1, h2, h3 { font-family: 'Orbitron', sans-serif; letter-spacing: 0.05em; }
a { color: var(--primary); text-decoration: none; }
p { margin-bottom: 1rem; }

/* ========================================
   Page loader — blocks first paint until the JS render settles
   ======================================== */
#loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.3rem;
  transition: opacity 0.4s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
#loader img {
  height: 58px;
  filter: drop-shadow(0 0 18px rgba(0, 240, 255, 0.45));
  animation: loader-pulse 1.6s ease-in-out infinite;
}
@keyframes loader-pulse {
  50% { transform: scale(1.07); opacity: 0.75; }
}
#loader .loader-dots { display: flex; gap: 0.45rem; }
#loader .loader-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
  animation: loader-dot 1.2s ease-in-out infinite;
}
#loader .loader-dots span:nth-child(2) { animation-delay: 0.15s; }
#loader .loader-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes loader-dot { 40% { opacity: 0.2; transform: translateY(3px); } }

/* ========================================
   Navigation (zipgo.ai navbar)
   ======================================== */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 2.5rem;
  padding: 1rem 2rem;
  transition: all 0.3s ease;
  background: transparent;
}
.topbar.scrolled {
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
/* Brand sits dead-center in the bar; nav items flow around it */
.brand {
  display: flex; align-items: center; gap: 0.55rem; text-decoration: none;
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
}
/* The hamburger is pinned to the viewport's top-left so it never moves when
   the sidebar opens/closes; sidebar + topbar content clear it. */
.nav-toggle {
  /* vertically centered against the ~67px topbar. z-index MUST beat the
     topbar (1000): on non-hero pages the topbar is opaque and would otherwise
     paint over the hamburger (hiding it) and swallow its clicks. */
  position: fixed; top: 19px; left: 16px; z-index: 1100;
  background: rgba(0, 0, 0, 0.6); border: 1px solid var(--border); color: var(--text-secondary);
  font-size: 1.05rem; padding: 0.3rem 0.7rem; cursor: pointer; transition: color 0.3s ease, border-color 0.3s ease;
}
.nav-toggle:hover { color: var(--primary); border-color: var(--primary); }
body.has-toggle.sidebar-collapsed .topbar { padding-left: 4.6rem; }
body.sidebar-collapsed .sidebar { display: none; }
/* The hamburger + drawer exist for everyone, guests included — Browse lives in
   the menu, and auth-only entries prompt sign-in when clicked. */
.brand img { height: 40px; width: auto; transition: transform 0.3s ease; }
.brand:hover img { transform: scale(1.05); }
.brand span {
  /* sized to visually match the 34px Zipgo logo beside it */
  font-family: 'Orbitron', sans-serif; font-weight: 800; font-size: 1.85rem;
  line-height: 1; text-transform: uppercase; letter-spacing: 0.1em;
  position: relative; top: 2px;
}
.brand .hl {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.topbar a.nav-link, .topbar a:not(.brand):not(.btn) {
  color: var(--text-secondary); text-decoration: none;
  font-size: 0.95rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  position: relative; padding: 0.5rem 0;
  transition: color 0.3s ease;
}
.topbar a:not(.brand):not(.btn)::after {
  content: ''; position: absolute; bottom: 0; left: 0;
  width: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}
.topbar a:not(.brand):not(.btn):hover { color: var(--text-primary); }
.topbar a:not(.brand):not(.btn):hover::after { width: 100%; }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--text-muted); font-size: 0.9rem; letter-spacing: 0.05em; }
/* Username link (→ account settings). Keep it as typed, not uppercased. */
.topbar .user-link { text-transform: none; letter-spacing: 0.03em; }

/* ========================================
   Layout with sidebar
   ======================================== */
.layout { display: flex; min-height: 0; }
/* Sidebar runs the full height of the viewport, alongside (not under) the
   topbar; topbar + content shift right while it's open. */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 50;
  border-right: 1px solid var(--border);
  padding: 1.4rem 1.1rem; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(10px);
  overflow-y: auto;
}
body.with-sidebar:not(.sidebar-collapsed) .topbar,
body.with-sidebar:not(.sidebar-collapsed) .main,
body.with-sidebar:not(.sidebar-collapsed) #root { margin-left: 280px; }
.sidebar h3 {
  /* sits to the right of the pinned hamburger */
  margin: 0.55rem 0 1.2rem 3.2rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.3em; color: var(--primary); font-weight: 600;
}
.course-link {
  display: block; padding: 0.6rem 0.75rem; margin-bottom: 0.3rem;
  color: var(--text-primary); border: 1px solid transparent; font-size: 0.98rem; font-weight: 500;
  transition: all 0.3s ease;
}
.course-link:hover { background: var(--bg-card); border-color: var(--border); text-decoration: none; }
.course-link.active { background: rgba(0, 240, 255, 0.05); border-color: rgba(0, 240, 255, 0.3); box-shadow: inset 2px 0 0 var(--primary); }
.course-link .status { font-size: 0.75rem; color: var(--text-muted); display: block; letter-spacing: 0.08em; text-transform: uppercase; }
.course-link .status.generating { color: #ffc86b; }
.course-link .status.failed { color: #ff6b81; }
/* Site nav inside the drawer (all viewports — Browse etc. live here, not the
   topbar). Auth-only entries carry .needs-auth for guests. */
.drawer-nav {
  display: flex; flex-direction: column; gap: 0.5rem;
  /* left margin clears the pinned hamburger on desktop (mobile resets it) */
  margin: 0.55rem 0 1.1rem 3.2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.drawer-nav a {
  color: var(--text-secondary); padding: 0.4rem 0; text-transform: uppercase;
  font-size: 0.85rem; letter-spacing: 0.08em; cursor: pointer;
}
.drawer-nav a:hover { color: var(--primary); text-decoration: none; }
.drawer-nav a .lock { font-size: 0.75rem; opacity: 0.7; margin-left: 0.4rem; }
.main { flex: 1; padding: 2.2rem; min-width: 0; }

/* ========================================
   Hero (home) — zipgo.ai hero pattern
   ======================================== */
/* Home: the INPUT ROW sits at the vertical center of the page — the block is
   flex-centered, then padded at the bottom by roughly the height of the
   title area above the input so the row itself lands on center. */
/* Column layout: the hero fills the first viewport; marketing sections
   (how-it-works, chips, pricing, FAQ) follow below the fold. */
.hero-main { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
.hero-main .hero { min-height: calc(100dvh - 80px); display: flex; flex-direction: column; justify-content: center; }

/* ---- Below-the-fold marketing sections (the homepage IS the landing page) */
.mkt { width: min(1000px, 100%); margin: 0 auto; padding: 3.2rem 1.4rem 0; text-align: center; }
.mkt:last-of-type { padding-bottom: 4rem; }
.mkt h2 {
  font-family: 'Orbitron', sans-serif; font-size: 1.5rem; letter-spacing: 0.08em;
  text-transform: uppercase; margin-bottom: 1.6rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.mkt-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.2rem; text-align: left; }
.mkt-step { border: 1px solid var(--border); background: rgba(0, 0, 0, 0.5); padding: 1.4rem 1.5rem; }
.mkt-step .n {
  font-family: 'Orbitron', sans-serif; font-size: 1.6rem; color: var(--primary);
  text-shadow: 0 0 16px rgba(0, 240, 255, 0.5);
}
.mkt-step h3 { margin: 0.5rem 0 0.5rem; font-size: 1.05rem; }
.mkt-step p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.6; }
.mkt-chips { display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: center; }
.mkt-chip {
  padding: 0.5rem 1.2rem; cursor: pointer; font-family: 'Rajdhani', sans-serif; font-size: 1rem;
  color: var(--text-primary); background: rgba(0, 0, 0, 0.55); border: 1px solid var(--border);
  transition: all 0.25s ease;
}
.mkt-chip:hover { color: var(--primary); border-color: var(--primary); box-shadow: var(--glow); transform: translateY(-2px); }
.mkt-price { max-width: 560px; margin: 0 auto; }
.mkt-price-line { font-size: 1.25rem; }
.mkt-price-line strong { color: var(--primary); }
.mkt-faq { max-width: 720px; text-align: left; }
.mkt-faq h2 { text-align: center; }
.mkt-faq details { border: 1px solid var(--border); background: rgba(0, 0, 0, 0.5); margin-bottom: 0.6rem; padding: 0.9rem 1.2rem; }
.mkt-faq summary { cursor: pointer; font-weight: 600; letter-spacing: 0.02em; }
.mkt-faq summary:hover { color: var(--primary); }
.mkt-faq p { color: var(--text-secondary); margin-top: 0.6rem; line-height: 1.6; }
.hero { max-width: 1000px; margin: 10vh auto 0; text-align: center; padding: 2rem; }
.hero-main .hero { margin: 0 auto; padding-bottom: clamp(140px, 24vh, 220px); }
.hero h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 800; line-height: 1.1; margin-bottom: 1.5rem;
}
.hero h1 .title-line {
  display: block; color: var(--text-secondary);
  font-size: 0.5em; letter-spacing: 0.3em; margin-bottom: 0.5rem;
}
.hero h1 .title-highlight {
  display: block;
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: gradient-shift 5s ease infinite;
  background-size: 200% 200%;
}
@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.hero p.sub {
  font-size: clamp(1rem, 2vw, 1.3rem); color: var(--text-secondary);
  max-width: 640px; margin: 0 auto 2.5rem; letter-spacing: 0.05em;
}
.section-tag {
  display: inline-block; font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.3em;
  color: var(--primary); margin-bottom: 1rem; padding: 0.5rem 1.5rem;
  border: 1px solid rgba(0, 240, 255, 0.3); background: rgba(0, 240, 255, 0.05);
}
.topic-form { display: flex; gap: 1rem; margin: 3.2rem auto 1.2rem; max-width: 760px; }
/* The input is the main focal point: tallest element in the row (the cog
   stretches to match) with a brighter-than-default outline. The [type=text]
   in the selector outranks the later global input[type=text] rule, which
   would otherwise shrink the padding and add a bottom margin (making the
   input shorter than the stretched cog). */
.topic-form input[type=text] {
  flex: 1; padding: 0.8rem 1.4rem; margin: 0; font-size: 1.2rem;
  border: 1px solid rgba(0, 240, 255, 0.45); background: rgba(0, 0, 0, 0.6);
  color: var(--text-primary);
  font-family: inherit; letter-spacing: 0.03em; transition: all 0.3s ease;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.12);
}
.topic-form input[type=text]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.35);
}
.input-tip {
  max-width: 760px; margin: 0 auto 1.5rem; padding: 1rem 1.2rem;
  border: 1px solid rgba(0, 240, 255, 0.3); background: rgba(0, 240, 255, 0.03);
  text-align: left;
}
.input-tip p { color: var(--text-secondary); margin-bottom: 0.8rem; font-size: 0.98rem; }
.input-tip-actions { display: flex; gap: 0.7rem; justify-content: flex-end; }
.model-select {
  padding: 0 1rem; border: 1px solid var(--border); background: rgba(0, 0, 0, 0.55);
  color: var(--text-primary); font-family: 'Orbitron', sans-serif; font-size: 0.82rem;
  letter-spacing: 0.06em; cursor: pointer;
}
.model-select:focus { outline: none; border-color: var(--primary); box-shadow: var(--glow); }
.model-select option { background: #050508; }
.cog-wrap { position: relative; display: flex; }
.btn-cog {
  width: 54px; align-self: stretch; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; transition: all 0.3s ease;
}
.btn-cog:hover { color: var(--primary); border-color: var(--primary); box-shadow: var(--glow); }
.btn-cog:hover svg { transform: rotate(45deg); }
.btn-cog svg { transition: transform 0.4s ease; }
.model-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 20;
  width: max-content; min-width: 200px; max-width: 90vw;
  padding: 1rem 1.1rem; text-align: left;
  background: #05050a; border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), var(--glow);
}
.model-pop .model-select { width: 100%; }

/* Processing-tier picker under the topic form */
.tier-row { display: flex; align-items: center; justify-content: center; gap: 0.8rem; margin-top: 0.9rem; }
.tier-opt { cursor: pointer; }
.tier-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tier-opt span {
  display: inline-block; padding: 0.35rem 1.1rem; border: 1px solid var(--border);
  font-family: 'Orbitron', sans-serif; font-size: 0.78rem; letter-spacing: 0.08em;
  color: var(--text-secondary); background: rgba(0, 0, 0, 0.55); transition: all 0.25s ease;
}
.tier-opt input:checked + span { color: var(--primary); border-color: var(--primary); box-shadow: var(--glow); }
.tier-opt:hover span { border-color: var(--primary); }

/* Generic modal (estimate quote, prerequisites, …) */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 6, 0.72); backdrop-filter: blur(4px);
}
/* display:flex above would defeat the hidden attribute without this */
.modal-backdrop[hidden] { display: none; }
.modal { width: min(440px, 92vw); text-align: left; }
.est-price {
  font-family: 'Orbitron', sans-serif; font-size: 1.35rem; color: var(--primary);
  margin: 0.6rem 0 0.2rem; text-shadow: 0 0 18px rgba(0, 240, 255, 0.45);
}

/* ========================================
   Buttons (zipgo.ai .btn / .btn-primary / .btn-secondary)
   ======================================== */
.btn {
  --cut: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.75rem;
  padding: 1rem 2.5rem;
  font-family: 'Orbitron', sans-serif; font-size: 0.9rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none;
  border: none; border-radius: 0; cursor: pointer; position: relative; overflow: hidden;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg-dark);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 10px 40px rgba(0, 240, 255, 0.4); text-decoration: none; }
/* Outlined variant: clip-path would clip a real border off at the cut
   corners, so the outline is the button's own background showing through a
   1px-inset fill layer clipped to a matching smaller polygon. */
.btn.secondary {
  background: var(--border); color: var(--text-primary);
}
.btn.secondary::before {
  content: ''; position: absolute; inset: 1px; z-index: -1;
  background: #07070c;
  clip-path: polygon(0 0, calc(100% - var(--cut) + 1px) 0, 100% calc(var(--cut) - 1px), 100% 100%, calc(var(--cut) - 1px) 100%, 0 calc(100% - var(--cut) + 1px));
  transition: background 0.3s ease;
}
.btn.secondary:hover { background: var(--primary); color: var(--primary); box-shadow: none; }
.btn.small {
  --cut: 9px;
  padding: 0.45rem 1.1rem; font-size: 0.72rem;
}
.btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

/* ========================================
   Cards (zipgo.ai .feature-card)
   ======================================== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 1.6rem 1.8rem; margin-bottom: 1rem;
  position: relative; overflow: hidden; transition: all 0.4s ease;
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  transform: scaleX(0); transition: transform 0.4s ease;
}
.card:hover { border-color: rgba(0, 240, 255, 0.3); }
.card:hover::before { transform: scaleX(1); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.2rem; }
.grid .card:hover { transform: translateY(-5px); }
.grid .card h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.8rem; }
.muted { color: var(--text-secondary); }
.error { color: #ff6b81; }
.ok { color: var(--primary); }

/* Forms */
input[type=email], input[type=password], input[type=text] {
  width: 100%; padding: 0.8rem 1rem; margin-bottom: 1rem;
  border: 1px solid var(--border); background: rgba(0, 0, 0, 0.55); color: var(--text-primary);
  font-size: 1.05rem; font-family: inherit; transition: all 0.3s ease;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: var(--glow); }
label {
  display: block; font-size: 0.72rem; color: var(--primary); margin-bottom: 0.35rem;
  text-transform: uppercase; letter-spacing: 0.25em; font-weight: 600;
  font-family: 'Orbitron', sans-serif;
}

/* ========================================
   Generation progress
   ======================================== */
.phases { margin: 1.3rem 0; }
.phase-row { padding: 0.55rem 0; }
.phase-head { display: flex; align-items: center; gap: 0.85rem; font-size: 1.05rem; letter-spacing: 0.03em; margin-bottom: 0.4rem; }
.phase-note { font-size: 0.85rem; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--border); flex-shrink: 0; transition: all 0.3s ease; }
.dot.running { background: var(--primary); box-shadow: var(--glow); animation: pulse 1.2s ease-in-out infinite; }
.dot.done { background: var(--primary); }
.dot.failed { background: #ff6b81; }
@keyframes pulse { 50% { opacity: 0.35; } }
/* Per-phase progress bar */
.phase-bar {
  height: 6px; background: rgba(255, 255, 255, 0.06); overflow: hidden; position: relative;
}
.phase-fill {
  height: 100%; width: 0; transition: width 0.5s ease;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}
.phase-bar.failed .phase-fill { background: #ff6b81; }
/* Running phases with no known fraction show an indeterminate sweep */
.phase-bar.running .phase-fill { width: 100% !important; opacity: 0.5;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: phase-sweep 1.4s ease-in-out infinite;
}
@keyframes phase-sweep {
  0% { background-position: -40% 0; }
  100% { background-position: 140% 0; }
}
.gen-footer { display: flex; align-items: center; gap: 1.2rem; margin-top: 1.2rem; flex-wrap: wrap; }
.cost-tag {
  font-family: 'Orbitron', sans-serif; font-size: 0.82rem; letter-spacing: 0.05em;
  color: var(--primary); border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 0.5rem 1rem; background: rgba(0, 240, 255, 0.04);
}
.genlog {
  background: var(--bg-card); border: 1px solid var(--border);
  font-family: ui-monospace, monospace; font-size: 0.8rem; padding: 1rem;
  max-height: 45vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  color: var(--text-secondary);
}

/* ========================================
   Course player
   ======================================== */
.player { display: flex; gap: 0; flex: 1 0 auto; min-height: 0; }
.modnav {
  width: 310px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 1.2rem;
  overflow-y: auto; max-height: calc(100vh - 67px); position: sticky; top: 67px;
  background: rgba(0, 0, 0, 0.5);
}
.modnav h2 { font-size: 1rem; margin: 0.2rem 0 0.4rem; }
.modnav .desc { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1.2rem; }
.mod-item {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.65rem;
  cursor: pointer; font-size: 0.95rem; border: 1px solid transparent; transition: all 0.3s ease;
}
.mod-item:hover { background: var(--bg-card); border-color: var(--border); }
.mod-item.active {
  background: rgba(0, 240, 255, 0.05); border-color: rgba(0, 240, 255, 0.3);
  box-shadow: inset 2px 0 0 var(--course-accent);
}
.mod-item.locked { opacity: 0.4; cursor: not-allowed; }
.mod-item .kind {
  font-size: 0.64rem; color: var(--course-accent); text-transform: uppercase;
  letter-spacing: 0.2em; display: block; font-weight: 600; font-family: 'Orbitron', sans-serif;
}
.mod-check { width: 16px; text-align: center; flex-shrink: 0; color: var(--primary); }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-frame { flex: 1; border: 0; width: 100%; min-height: calc(100vh - 140px); background: var(--bg-dark); }
.content-head {
  display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1.4rem;
  border-bottom: 1px solid var(--border); background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(20px);
}
.content-head h3 { margin: 0; font-size: 0.92rem; flex: 1; }
.content-tools { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  background: rgba(0, 240, 255, 0.06); border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; transition: all 0.3s ease;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); box-shadow: var(--glow); }
.icon-btn.active { color: #000; background: var(--primary); border-color: var(--primary); box-shadow: var(--glow); }

/* Inspect & explain popup + notes panel */
.zl-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
}
.zl-pop {
  width: min(560px, 100%); max-height: 82vh; display: flex; flex-direction: column;
  background: #05050c; border: 1px solid rgba(0, 240, 255, 0.35);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), var(--glow);
}
.zl-pop.zl-notes { width: min(640px, 100%); }
.zl-pop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--border);
  font-family: 'Orbitron', sans-serif; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--primary);
}
.zl-x { background: none; border: 0; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; }
.zl-x:hover { color: var(--primary); }
.zl-pop-body { padding: 1.2rem; overflow-y: auto; }
.zl-loading { display: flex; align-items: center; gap: 0.6rem; color: var(--text-secondary); }
.zl-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(0, 240, 255, 0.25); border-top-color: var(--primary);
  animation: zl-spin 0.8s linear infinite;
}
@keyframes zl-spin { to { transform: rotate(360deg); } }
.zl-answer { white-space: pre-wrap; line-height: 1.65; color: var(--text-primary); }
.zl-pop-actions { display: flex; align-items: center; margin-top: 1.2rem; }
.zl-note { border: 1px solid var(--border); padding: 0.9rem 1rem; margin-bottom: 0.9rem; }
.zl-note-src { color: var(--primary); font-size: 0.85rem; font-style: italic; margin-bottom: 0.5rem; }
.zl-note-ans { white-space: pre-wrap; line-height: 1.6; margin-bottom: 0.7rem; font-size: 0.95rem; }

/* Floating Ask AI button — outline (cut-corner) by default with a cyan wand,
   fills with the site gradient on hover. display toggled by JS. */
.zl-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 1500;
  display: none; align-items: center; justify-content: center;
  width: 56px; height: 56px; padding: 0; cursor: pointer;
  background: #05050c; color: var(--primary); border: 1px solid var(--primary);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  box-shadow: 0 8px 30px rgba(0, 240, 255, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.zl-fab:hover {
  background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #000;
  transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0, 240, 255, 0.5);
}
/* Stacked FABs: wand at the bottom, feedback above it, prerequisites on top */
.zl-fab.fb { bottom: 92px; color: var(--secondary); border-color: var(--secondary); box-shadow: 0 8px 30px rgba(139, 92, 246, 0.2); }
.zl-fab.fb:hover { background: linear-gradient(135deg, var(--secondary), var(--primary)); color: #000; }
.zl-fab.pr { bottom: 162px; }
.zl-fab.active {
  background: linear-gradient(135deg, var(--warn), #e0a94b); color: #000; border-color: var(--warn);
  animation: fab-pulse 1.2s ease-in-out infinite;
}
@keyframes fab-pulse { 50% { box-shadow: 0 8px 34px rgba(255, 200, 107, 0.65); } }

/* Ask AI chat window */
.zl-chat {
  position: fixed; right: 22px; bottom: 22px; z-index: 1600;
  width: min(390px, calc(100vw - 24px)); height: min(72vh, 580px);
  display: flex; flex-direction: column;
  background: #05050c; border: 1px solid rgba(0, 240, 255, 0.35);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), var(--glow);
}
.zl-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 0.9rem 0.7rem 1.1rem; border-bottom: 1px solid var(--border);
  font-family: 'Orbitron', sans-serif; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--primary);
}
.zl-chat-head-btns { display: flex; align-items: center; gap: 0.6rem; }
.zl-chat-save {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  font-size: 0.72rem; padding: 0.25rem 0.6rem; cursor: pointer;
}
.zl-chat-save:hover { color: var(--primary); border-color: var(--primary); }
.zl-chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.zl-ctx { font-size: 0.78rem; color: var(--primary); font-style: italic; border-left: 2px solid rgba(0, 240, 255, 0.4); padding-left: 0.6rem; }
.zl-msg { max-width: 90%; }
.zl-msg.me { align-self: flex-end; }
.zl-msg.ai { align-self: flex-start; }
.zl-msg-text { padding: 0.6rem 0.8rem; font-size: 0.92rem; line-height: 1.55; white-space: pre-wrap; }
.zl-msg.me .zl-msg-text { background: rgba(0, 240, 255, 0.1); border: 1px solid rgba(0, 240, 255, 0.3); }
.zl-msg.ai .zl-msg-text { background: var(--bg-card); border: 1px solid var(--border); }
.zl-chat-input { display: flex; gap: 0.5rem; padding: 0.7rem; border-top: 1px solid var(--border); }
.zl-chat-input input { flex: 1; margin: 0; padding: 0.55rem 0.7rem; font-size: 0.92rem; }

/* ========================================
   Quiz runner
   ======================================== */
.quiz-wrap { max-width: 780px; margin: 1.6rem auto; padding: 0 1.4rem 3rem; width: 100%; }
.question { margin-bottom: 1.6rem; }
.question .prompt { font-weight: 600; margin-bottom: 0.55rem; font-size: 1.12rem; }
.choice {
  display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.55rem 0.7rem;
  cursor: pointer; border: 1px solid transparent; transition: all 0.3s ease;
}
.choice:hover { background: var(--bg-card); border-color: var(--border); }
.qresult { padding: 0.6rem 0.9rem; margin-top: 0.5rem; font-size: 0.93rem; border: 1px solid transparent; }
.qresult.correct { background: rgba(0, 240, 255, 0.06); border-color: rgba(0, 240, 255, 0.3); color: var(--primary); }
.qresult.wrong { background: rgba(255, 107, 129, 0.08); border-color: rgba(255, 107, 129, 0.3); color: #ff6b81; }
.score-banner { text-align: center; padding: 1.6rem; margin-bottom: 1.6rem; border: 1px solid var(--border); background: var(--bg-card); }
.score-banner.pass { border-color: rgba(0, 240, 255, 0.35); box-shadow: var(--glow); }
.score-banner.fail { border-color: rgba(255, 107, 129, 0.35); }
.score-banner .big { font-size: 2.6rem; font-weight: 800; font-family: 'Orbitron', sans-serif; }

/* ========================================
   Admin table + badges
   ======================================== */
table.admin { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
table.admin th, table.admin td { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border); }
table.admin th {
  color: var(--primary); font-weight: 600; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.25em; font-family: 'Orbitron', sans-serif;
}
.badge {
  display: inline-block; padding: 0.14rem 0.65rem; font-size: 0.68rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em;
  font-family: 'Orbitron', sans-serif;
}
.badge.verified { background: rgba(0, 240, 255, 0.05); color: var(--primary); border: 1px solid rgba(0, 240, 255, 0.3); }
.badge.generating { background: rgba(255, 200, 107, 0.06); color: #ffc86b; border: 1px solid rgba(255, 200, 107, 0.35); }
.badge.failed { background: rgba(255, 107, 129, 0.06); color: #ff6b81; border: 1px solid rgba(255, 107, 129, 0.35); }
.badge.ready { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }
.badge.locked { background: rgba(139, 92, 246, 0.1); color: var(--secondary); border: 1px solid rgba(139, 92, 246, 0.4); }

/* The drawer backdrop only exists on mobile (created in JS, always in DOM) */
.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
  /* ---- Topbar: brand flows normally (not absolute-centered); secondary
         nav moves into the drawer for signed-in users ---- */
  /* Mobile top bar: hamburger (fixed), logo, account slot. Everything else
     moves into the drawer. Applies to guests too. */
  .topbar { padding: 0.7rem 1rem; gap: 1rem; }
  body.has-toggle .topbar { padding-left: 3.7rem; } /* clear the fixed hamburger */
  /* Brand stays absolutely centered (inherits desktop rule) — never flows left */
  .brand img { height: 28px; }
  body.has-toggle .topbar .topbar-nav-item { display: none; }
  /* Keep a long username from colliding with the centered logo */
  .topbar .user-link { max-width: 26vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .nav-toggle { top: 14px; }

  /* ---- Sidebar becomes an overlay drawer: never pushes content ---- */
  body.with-sidebar .topbar,
  body.with-sidebar .main,
  body.with-sidebar #root { margin-left: 0 !important; }
  .sidebar {
    display: block !important; /* stay in DOM so the slide transition runs */
    width: min(84vw, 320px);
    z-index: 1050; /* above the topbar (1000) so the drawer isn't clipped */
    padding-top: 3.6rem; /* clear the fixed hamburger at the top */
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
  }
  body:not(.sidebar-collapsed) .sidebar { transform: translateX(0); }
  .sidebar h3, .drawer-nav { margin-left: 0; } /* hamburger is above, not beside, on mobile */
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1040;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
  }
  body.with-sidebar:not(.sidebar-collapsed) .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  /* ---- Main + hero ---- */
  .main { padding: 1.3rem 1.1rem; }
  .hero { padding: 1.2rem; }
  .hero-main .hero { padding-bottom: clamp(80px, 14vh, 160px); }
  .topic-form { flex-wrap: wrap; gap: 0.6rem; margin-top: 2rem; }
  .topic-form input[type=text] { flex: 1 1 180px; font-size: 1.05rem; }
  .topic-form .btn { flex: 1 1 100%; }
  .input-tip-actions { justify-content: stretch; }

  /* ---- Cards, grid ---- */
  .grid { grid-template-columns: 1fr; }
  .card { padding: 1.2rem 1.3rem; }

  /* ---- Course player: the lesson/quiz fills the screen; the module list is
         moved into the hamburger drawer by course.html (.modnav.in-drawer) ---- */
  .player { flex-direction: column; }
  .modnav.in-drawer {
    width: auto; position: static; max-height: none; overflow: visible;
    border: 0; padding: 0; background: none;
    margin-bottom: 1.2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
  }
  .modnav.in-drawer h2 { font-size: 0.95rem; }
  .modnav.in-drawer .desc { font-size: 0.82rem; }
  .content-frame { min-height: calc(100dvh - 112px); }

  /* ---- Admin table scrolls horizontally instead of overflowing ---- */
  table.admin { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 480px) {
  .topbar { padding-right: 0.8rem; }
  .brand span { font-size: 1.25rem; }
  .hero h1 { margin-bottom: 1rem; }
  .btn { padding: 0.9rem 1.6rem; }
  .quiz-wrap { padding: 0 0.9rem 3rem; }
  .score-banner .big { font-size: 2rem; }
}
