/* ============================================================================
   GOLEARNAI — learning-specific components, layered on top of glass.css.
   Reuses glass.css design tokens (--bg, --yellow, --text, --glass-*, etc.).
   ============================================================================ */
:root {
  --sans: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
  --mono: 'Courier New', Consolas, Monaco, monospace;

  /* 8px spacing scale */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-8: 48px; --space-10: 64px;
  /* Type scale */
  --fs-caption: .78rem; --fs-body: .95rem; --fs-lead: 1.08rem;
  --fs-h3: 1.25rem; --fs-h2: 1.6rem; --fs-h1: 2.2rem; --fs-display: clamp(2.4rem, 5vw, 4rem);
  --ai-from: #7c3aed;
  --ai-to:   #6366f1;
  --code-bg: #0d1117;
  --sidebar-w: 290px;
  --nav-h: 56px;   /* actual navbar height; refined at runtime by lesson.js */

  /* Consistent radius + soft shadows. The glass background/border/blur come from
     the existing navy glass tokens defined in glass.css (no white frosting). */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-soft: 0 8px 30px rgba(0,6,30,0.34), 0 2px 8px rgba(0,6,30,0.22);
  --shadow-lift: 0 18px 48px rgba(0,12,60,0.40), 0 4px 12px rgba(0,6,30,0.24);
}

/* Reusable reference-glass utility */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-bd);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: var(--shadow-soft);
}

/* Accessibility: visible focus + skip link */
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; border-radius: 6px; }
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 3000;
  background: var(--yellow); color: #012A4A; font-weight: 700; padding: .6rem 1rem; border-radius: 10px; text-decoration: none;
}
.skip-link:focus { left: 8px; }

body { font-family: var(--sans); color: var(--text); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.home-title, .hero-title, .console-title, .lesson-h1, .auth-card h1, .section-head h2, .dp-name { letter-spacing: -0.02em; }
a { color: #7ab4ff; }
.text-muted-2 { color: var(--muted); }

/* ── Brand word in navbar ── */
/* Make <button> avatar-menu items (e.g. Logout) match the <a> items exactly */
button.nld-item { background: none; border: none; width: 100%; text-align: left; cursor: pointer; font: inherit; }

/* ── Scroll-reveal ── */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s cubic-bezier(.16,1,.3,1); }
.reveal.revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1 !important; transform: none !important; } }

/* ── Settings (royal, tabbed) ── */
.settings-wrap { padding: 2.4rem 0 4rem; max-width: 920px; }
.settings-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.6rem; }
.set-avatar { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.3rem; color: #fff; box-shadow: var(--shadow-soft); }
.settings-title { font-size: 1.8rem; font-weight: 800; letter-spacing: -.02em; }
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.4rem; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: .3rem; position: sticky; top: calc(var(--nav-h) + 16px); }
.set-tab { display: flex; align-items: center; gap: .6rem; text-align: left; background: none; border: 1px solid transparent; color: var(--muted); font-weight: 600; font-size: .92rem; padding: .65rem .9rem; border-radius: 12px; cursor: pointer; transition: all .2s; }
.set-tab:hover { color: var(--text); background: var(--glass-bg); }
.set-tab.active { color: var(--text); background: var(--glass-bg); border-color: var(--yellow-bd); }
.set-tab.active i { color: var(--yellow); }
.set-panel { display: none; padding: 1.8rem; border-radius: var(--radius-lg); }
.set-panel.active { display: block; animation: pageFade .3s ease both; }
.set-h { font-size: 1.3rem; font-weight: 800; }
.set-sub { color: var(--muted); font-size: .9rem; margin-bottom: 1.2rem; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.pro-badge { font-size: .68rem; font-weight: 800; letter-spacing: .04em; padding: 2px 9px; border-radius: 9px; color: #1a1200;
  background: linear-gradient(135deg, var(--yellow), #ffd600); }
.pro-status { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.2rem; border-radius: var(--radius-md); font-weight: 600;
  background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.35); color: #9fe3c0; }
.pro-status i { font-size: 1.2rem; }
.upgrade-card { text-align: center; padding: 1.4rem .5rem; }
.up-badge { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: #1a1200;
  background: linear-gradient(135deg, var(--yellow), #ffd600); box-shadow: 0 10px 30px rgba(248,237,8,.4); }
.upgrade-card h3 { font-size: 1.3rem; font-weight: 800; margin-bottom: .4rem; }
.up-list { list-style: none; margin: 1.2rem auto; padding: 0; max-width: 360px; text-align: left; display: flex; flex-direction: column; gap: .5rem; }
.up-list li { display: flex; gap: .6rem; align-items: center; color: var(--text); font-size: .92rem; }
.up-list i { color: #4ade80; }
.up-note { font-size: .78rem; color: var(--muted); margin-top: .8rem; }
.ai-fab.locked { background: linear-gradient(135deg, #3a3550, #2a2740); box-shadow: 0 10px 30px rgba(0,0,0,.4); opacity: .92; }
.ai-fab.locked:hover { opacity: 1; }
@media (max-width: 760px) { .settings-layout { grid-template-columns: 1fr; } .settings-nav { flex-direction: row; flex-wrap: wrap; position: static; } .set-grid { grid-template-columns: 1fr; } }

/* ── Command palette trigger (navbar) ── */
.cmdk-trigger {
  align-items: center; gap: .5rem; margin-left: 1rem; padding: .42rem .8rem; cursor: pointer;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: 12px; color: var(--muted); font-size: .82rem;
  transition: border-color .2s, color .2s;
}
.cmdk-trigger:hover { border-color: var(--yellow-bd); color: var(--text); }
.cmdk-trigger kbd { background: rgba(255,255,255,.08); border: 1px solid var(--glass-bd); border-radius: 6px; padding: 1px 6px; font-size: .72rem; color: var(--text); }

/* ── Command palette overlay ── */
.cmdk-overlay { position: fixed; inset: 0; z-index: 2500; background: rgba(2,8,24,.6); backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
body.cmdk-open { overflow: hidden; }
.cmdk { width: min(92vw, 600px); border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,4,30,.6); animation: cmdkIn .16s cubic-bezier(.16,1,.3,1); }
@keyframes cmdkIn { from { opacity: 0; transform: translateY(-12px) scale(.98); } to { opacity: 1; transform: none; } }
.cmdk-input-row { display: flex; align-items: center; gap: .6rem; padding: .9rem 1rem; border-bottom: 1px solid var(--glass-bd); }
.cmdk-input-row > i { color: var(--muted); font-size: 1.05rem; }
.cmdk-input-row input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 1.02rem; }
.cmdk-input-row input::placeholder { color: var(--muted); }
.cmdk-esc { background: rgba(255,255,255,.07); border: 1px solid var(--glass-bd); border-radius: 6px; padding: 1px 7px; font-size: .7rem; color: var(--muted); }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: .4rem; }
.cmdk-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: .6rem .7rem .3rem; }
.cmdk-item { display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left; padding: .6rem .7rem; border-radius: 10px; background: none; border: none; cursor: pointer; color: var(--text); text-decoration: none; font-size: .92rem; }
.cmdk-item i { color: var(--muted); width: 18px; }
.cmdk-item .cmdk-meta { margin-left: auto; font-size: .76rem; color: var(--muted); }
.cmdk-item span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item:hover, .cmdk-item.active { background: rgba(255,255,255,.07); }
.cmdk-item.active i, .cmdk-item.active span:nth-child(2) { color: var(--yellow); }
.cmdk-empty { padding: 1.2rem; text-align: center; color: var(--muted); }
.cmdk-foot { display: flex; gap: 1rem; padding: .6rem 1rem; border-top: 1px solid var(--glass-bd); font-size: .72rem; color: var(--muted); }
.cmdk-foot kbd { background: rgba(255,255,255,.07); border: 1px solid var(--glass-bd); border-radius: 5px; padding: 0 5px; margin-right: 2px; }

/* ── Hero trust strip ── */
.trust-strip {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 1.4rem;
  max-width: 720px; margin: 2rem auto 0; padding: 1rem 1.6rem;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%); box-shadow: var(--shadow-soft);
}
.trust-item { text-align: center; }
.trust-num { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; background: linear-gradient(90deg, var(--yellow), #ffd600); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; line-height: 1; }
.trust-label { font-size: .74rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }
.trust-divider { width: 1px; height: 34px; background: var(--glass-bd); }
@media (max-width: 560px) { .trust-divider { display: none; } .trust-strip { gap: 1rem 1.6rem; } }

.brand-word { font-weight: 800; letter-spacing: .02em; color: var(--text); font-size: 1.05rem; }
.brand-word .brand-ai {
  background: linear-gradient(90deg, var(--yellow), #ffd600);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.nav-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .8rem; font-weight: 600; text-decoration: none;
  color: var(--text); background: var(--glass-bg);
  border: 1px solid var(--glass-bd); border-radius: 18px; padding: .35rem .8rem;
  transition: border-color .2s, transform .15s;
}
.nav-pill:hover { border-color: var(--yellow-bd); transform: translateY(-1px); color: var(--text); }
.nav-avatar-circle {
  width: 36px; height: 36px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: .74rem; font-weight: 800;
  color: #fff; letter-spacing: .03em; text-transform: uppercase;
  box-shadow: 0 0 0 2.5px rgba(255,255,255,.18), 0 2px 10px rgba(0,0,0,.45);
}

/* ── Alerts ── */
.gc-alert {
  border-radius: 12px; padding: .7rem 1rem; margin-bottom: .6rem; font-size: .9rem;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--text);
}
.gc-alert-success { border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.12); }
.gc-alert-error, .gc-alert-danger { border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.12); }

/* ── Buttons ── */
.btn-yellow {
  background: var(--yellow); color: #012A4A; font-weight: 700; border: none;
  border-radius: 28px; padding: .7rem 1.8rem; font-size: 1rem; text-decoration: none;
  display: inline-flex; align-items: center; gap: .5rem; transition: transform .15s, box-shadow .2s, background .2s;
}
.btn-yellow:hover { background: #fffb6e; transform: translateY(-2px); box-shadow: 0 8px 26px rgba(248,237,8,.35); color: #012A4A; }
.btn-glass {
  background: var(--glass-bg); color: var(--text); border: 1px solid var(--glass-bd);
  border-radius: 28px; padding: .7rem 1.6rem; text-decoration: none; display: inline-flex; align-items: center; gap: .5rem;
  transition: border-color .2s, transform .15s;
}
.btn-glass:hover { border-color: var(--yellow-bd); transform: translateY(-2px); color: var(--text); }

/* ============================================================================
   HOME — prompt hero + recent courses
   ============================================================================ */
.home-hero { padding: 4.5rem 0 2rem; text-align: center; position: relative; }
.home-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(124,58,237,.2); border: 1px solid rgba(124,58,237,.4); color: #c4b5fd;
  padding: 5px 14px; border-radius: 20px; font-size: .76rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; margin-bottom: 1.3rem;
}
.home-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: #a78bfa; animation: ping 1.6s ease-in-out infinite; }
@keyframes ping { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .4; transform: scale(1.4);} }
.home-title { font-size: clamp(2.2rem, 4.5vw, 3.8rem); font-weight: 800; line-height: 1.08; letter-spacing: -.02em; }
.home-title .grad {
  background: linear-gradient(90deg, var(--yellow), #ffd600);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.home-sub { color: var(--muted); font-size: 1.08rem; max-width: 620px; margin: 1rem auto 0; line-height: 1.65; }

.prompt-card {
  max-width: 720px; margin: 2rem auto 0; background: var(--glass-bg);
  border: 1px solid var(--glass-bd); border-radius: 22px; padding: .9rem 1rem .85rem;
  box-shadow: 0 18px 60px rgba(0,10,50,.45); backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  transition: border-color .25s, box-shadow .25s; text-align: left;
}
.prompt-card:focus-within {
  border-color: var(--yellow-bd);
  box-shadow: 0 18px 60px rgba(0,10,50,.45), 0 0 0 4px var(--yellow-dim);
}
.prompt-card textarea {
  width: 100%; background: transparent; border: none; resize: none; outline: none;
  color: var(--text); font-size: 1.08rem; line-height: 1.55; padding: .35rem .6rem .75rem; min-height: 84px;
  font-family: inherit;
}
.prompt-card textarea::placeholder { color: var(--muted); }
/* Control bar: level selector (left) · generate (right), separated from the textarea */
.prompt-row {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .7rem .15rem 0; margin-top: .15rem; border-top: 1px solid var(--glass-bd);
  flex-wrap: wrap;
}
.prompt-hint {
  font-size: .8rem; color: var(--muted); text-align: center; max-width: 720px;
  margin: .7rem auto 0; display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.prompt-hint i { color: var(--yellow); }
/* Level selector — refined pill with custom caret */
.level-select {
  position: relative; display: inline-flex; align-items: center; gap: .5rem; cursor: pointer;
  background: var(--card-bg); border: 1px solid var(--card-bd); border-radius: 999px;
  padding: .45rem .55rem .45rem .85rem; font-size: .84rem; color: var(--text);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.level-select:hover { border-color: var(--yellow-bd); background: var(--yellow-dim); }
.level-select:focus-within { border-color: var(--yellow-bd); box-shadow: 0 0 0 3px var(--yellow-dim); }
.level-select > i:first-child { color: var(--yellow); font-size: .95rem; }
.level-select .level-label { color: var(--muted); font-weight: 500; }
.level-select select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background: transparent; border: none; outline: none; color: var(--text);
  font-size: .84rem; font-weight: 700; cursor: pointer; padding: 0 1.3rem 0 .1rem; font-family: inherit;
}
.level-select select option { background: #0a2540; color: var(--text); }
.level-caret {
  position: absolute; right: .8rem; pointer-events: none; color: var(--muted);
  font-size: .7rem; transition: transform .2s;
}
.level-select:focus-within .level-caret { transform: rotate(180deg); color: var(--yellow); }
.example-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1.2rem; }
.example-chip {
  background: var(--card-bg); border: 1px solid var(--card-bd); color: var(--text);
  font-size: .82rem; border-radius: 18px; padding: .35rem .9rem; cursor: pointer; transition: border-color .2s, transform .15s;
}
.example-chip:hover { border-color: var(--yellow-bd); transform: translateY(-1px); }

/* Weekly generation quota banner */
.quota-banner {
  max-width: 720px; margin: 1.1rem auto 0; text-align: center; font-size: .88rem;
  color: var(--muted); background: var(--glass-bg); border: 1px solid var(--glass-bd);
  border-radius: 14px; padding: .6rem 1rem;
}
.quota-banner strong { color: var(--text); }
.quota-banner i { color: var(--yellow); margin-right: 5px; }
.quota-banner.limit { color: #f3d77a; background: var(--yellow-dim); border-color: var(--yellow-bd); }
.btn-yellow[disabled], .btn-yellow[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; background: #cabf3a;
}

/* Course search */
.course-search {
  display: flex; align-items: center; gap: .6rem; max-width: 620px; margin: 0 auto 1.6rem;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: 16px;
  padding: .4rem .4rem .4rem .9rem; position: relative;
}
.course-search > i.bi-search { color: var(--muted); font-size: 1rem; }
.course-search input {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text);
  font-size: .95rem; padding: .5rem .2rem; min-width: 0;
}
.course-search input::placeholder { color: var(--muted); }
.course-search .btn-glass { padding: .5rem 1.1rem; border-radius: 12px; white-space: nowrap; }
.course-search .search-clear {
  color: var(--muted); text-decoration: none; font-size: 1.3rem; line-height: 1; padding: 0 .3rem;
}
.course-search .search-clear:hover { color: var(--yellow); }
@media (max-width: 480px) {
  .course-search { flex-wrap: wrap; padding: .5rem .7rem; }
  .course-search input { flex: 1 1 100%; }
  .course-search .btn-glass { flex: 1; text-align: center; justify-content: center; }
}

/* Live-search dropdown + states */
.search-wrap { position: relative; max-width: 620px; margin: 0 auto 1rem; }
.search-wrap .course-search { margin: 0; }
.search-ico { color: var(--muted); font-size: 1rem; }
.search-spin {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; opacity: 0;
  border: 2px solid rgba(255,255,255,.18); border-top-color: var(--yellow); transition: opacity .2s;
}
.search-spin.on { opacity: 1; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.search-clear { background: none; border: none; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 .3rem; }
.search-clear:hover { color: var(--yellow); }
.search-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 50;
  background: rgba(8,18,40,.92); border: 1px solid var(--glass-bd); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,8,40,.55); backdrop-filter: blur(20px) saturate(160%);
  padding: .35rem; max-height: 60vh; overflow-y: auto; animation: sdIn .18s cubic-bezier(.16,1,.3,1);
}
@keyframes sdIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.sd-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .5rem .7rem .3rem; }
.sd-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
  padding: .6rem .7rem; border-radius: 10px; text-decoration: none; color: var(--text);
  background: none; border: none; cursor: pointer; font-size: .9rem;
}
.sd-item:hover, .sd-item.active { background: rgba(255,255,255,.06); color: var(--text); }
.sd-item .sd-topic { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--yellow); background: var(--yellow-dim); border: 1px solid var(--yellow-bd); padding: 2px 7px; border-radius: 9px; white-space: nowrap; }
.sd-item .sd-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sd-item .sd-meta { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.sd-item.sd-history i { color: var(--muted); }
.sd-empty { padding: .9rem .8rem; color: var(--muted); font-size: .88rem; }
.search-status { text-align: center; color: var(--muted); font-size: .82rem; min-height: 1.1rem; margin-bottom: 1rem; }
#courseGrid { transition: opacity .25s ease; }
#courseGrid.grid-fade { opacity: .35; }

/* Skeleton loaders (shimmer) */
.sk { position: relative; overflow: hidden; background: rgba(255,255,255,.06); border-radius: 8px; }
.sk::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.09), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton-card { background: var(--card-bg); border: 1px solid var(--card-bd); border-radius: 18px; padding: 1.3rem 1.25rem; display: flex; flex-direction: column; gap: .7rem; }
.sk-chip { width: 70px; height: 18px; border-radius: 12px; }
.sk-line { height: 12px; } .sk-line.w90 { width: 90%; } .sk-line.w85 { width: 85%; } .sk-line.w80 { width: 80%; } .sk-line.w70 { width: 70%; } .sk-line.w60 { width: 60%; }
.sk-foot { height: 30px; border-radius: 8px; margin-top: .4rem; }

/* Toasts */
.toast-stack { position: fixed; top: 72px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: .6rem; max-width: 360px; width: calc(100vw - 32px); pointer-events: none; }
.gc-toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: .6rem; padding: .8rem .9rem;
  background: rgba(10,20,44,.92); border: 1px solid var(--glass-bd); border-left: 3px solid #7ab4ff;
  border-radius: 12px; box-shadow: 0 14px 40px rgba(0,8,40,.5); backdrop-filter: blur(18px) saturate(160%);
  color: var(--text); font-size: .9rem; opacity: 0; transform: translateX(20px); transition: opacity .3s, transform .3s;
}
.gc-toast.in { opacity: 1; transform: none; }
.gc-toast.out { opacity: 0; transform: translateX(20px); }
.gc-toast-ico { font-size: 1.05rem; margin-top: 1px; }
.gc-toast-msg { flex: 1; line-height: 1.4; }
.gc-toast-x { background: none; border: none; color: var(--muted); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 2px; }
.gc-toast-x:hover { color: var(--text); }
.gc-toast-success { border-left-color: #22c55e; } .gc-toast-success .gc-toast-ico { color: #4ade80; }
.gc-toast-error, .gc-toast-danger { border-left-color: #ef4444; } .gc-toast-error .gc-toast-ico, .gc-toast-danger .gc-toast-ico { color: #f87171; }
.gc-toast-warning { border-left-color: #f59e0b; } .gc-toast-warning .gc-toast-ico { color: #fbbf24; }
.gc-toast-info .gc-toast-ico { color: #7ab4ff; }
@media (max-width: 560px) { .toast-stack { left: 16px; right: 16px; max-width: none; } }

/* Generation steps */
.gen-steps { list-style: none; margin: 1.4rem 0 .4rem; padding: 0; text-align: left; max-width: 360px; margin-left: auto; margin-right: auto; }
.gen-steps li { display: flex; align-items: center; gap: .7rem; padding: .5rem .2rem; color: var(--muted); font-size: .92rem; transition: color .3s; }
.gen-steps .gs-ico { width: 22px; height: 22px; min-width: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; font-size: .7rem; transition: all .3s; }
.gen-steps li.done { color: var(--text); }
.gen-steps li.done .gs-ico { background: #22c55e; border-color: #22c55e; color: #04220f; }
.gen-steps li.done .gs-ico::before { content: '\2713'; font-weight: 700; }
.gen-steps li.active { color: var(--text); }
.gen-steps li.active .gs-ico { border-color: var(--yellow); border-top-color: transparent; animation: spin .7s linear infinite; }
.gen-skeleton { margin-top: 1rem; display: flex; flex-direction: column; gap: .6rem; max-width: 380px; margin-left: auto; margin-right: auto; }
.gen-skeleton .sk-line { height: 11px; }

/* Live lesson stream while generating */
.gen-lessons { margin-top: 1.2rem; display: flex; flex-direction: column; gap: .4rem; max-width: 440px; margin-left: auto; margin-right: auto; text-align: left; }
.gl-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; border-radius: 10px; font-size: .9rem; color: var(--muted);
  background: var(--glass-bg); border: 1px solid var(--glass-bd2); animation: glIn .35s ease both; }
@keyframes glIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.gl-ic { width: 22px; height: 22px; min-width: 22px; display: flex; align-items: center; justify-content: center; font-size: .78rem; }
.gl-row.done { color: var(--text); } .gl-row.done .gl-ic { color: #4ade80; }
.gl-row.active { color: var(--text); border-color: var(--yellow-bd); }
.gl-row.failed .gl-ic { color: #f87171; }
.gl-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.2); }
.gl-spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(248,237,8,.25); border-top-color: var(--yellow); animation: spin .7s linear infinite; }

.section-head { text-align: center; margin: 3.5rem 0 1.6rem; }
.section-head h2 { font-size: clamp(1.5rem, 2.5vw, 2.1rem); font-weight: 800; }
.section-head p { color: var(--muted); }

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.1rem; }
.course-card {
  background: var(--card-bg); border: 1px solid var(--card-bd); border-radius: var(--radius-lg); padding: 1.3rem 1.25rem;
  text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: .6rem;
  backdrop-filter: blur(var(--glass-blur)) saturate(160%); -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: var(--shadow-soft);
  transition: transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s, border-color .25s; position: relative;
}
.course-card:hover {
  transform: translateY(-6px); border-color: var(--yellow-bd);
  box-shadow: var(--shadow-lift); color: var(--text);
}
.course-card .cc-topic {
  align-self: flex-start; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--yellow); background: var(--yellow-dim); border: 1px solid var(--yellow-bd); padding: 2px 10px; border-radius: 12px;
}
.course-card .cc-title { font-size: 1.12rem; font-weight: 700; line-height: 1.25; }
.course-card .cc-desc { font-size: .86rem; color: var(--muted); line-height: 1.5; flex-grow: 1; }
.course-card .cc-meta { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .76rem; color: var(--muted); margin-top: .3rem; }
.course-card .cc-meta i { color: #7ab4ff; }
.course-card .cc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .4rem; border-top: 1px solid var(--glass-bd2); padding-top: .7rem; }
.course-card .cc-author { font-size: .76rem; color: var(--muted); }
.course-card .cc-view { font-size: .82rem; font-weight: 700; color: var(--yellow); display: inline-flex; gap: 4px; align-items: center; }
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-ill { width: 76px; height: 76px; margin: 0 auto .6rem; border-radius: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--yellow); background: var(--yellow-dim); border: 1px solid var(--yellow-bd); }

/* ── Logged-in workspace ── */
.workspace-section { padding: 1.5rem 0 0; }
.ws-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.1rem; }
.ws-greeting { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.ws-wave { display: inline-block; animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave { 0%,60%,100% { transform: rotate(0); } 10% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } 30% { transform: rotate(14deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } }
.ws-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ws-action { display: inline-flex; align-items: center; gap: 7px; font-size: .85rem; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--text); border-radius: 12px; padding: .5rem .9rem; transition: border-color .2s, transform .15s; }
.ws-action:hover { border-color: var(--yellow-bd); transform: translateY(-1px); color: var(--text); }
.ws-action i { color: var(--yellow); }
.ws-sub { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: .8rem; }
.ws-empty { color: var(--muted); font-size: .92rem; background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: var(--radius-md); padding: 1.2rem 1.4rem; }

/* Filter tabs (Explore / Continue / Popular) */
.filter-tabs { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.4rem; }
.filter-tab { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; font-weight: 600; cursor: pointer;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--muted); border-radius: 22px; padding: .45rem 1rem; transition: all .2s; }
.filter-tab:hover { color: var(--text); border-color: var(--yellow-bd); }
.filter-tab.active { background: var(--yellow); color: #012A4A; border-color: var(--yellow); }

/* Card enhancements (reference-aligned) */
.cc-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.cc-level { display: inline-flex; align-items: center; gap: 5px; font-size: .68rem; color: var(--muted); white-space: nowrap; }
.cc-dot { width: 7px; height: 7px; border-radius: 50%; }
.cc-dot.green { background: #4ade80; box-shadow: 0 0 6px rgba(74,222,128,.6); }
.cc-dot.amber { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,.6); }
.cc-progress { height: 6px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; margin-top: .2rem; }
.cc-progress-fill { height: 100%; background: linear-gradient(90deg, var(--yellow), #ffd600); border-radius: 4px; }
.cc-progress-label { font-size: .72rem; color: var(--muted); margin-top: -.1rem; }
.cc-avatar { width: 22px; height: 22px; min-width: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: .66rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--ai-from), var(--ai-to)); margin-right: 6px; }
.cc-author { display: inline-flex; align-items: center; }

/* ── Landing band: how it works / features / testimonials ── */
.landing-band { padding-bottom: 1rem; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.how-step { position: relative; padding: 1.6rem 1.4rem; border-radius: var(--radius-lg); text-align: center;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); backdrop-filter: blur(var(--glass-blur)) saturate(160%); box-shadow: var(--shadow-soft); }
.how-step i { font-size: 1.8rem; color: var(--yellow); display: block; margin: .4rem 0 .6rem; }
.how-step h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: .4rem; }
.how-step p { font-size: .88rem; color: var(--muted); line-height: 1.55; }
.how-num { position: absolute; top: 14px; left: 16px; width: 26px; height: 26px; border-radius: 50%; font-size: .8rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, var(--ai-from), var(--ai-to)); }

.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.feature-card { padding: 1.5rem 1.3rem; border-radius: var(--radius-lg);
  background: var(--glass-bg); border: 1px solid var(--glass-bd); backdrop-filter: blur(var(--glass-blur)) saturate(160%); box-shadow: var(--shadow-soft);
  transition: transform .2s, border-color .2s; }
.feature-card:hover { transform: translateY(-4px); border-color: var(--yellow-bd); }
.fc-ico { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; color: #fff;
  background: linear-gradient(135deg, var(--ai-from), var(--ai-to)); box-shadow: 0 6px 20px var(--ai-glow, rgba(124,58,237,.4)); margin-bottom: 1rem; }
.feature-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; }
.feature-card p { font-size: .86rem; color: var(--muted); line-height: 1.55; }

.testi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.testi-card { padding: 1.5rem 1.4rem; border-radius: var(--radius-lg); margin: 0;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); backdrop-filter: blur(var(--glass-blur)) saturate(160%); box-shadow: var(--shadow-soft); }
.testi-card blockquote { margin: 0 0 1rem; font-size: .92rem; line-height: 1.6; color: #e6eefb; }
.testi-card figcaption { display: flex; align-items: center; gap: .6rem; }
.testi-av { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #012A4A;
  background: linear-gradient(135deg, var(--yellow), #ffd600); }
.testi-card figcaption span:not(.testi-av) { display: flex; flex-direction: column; }
.testi-role { font-size: .76rem; color: var(--muted); }

@media (max-width: 880px) {
  .how-grid, .testi-grid { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) { .feature-grid { grid-template-columns: 1fr; } }

/* Ripple micro-interaction */
.ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,.35); transform: scale(0); animation: rippleAnim .6s ease-out; pointer-events: none; }
.btn-yellow .ripple, .filter-tab.active .ripple { background: rgba(1,42,74,.25); }
@keyframes rippleAnim { to { transform: scale(2.6); opacity: 0; } }

/* ============================================================================
   GENERATING — progress
   ============================================================================ */
.gen-wrap { max-width: 640px; margin: 5rem auto; text-align: center; }
.gen-card { background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: 22px; padding: 2.5rem 2rem; }
.gen-spinner { width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 1.4rem;
  background: linear-gradient(135deg, var(--ai-from), var(--ai-to)); display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #fff; box-shadow: 0 8px 30px rgba(124,58,237,.45); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.08);} }
.progress-track { height: 12px; background: rgba(255,255,255,.08); border-radius: 8px; overflow: hidden; margin: 1.5rem 0 .6rem; }
.progress-fill { height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, var(--ai-from), var(--ai-to)); transition: width .6s ease; }
.progress-pct { font-weight: 800; font-size: 1.1rem; }

/* ============================================================================
   LEARNING — sidebar + content
   ============================================================================ */
.learn-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: calc(100vh - var(--nav-h)); }
.learn-sidebar {
  /* Solid navbar background colour (no blur) */
  background: #020c20; border-right: 1px solid var(--glass-bd); padding: 1.1rem .8rem;
  position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); overflow-y: auto;
  /* Firefox: thin scrollbar with a transparent track */
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.16) transparent;
}
/* WebKit/Chromium: transparent scrollbar track + subtle thumb */
.learn-sidebar::-webkit-scrollbar { width: 8px; }
.learn-sidebar::-webkit-scrollbar-track { background: transparent; }
.learn-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }
.learn-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.26); }
.ls-course-title { font-size: 1rem; font-weight: 800; padding: .2rem .5rem .1rem; }
.ls-progress-row { display: flex; align-items: center; gap: .5rem; padding: .2rem .5rem .8rem; font-size: .74rem; color: var(--muted); }
.ls-mini-track { flex: 1; height: 6px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; }
.ls-mini-fill { height: 100%; background: linear-gradient(90deg, var(--yellow), #ffd600); }
.ls-list { list-style: none; margin: 0; padding: 0; }
.ls-item { display: flex; align-items: center; gap: .55rem; padding: .55rem .6rem; border-radius: 10px;
  text-decoration: none; color: var(--text); font-size: .86rem; line-height: 1.3; transition: background .15s; }
.ls-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
.ls-item.active { background: var(--yellow-dim); border: 1px solid var(--yellow-bd); }
.ls-num { width: 22px; height: 22px; min-width: 22px; border-radius: 6px; background: rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; color: var(--muted); }
.ls-item.done .ls-num { background: rgba(34,197,94,.2); color: #4ade80; }
.ls-item.active .ls-num { background: var(--yellow); color: #012A4A; }
.ls-cap { color: var(--yellow); }
.ls-star { margin-left: auto; color: var(--yellow); font-size: .8rem; }

.learn-main { padding: 1.6rem clamp(.9rem, 3vw, 2.4rem) 4rem; max-width: 980px; }
/* Lesson reading surface: frosted glass so the ambient theme glows through. */
.lesson-body {
  background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: var(--radius-lg);
  padding: 1.7rem 1.9rem; backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%); box-shadow: var(--shadow-soft);
}
@media (max-width: 600px) { .lesson-body { padding: 1.1rem 1rem; border-radius: var(--radius-md); } }
.lesson-eyebrow { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.lesson-h1 { font-size: clamp(1.7rem, 3vw, 2.4rem); font-weight: 800; margin: .2rem 0 1rem; }
.lesson-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.6rem; }
.tool-btn { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--text); border-radius: 18px;
  padding: .4rem .9rem; cursor: pointer; transition: border-color .2s, transform .15s; }
.tool-btn:hover { border-color: var(--yellow-bd); transform: translateY(-1px); }
.tool-btn.is-on { background: rgba(34,197,94,.16); border-color: rgba(34,197,94,.5); color: #4ade80; }
.tool-btn.bm.is-on { background: var(--yellow-dim); border-color: var(--yellow-bd); color: var(--yellow); }

/* ── Lesson prose (rendered Markdown) ── */
.prose { font-size: 1rem; line-height: 1.75; color: #e6eefb; }
.prose h2 { font-size: 1.5rem; font-weight: 800; margin: 2rem 0 .8rem; }
.prose h3 { font-size: 1.2rem; font-weight: 700; margin: 1.6rem 0 .6rem; color: #cfe2ff; }
.prose p { margin: 0 0 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem 1.3rem; }
.prose li { margin: .3rem 0; }
.prose a { color: #7ab4ff; }
.prose strong { color: #fff; }
.prose blockquote { border-left: 3px solid var(--yellow); background: var(--yellow-dim); padding: .7rem 1rem;
  border-radius: 0 10px 10px 0; margin: 1rem 0; color: #f3edc0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: .9rem; }
.prose th, .prose td { border: 1px solid var(--glass-bd); padding: .55rem .8rem; text-align: left; }
.prose th { background: rgba(255,255,255,.05); font-weight: 700; }
.prose code { font-family: var(--mono); background: rgba(255,255,255,.08); padding: .12em .4em; border-radius: 5px; font-size: .88em; }
.prose pre { margin: 1.2rem 0; }
.prose pre code { background: none; padding: 0; }
.prose .admonition { border: 1px solid var(--glass-bd); border-left: 4px solid #7ab4ff; background: var(--glass-bg);
  border-radius: 0 10px 10px 0; padding: .8rem 1rem; margin: 1.2rem 0; }
.prose .admonition-title { font-weight: 700; margin-bottom: .3rem; color: #7ab4ff; }
.prose .admonition.tip { border-left-color: #4ade80; } .prose .admonition.tip .admonition-title { color: #4ade80; }
.prose .admonition.warning { border-left-color: #f59e0b; } .prose .admonition.warning .admonition-title { color: #f59e0b; }

/* ── Pygments highlight (dark) ── */
.highlight { background: var(--code-bg); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; overflow: auto; }
.highlight pre { margin: 0; padding: 1rem 1.2rem; font-family: var(--mono); font-size: .85rem; line-height: 1.7; color: #e6edf3; background: none; }
.highlight .k, .highlight .kn, .highlight .kd, .highlight .kc, .highlight .kr { color: #f472b6; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sd { color: #86efac; }
.highlight .nf, .highlight .fm { color: #818cf8; }
.highlight .nc, .highlight .nn { color: #67e8f9; }
.highlight .mi, .highlight .mf, .highlight .mh { color: #fbbf24; }
.highlight .c, .highlight .c1, .highlight .cm { color: #6272a4; font-style: italic; }
.highlight .o, .highlight .ow { color: #ff9d6c; }
.highlight .nb, .highlight .bp { color: #7ab4ff; }
.highlight .nd { color: #f59e0b; }

/* ── Code block wrapper (copy button) ── */
.codeblock { position: relative; }
.code-copy { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14); color: #cdd9e8; border-radius: 6px; font-size: .72rem;
  padding: 3px 8px; cursor: pointer; opacity: 0; transition: opacity .2s; }
.codeblock:hover .code-copy { opacity: 1; }
.code-copy:hover { background: rgba(255,255,255,.16); }

/* ── Mermaid diagrams ── */
.mermaid-wrap {
  margin: 1.6rem 0; padding: 1rem; text-align: center; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--glass-bd); border-radius: 12px;
}
.mermaid-wrap .mermaid { display: inline-block; }
.mermaid-wrap svg { max-width: 100%; height: auto; }

/* ── Interactive code examples (CodeMirror) ── */
.example-block { margin: 1.6rem 0; border: 1px solid var(--glass-bd); border-radius: 14px; overflow: hidden; background: var(--code-bg); }
.example-bar { display: flex; align-items: center; gap: 8px; padding: .55rem .9rem; background: rgba(255,255,255,.04); border-bottom: 1px solid rgba(255,255,255,.07); }
.example-bar .dot-r,.example-bar .dot-y,.example-bar .dot-g { width: 10px; height: 10px; border-radius: 50%; }
.dot-r { background:#ef4444;} .dot-y { background:#f59e0b;} .dot-g { background:#22c55e;}
.example-bar .ex-title { font-size: .76rem; color: var(--muted); font-family: var(--mono); margin-left: 6px; }
.example-bar .ex-actions { margin-left: auto; display: flex; gap: 6px; }
.ex-btn { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); color: #cdd9e8;
  border-radius: 6px; font-size: .72rem; padding: 3px 9px; cursor: pointer; }
.ex-btn:hover { background: rgba(255,255,255,.14); }
.CodeMirror { height: auto !important; background: var(--code-bg) !important; color: #e6edf3 !important;
  font-family: var(--mono) !important; font-size: 14px !important; line-height: 1.7 !important; }
.CodeMirror-gutters { background: #161b22 !important; border-right: 1px solid rgba(255,255,255,.06) !important; }

/* ── Quiz ── */
.quiz-section { margin: 2.4rem 0; }
.quiz-card { background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: 14px; padding: 1.2rem 1.3rem; margin-bottom: 1rem; }
.quiz-q { font-weight: 700; margin-bottom: .8rem; }
.quiz-opt { display: block; width: 100%; text-align: left; background: var(--card-bg); border: 1px solid var(--card-bd);
  color: var(--text); border-radius: 10px; padding: .6rem .9rem; margin-bottom: .5rem; cursor: pointer; transition: border-color .15s, background .15s; }
.quiz-opt:hover { border-color: var(--yellow-bd); }
.quiz-opt.correct { background: rgba(34,197,94,.16); border-color: rgba(34,197,94,.55); }
.quiz-opt.wrong { background: rgba(239,68,68,.16); border-color: rgba(239,68,68,.55); }
.quiz-explain { margin-top: .5rem; font-size: .85rem; color: var(--muted); display: none; }
.quiz-explain.show { display: block; }

/* ── Section titles inside lesson ── */
.lesson-section-title { font-size: 1.3rem; font-weight: 800; margin: 2.4rem 0 1rem; display: flex; align-items: center; gap: .5rem; }
.lesson-section-title i { color: var(--yellow); }

/* ── Note panel ── */
.note-area { width: 100%; min-height: 110px; background: var(--code-bg); border: 1px solid var(--glass-bd);
  border-radius: 12px; color: var(--text); padding: .8rem 1rem; font-family: var(--sans); font-size: .92rem; resize: vertical; }
.note-status { font-size: .76rem; color: var(--muted); margin-top: .35rem; }

/* ── Lesson nav ── */
.lesson-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; border-top: 1px solid var(--glass-bd); padding-top: 1.5rem; }
.lesson-nav a { flex: 1; text-decoration: none; }
.lesson-nav .ln-card { background: var(--card-bg); border: 1px solid var(--card-bd); border-radius: 12px; padding: .8rem 1rem; transition: border-color .2s, transform .15s; }
.lesson-nav .ln-card:hover { border-color: var(--yellow-bd); transform: translateY(-2px); }
.lesson-nav .ln-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.lesson-nav .ln-title { font-weight: 700; font-size: .9rem; color: var(--text); }
.lesson-nav .next { text-align: right; }

/* ── Mobile sidebar drawer ── */
.sidebar-toggle { display: none; }
.sidebar-close { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 900px) {
  .learn-shell { grid-template-columns: 1fr; }
  .learn-main { padding: 1.4rem 1.1rem 4rem; max-width: 100%; }
  .learn-sidebar {
    position: fixed; left: 0; top: var(--nav-h); z-index: 1100; width: 86%; max-width: 330px;
    height: calc(100vh - var(--nav-h)); transform: translateX(-105%);
    transition: transform .28s cubic-bezier(.16,1,.3,1); box-shadow: 0 0 60px rgba(0,0,0,.65);
  }
  .learn-sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: var(--nav-h) 0 0 0; z-index: 1050;
    background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .sidebar-toggle {
    display: inline-flex; align-items: center; gap: 6px; position: fixed; bottom: 18px; left: 18px; z-index: 1150;
    background: var(--yellow); color: #012A4A; font-weight: 700; border: none;
    border-radius: 24px; padding: .6rem 1.1rem; font-size: .85rem; cursor: pointer;
    box-shadow: 0 8px 26px rgba(248,237,8,.4);
  }
  /* Close (X) button inside the open drawer. */
  .sidebar-close {
    display: inline-flex; align-items: center; justify-content: center; position: absolute; top: 10px; right: 10px;
    width: 36px; height: 36px; border-radius: 10px; z-index: 3; cursor: pointer;
    background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--text); font-size: 1rem;
  }
  .sidebar-close:hover { border-color: var(--yellow-bd); color: var(--yellow); }
  .ls-course-title { padding-right: 2.6rem; }   /* keep title clear of the X */
  body.drawer-open { overflow: hidden; }
}

/* ── Auth ── */
.auth-wrap { max-width: 430px; margin: 4rem auto; }
.auth-card { background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: 20px; padding: 2.2rem 2rem;
  box-shadow: 0 18px 60px rgba(0,10,50,.45); }
.auth-card h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: .3rem; }
.auth-card .sub { color: var(--muted); font-size: .9rem; margin-bottom: 1.4rem; }
.auth-field { margin-bottom: 1rem; }
.auth-field label { font-size: .8rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: .35rem; }
.auth-field input, .auth-field textarea {
  width: 100%; background: var(--code-bg); border: 1px solid var(--glass-bd); border-radius: 10px;
  color: var(--text); padding: .6rem .8rem; font-size: .95rem; outline: none; }
.auth-field input:focus { border-color: var(--yellow-bd); }
.auth-error { color: #f87171; font-size: .8rem; margin-top: .3rem; }
.auth-foot { text-align: center; margin-top: 1.2rem; color: var(--muted); font-size: .88rem; }
.auth-foot a { color: var(--yellow); text-decoration: none; }
.helptext, .helptext li { font-size: .74rem; color: var(--muted); }

/* ============================================================================
   ADMIN CONSOLE
   ============================================================================ */
.console-wrap { padding: 2rem 0 4rem; }
.console-head { margin-bottom: 1rem; }
.console-title { font-size: 1.6rem; font-weight: 800; display: flex; align-items: center; gap: .55rem; }
.console-title i { color: var(--yellow); }
.console-sub { color: var(--muted); font-size: .92rem; }
.console-tabs { display: flex; gap: .4rem; border-bottom: 1px solid var(--glass-bd); margin-bottom: 1.6rem; flex-wrap: wrap; }
.console-tab { display: inline-flex; align-items: center; gap: 6px; padding: .6rem 1rem; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; }
.console-tab:hover { color: var(--text); }
.console-tab.active { color: var(--text); border-bottom-color: var(--yellow); }

.quota-banner.admin { color: #9fe3c0; background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.32); }
.btn-glass.danger, .btn-glass .danger { border-color: rgba(239,68,68,.4); }
.btn-glass.danger:hover { border-color: rgba(239,68,68,.7); color: #f87171; }

/* Stat widgets (glassmorphism) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat-widget {
  display: flex; align-items: center; gap: .9rem; padding: 1.1rem 1.2rem;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%); box-shadow: var(--shadow-soft);
  transition: transform .2s, border-color .2s;
}
.stat-widget:hover { transform: translateY(-3px); border-color: var(--yellow-bd); }
.sw-ico { width: 46px; height: 46px; min-width: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.sw-ico.blue { background: rgba(59,130,246,.16); color: #60a5fa; }
.sw-ico.green { background: rgba(34,197,94,.16); color: #4ade80; }
.sw-ico.yellow { background: var(--yellow-dim); color: var(--yellow); }
.sw-ico.purple { background: rgba(139,92,246,.16); color: #c4b5fd; }
.sw-num { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.sw-label { font-size: .78rem; color: var(--muted); }

/* Charts */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.6rem; }
.chart-card, .activity-card, .glass-panel, .table-card {
  background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: var(--radius-lg);
  padding: 1.2rem 1.3rem; backdrop-filter: blur(var(--glass-blur)) saturate(160%); box-shadow: var(--shadow-soft);
}
.chart-card h3, .activity-card h3, .panel-title { font-size: 1rem; font-weight: 700; margin-bottom: .9rem; }
.chart-box { position: relative; height: 240px; }

/* Activity */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--glass-bd2); font-size: .9rem; }
.activity-list li:last-child { border-bottom: none; }
.al-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.al-dot.completed { background: #22c55e; } .al-dot.failed { background: #ef4444; } .al-dot.generating { background: #f59e0b; }
.al-main { flex: 1; } .al-main a { color: #7ab4ff; }
.al-meta { font-size: .76rem; color: var(--muted); white-space: nowrap; }

/* Filters + tables */
.console-filters { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.2rem; align-items: center; }
.cf-search { display: flex; align-items: center; gap: .5rem; background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: 12px; padding: .45rem .8rem; flex: 1; min-width: 200px; }
.cf-search i { color: var(--muted); } .cf-search input { flex: 1; background: none; border: none; outline: none; color: var(--text); min-width: 0; }
.cf-select { background: var(--code-bg); border: 1px solid var(--glass-bd); border-radius: 12px; color: var(--text); padding: .5rem .7rem; outline: none; }
.table-card { padding: .4rem; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 640px; }
.data-table.compact { min-width: 420px; }
.data-table th { text-align: left; padding: .7rem .8rem; color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--glass-bd); }
.data-table td { padding: .7rem .8rem; border-bottom: 1px solid var(--glass-bd2); vertical-align: middle; }
.data-table tr:hover td { background: rgba(255,255,255,.03); }
.u-name { color: var(--text); font-weight: 600; text-decoration: none; } .u-name:hover { color: var(--yellow); }
.u-sub, .u-meta, .u-email { color: var(--muted); font-size: .8rem; }
.u-actions { display: flex; gap: .4rem; white-space: nowrap; }
.inline-form { display: inline; margin: 0; }
.icon-act { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--text); cursor: pointer; text-decoration: none; }
.icon-act:hover { border-color: var(--yellow-bd); color: var(--yellow); }
.icon-act.danger:hover { border-color: rgba(239,68,68,.6); color: #f87171; }
.icon-act.ok:hover { border-color: rgba(34,197,94,.6); color: #4ade80; }
.empty-row { text-align: center; color: var(--muted); padding: 1.5rem; }
.badge-role { font-size: .68rem; font-weight: 700; padding: 2px 9px; border-radius: 9px; background: rgba(255,255,255,.07); color: var(--muted); }
.badge-role.admin { background: rgba(139,92,246,.18); color: #c4b5fd; }
.badge-status { font-size: .68rem; font-weight: 700; padding: 2px 9px; border-radius: 9px; }
.badge-status.active { background: rgba(34,197,94,.16); color: #4ade80; }
.badge-status.suspended { background: rgba(239,68,68,.16); color: #f87171; }

/* User detail */
.back-link { color: var(--muted); text-decoration: none; font-size: .86rem; display: inline-flex; gap: 5px; align-items: center; margin-bottom: 1rem; }
.back-link:hover { color: var(--yellow); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.dp-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.dp-name { font-size: 1.2rem; font-weight: 800; }
.dp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: 1.2rem; }
.dp-stats > div { display: flex; flex-direction: column; gap: 2px; }
.dp-k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dp-v { font-weight: 700; }
.dp-actions, .credit-forms { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.dp-actions form, .credit-form { margin: 0; display: flex; gap: .4rem; align-items: center; }
.panel-subtitle { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 1.2rem 0 .6rem; }
.credit-input { width: 80px; background: var(--code-bg); border: 1px solid var(--glass-bd); border-radius: 10px; color: var(--text); padding: .45rem .6rem; outline: none; }
.data-table td.pos { color: #4ade80; font-weight: 700; } .data-table td.neg { color: #f87171; font-weight: 700; }

@media (max-width: 820px) {
  .chart-row, .detail-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   BREADCRUMBS + READING PROGRESS
   ============================================================================ */
.breadcrumbs { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--muted); text-decoration: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs a:hover { color: var(--yellow); }
.breadcrumbs i { font-size: .7rem; opacity: .6; }
.breadcrumbs span[aria-current] { color: var(--text); font-weight: 600; }
.read-progress { position: fixed; top: var(--nav-h); left: 0; height: 3px; width: 0; z-index: 999;
  background: linear-gradient(90deg, var(--yellow), #ffd600); box-shadow: 0 0 12px rgba(248,237,8,.5); transition: width .1s linear; }

/* ============================================================================
   AI TUTOR
   ============================================================================ */
/* Floating AI Tutor launcher — fixed to the viewport's bottom-right corner so
   it stays reachable from any scroll position, above the navbar and drawer. */
.ai-fab {
  position: fixed; right: 20px; bottom: 22px; z-index: 1400; display: inline-flex; align-items: center; gap: 8px;
  padding: .7rem 1.1rem; border: none; border-radius: 30px; cursor: pointer; color: #fff; font-weight: 700; font-size: .9rem;
  background: linear-gradient(135deg, var(--ai-from), var(--ai-to)); box-shadow: 0 10px 30px rgba(124,58,237,.5);
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.ai-fab::after {
  /* Soft attention pulse so the floating chatbot reads as "live". */
  content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: -1;
  box-shadow: 0 0 0 0 var(--ai-glow); animation: aiFabPulse 2.6s ease-out infinite;
}
@keyframes aiFabPulse { 0% { box-shadow: 0 0 0 0 var(--ai-glow); } 70%,100% { box-shadow: 0 0 0 16px rgba(124,58,237,0); } }
.ai-fab:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 40px rgba(124,58,237,.65); }
.ai-fab i { font-size: 1.1rem; }
.ai-fab.hidden { opacity: 0; pointer-events: none; transform: scale(.8); }

.ai-panel {
  position: fixed; right: 20px; bottom: 22px; z-index: 1450; width: min(94vw, 480px); height: min(84vh, 760px);
  display: flex; flex-direction: column; border-radius: 18px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,4,30,.6); transform: translateY(24px) scale(.96); opacity: 0;
  transition: transform .25s cubic-bezier(.16,1,.3,1), opacity .25s;
}
.ai-panel.open { transform: none; opacity: 1; }
.ai-panel-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1rem; border-bottom: 1px solid var(--glass-bd); }
.aph-title { font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: 7px; }
.aph-dot { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.aph-sub { color: var(--muted); font-weight: 500; font-size: .8rem; }
.ai-close { background: none; border: none; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.ai-close:hover { color: var(--text); }
.ai-quick { display: flex; flex-wrap: wrap; gap: .4rem; padding: .7rem 1rem; border-bottom: 1px solid var(--glass-bd2); }
.ai-chip { font-size: .76rem; background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--text); border-radius: 16px; padding: .32rem .7rem; cursor: pointer; transition: border-color .2s; }
.ai-chip:hover { border-color: var(--yellow-bd); color: var(--yellow); }
.ai-thread { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .9rem; }
.ai-welcome { color: var(--muted); font-size: .88rem; line-height: 1.5; text-align: center; padding: 1rem .5rem; }
.ai-welcome i { color: var(--ai-from); font-size: 1.4rem; display: block; margin-bottom: .4rem; }
.ai-msg { display: flex; gap: .55rem; align-items: flex-start; }
.ai-user { justify-content: flex-end; }
.ai-avatar { width: 26px; height: 26px; min-width: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--ai-from), var(--ai-to)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: .72rem; }
.ai-bubble { padding: .6rem .8rem; border-radius: 12px; font-size: .88rem; line-height: 1.55; max-width: 86%; }
.ai-user .ai-bubble { background: var(--yellow-dim); border: 1px solid var(--yellow-bd); color: #f3edc0; }
.ai-assistant .ai-bubble { background: var(--glass-bg); border: 1px solid var(--glass-bd); }
.ai-assistant .ai-bubble.prose { font-size: .88rem; }
.ai-assistant .ai-bubble.prose pre { margin: .6rem 0; }
.ai-assistant .ai-bubble.prose h2, .ai-assistant .ai-bubble.prose h3 { font-size: .95rem; margin: .5rem 0 .3rem; }
.ai-bubble.ai-streaming { white-space: pre-wrap; }
.ai-bubble.ai-streaming::after { content: '▋'; color: var(--yellow); margin-left: 1px; animation: caret-blink .8s step-end infinite; }
.ai-err { color: #f87171; font-size: .85rem; }
.ai-typing { display: inline-flex; gap: 4px; padding: 2px 0; }
.ai-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: aiTyping 1.2s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .2s; } .ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiTyping { 0%,60%,100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.ai-input { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--glass-bd); }
.ai-input input { flex: 1; background: var(--code-bg); border: 1px solid var(--glass-bd); border-radius: 20px; color: var(--text); padding: .55rem .9rem; outline: none; font-size: .9rem; }
.ai-input input:focus { border-color: var(--yellow-bd); }
.ai-send { width: 38px; height: 38px; min-width: 38px; border: none; border-radius: 50%; background: linear-gradient(135deg, var(--ai-from), var(--ai-to)); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ai-send:hover { filter: brightness(1.1); }
@media (max-width: 560px) {
  .ai-panel { right: 0; left: 0; bottom: 0; width: 100%; height: 80vh; border-radius: 18px 18px 0 0; }
  .ai-fab { right: 14px; bottom: 14px; }
}

/* ============================================================================
   VIDEO RESOURCES
   ============================================================================ */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; margin: .4rem 0 1rem; }
.video-card {
  display: flex; gap: .8rem; align-items: center; padding: .85rem; border-radius: var(--radius-md);
  text-decoration: none; color: var(--text); transition: transform .2s, border-color .2s, box-shadow .2s;
}
.video-card:hover { transform: translateY(-3px); border-color: rgba(239,68,68,.5); box-shadow: var(--shadow-lift); color: var(--text); }
.vc-thumb {
  width: 58px; height: 44px; min-width: 58px; border-radius: 10px; color: #fff; font-size: 1.4rem;
  background: linear-gradient(135deg, rgba(239,68,68,.9), rgba(190,18,18,.95)); display: flex; align-items: center; justify-content: center;
}
.vc-title { font-weight: 600; font-size: .9rem; line-height: 1.3; }
.vc-cta { font-size: .76rem; color: #f87171; margin-top: 3px; display: inline-flex; gap: 4px; align-items: center; }

/* ============================================================================
   IDE WORKSPACE — collapsible + resizable sidebar
   ============================================================================ */
.ls-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding-right: .3rem; }
.sb-collapse {
  background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--muted);
  width: 28px; height: 28px; min-width: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.sb-collapse:hover { color: var(--yellow); border-color: var(--yellow-bd); }
.resize-handle { position: absolute; top: 0; right: -3px; width: 8px; height: 100%; cursor: col-resize; z-index: 6; }
.resize-handle:hover { background: linear-gradient(90deg, transparent, rgba(248,237,8,.22)); }
.sb-expand {
  display: none; position: fixed; left: 8px; top: 66px; z-index: 800; width: 34px; height: 34px; border-radius: 9px;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--text); cursor: pointer;
  backdrop-filter: blur(12px); align-items: center; justify-content: center;
}
.sb-expand:hover { border-color: var(--yellow-bd); color: var(--yellow); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .CodeMirror { pointer-events: none; }
@media (min-width: 901px) {
  .learn-sidebar { transition: opacity .2s ease, transform .2s ease; }
  .learn-shell.sb-collapsed { grid-template-columns: 0 1fr; }
  .learn-shell.sb-collapsed .learn-sidebar { opacity: 0; pointer-events: none; transform: translateX(-14px); }
  .learn-shell.sb-collapsed .sb-expand { display: inline-flex; }
}
@media (max-width: 900px) {
  .sb-collapse, .resize-handle, .sb-expand { display: none !important; }
}

/* ============================================================================
   LESSON LOADING + STREAMING REVEAL
   ============================================================================ */
.lesson-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; padding: 3rem 1rem; min-height: 280px; transition: opacity .3s ease;
}
.lesson-loading.done { opacity: 0; }
.ll-spinner {
  width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #fff; background: linear-gradient(135deg, var(--ai-from), var(--ai-to));
  box-shadow: 0 8px 34px rgba(124,58,237,.5); animation: ll-pulse 1.6s ease-in-out infinite;
}
@keyframes ll-pulse { 0%,100% { transform: scale(1); box-shadow: 0 8px 34px rgba(124,58,237,.4);} 50% { transform: scale(1.1); box-shadow: 0 12px 46px rgba(124,58,237,.7);} }
.ll-text { color: var(--muted); font-size: 1rem; font-weight: 600; letter-spacing: .01em; }
.ll-dots span { animation: ll-dot 1.4s infinite; opacity: .2; }
.ll-dots span:nth-child(2) { animation-delay: .2s; }
.ll-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes ll-dot { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }

/* Streamed-in blocks start hidden, then fade/slide in as "revealed". */
.streaming .stream-block { opacity: 0; transform: translateY(10px); }
.stream-block { transition: opacity .45s ease, transform .45s ease; }
.stream-block.revealed { opacity: 1; transform: none; }
.stream-caret {
  display: inline-block; width: 8px; height: 1.05em; margin-left: 3px; vertical-align: text-bottom;
  background: var(--yellow); border-radius: 2px; animation: caret-blink .8s step-end infinite;
}
@keyframes caret-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ============================================================================
   GLOBAL POLISH + RESPONSIVE
   ============================================================================ */
/* NOTE: this fades <body> with OPACITY ONLY — never a transform. A transform on
   body (even a brief animated one, or one retained via fill-mode) makes body the
   containing block for every `position: fixed` element, which breaks the
   floating AI Tutor FAB/panel (their `bottom` would measure from the page
   bottom, not the viewport) and every other fixed overlay. Keep it transform-free. */
body { animation: bodyFade .4s ease both; }
@keyframes bodyFade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  body, .stream-block, .course-card, .btn-yellow, .tool-btn { animation: none !important; transition: none !important; }
}

/* Wide content (tables/code) scrolls instead of breaking the layout on mobile. */
.prose { overflow-wrap: break-word; }
.prose table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Tablet */
@media (max-width: 992px) {
  .home-hero { padding: 3rem 0 1.5rem; }
  .course-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
}

/* Phones */
@media (max-width: 600px) {
  .top-nav { padding: .6rem .4rem; }
  .home-hero { padding: 2.2rem 0 1rem; }
  .home-title { font-size: clamp(1.8rem, 7vw, 2.4rem); }
  .home-sub { font-size: .98rem; }
  .prompt-card { margin-top: 1.4rem; border-radius: 18px; }
  .prompt-row { flex-direction: column; align-items: stretch; gap: .6rem; }
  .prompt-row .btn-yellow { width: 100%; justify-content: center; }
  .course-grid { grid-template-columns: 1fr; }
  .lesson-h1 { font-size: 1.5rem; }
  .learn-main { padding: 1.1rem .9rem 5rem; }
  .lesson-toolbar { gap: .45rem; }
  .auth-wrap { margin: 2rem auto; padding: 0 .9rem; }
  .auth-card { padding: 1.6rem 1.2rem; }
  .lesson-nav { flex-direction: column; }
}

/* Large desktops: a touch more breathing room. */
@media (min-width: 1400px) {
  .learn-main { max-width: 1000px; }
}

/* ============================================================================
   STICKY NAV + NO HORIZONTAL OVERFLOW
   ============================================================================ */
body { overflow-x: hidden; }
/* !important required to beat glass.css's `.top-nav { position: relative !important }`
   so the nav actually sticks on desktop (not just <=900px). */
.top-nav, nav.navbar { position: sticky !important; top: 0 !important; z-index: 1000 !important; }
img, svg, table, pre, .CodeMirror { max-width: 100%; }

/* ============================================================================
   COURSE CARD — owner-only delete
   ============================================================================ */
.course-card-wrap { position: relative; }
.cc-delete-form { position: absolute; top: 10px; right: 10px; z-index: 5; margin: 0; }
.cc-delete {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--glass-bd);
  background: rgba(8,16,38,.62); color: var(--muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center; font-size: .92rem;
  opacity: 0; transform: translateY(-4px); backdrop-filter: blur(8px);
  transition: opacity .2s ease, transform .2s ease, background .2s, color .2s, border-color .2s;
}
.course-card-wrap:hover .cc-delete { opacity: 1; transform: none; }
.cc-delete:hover { background: rgba(239,68,68,.22); border-color: rgba(239,68,68,.55); color: #f87171; }
/* Touch devices have no hover — always show the control. */
@media (hover: none) { .cc-delete { opacity: 1; transform: none; } }

/* ============================================================================
   MOBILE: glassmorphism drawer + responsive editor
   ============================================================================ */
@media (max-width: 900px) {
  .learn-sidebar {
    /* Solid navbar background colour (no blur) */
    background: #020c20;
    border-right: 1px solid var(--glass-bd);
    -webkit-overflow-scrolling: touch;   /* independent momentum scroll */
  }
}
@media (max-width: 600px) {
  .CodeMirror { font-size: 13px !important; line-height: 1.6 !important; }
  .example-block { border-radius: 10px; }
  .example-bar { flex-wrap: wrap; gap: 6px; }
  .example-bar .ex-actions { margin-left: auto; }
  .ex-btn { padding: 3px 7px; font-size: .68rem; }
  .lesson-section-title { font-size: 1.15rem; }
  .prose { font-size: .96rem; }
  .prose h2 { font-size: 1.3rem; }
  .cc-delete { opacity: 1; transform: none; }
}

/* ============================================================================
   GENERATION ACTIONS (Cancel / Regenerate) + COURSE PRIVACY CONTROLS
   ============================================================================ */
.gen-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 1.1rem; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px; padding: .6rem 1.15rem; border-radius: 12px; cursor: pointer;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--muted); font-weight: 600; font-size: .9rem;
  transition: border-color .2s, color .2s, background .2s;
}
.btn-ghost:hover { color: #f87171; border-color: rgba(239,68,68,.5); background: rgba(239,68,68,.1); }
.btn-ghost:disabled { opacity: .5; cursor: default; }
.gen-spinner.stopped { animation: none; opacity: .5; }

/* Owner card actions: visibility toggle + delete, top-right of each card. */
.cc-actions { position: absolute; top: 10px; right: 10px; z-index: 5; display: flex; gap: 6px; margin: 0; }
.cc-actions .cc-action-form { margin: 0; }
.cc-iconbtn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--glass-bd);
  background: rgba(8,16,38,.62); color: var(--muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center; font-size: .92rem; backdrop-filter: blur(8px);
  transition: opacity .2s, transform .2s, background .2s, color .2s, border-color .2s;
}
.cc-vis { opacity: .6; }
.course-card-wrap:hover .cc-vis { opacity: 1; }
.cc-vis:hover { color: var(--yellow); border-color: var(--yellow-bd); }
.cc-vis.is-private { color: #fbbf24; border-color: rgba(251,191,36,.4); opacity: 1; }
@media (hover: none) { .cc-vis { opacity: 1; } }
.cc-meta-private { color: #fbbf24 !important; }

/* Sidebar visibility toggle on the lesson page (owner only). */
.ls-visibility { margin: .5rem 0 0; }
.vis-toggle {
  width: 100%; display: inline-flex; align-items: center; gap: .5rem; cursor: pointer;
  padding: .5rem .7rem; border-radius: 10px; font-size: .82rem; font-weight: 600;
  background: var(--glass-bg); border: 1px solid var(--glass-bd); color: var(--text);
  transition: border-color .2s, color .2s, background .2s;
}
.vis-toggle .vis-swap { margin-left: auto; font-size: .78rem; opacity: .55; }
.vis-toggle:hover { border-color: var(--yellow-bd); }
.vis-toggle.is-private { color: #fbbf24; border-color: rgba(251,191,36,.35); }
.vis-toggle.is-public i:first-child { color: #4ade80; }
.ls-regen { margin: .5rem 0 0; }
.vis-toggle.is-missing { color: var(--ai-to); border-color: rgba(99,102,241,.4); justify-content: center; }
.vis-toggle.is-missing:hover { border-color: var(--ai-from); color: var(--ai-from); }

/* ── Site footer (SEO internal linking) ─────────────────────────────────────
   Overrides the legacy horizontal `.site-footer` bar (defined in glass.css)
   with a multi-column footer that surfaces internal links site-wide. */
.site-footer {
  display: block;
  padding: 2.6rem 0 1.4rem;
  margin-top: 4rem;
  background: rgba(2,8,24,.70);
  border-top: 1px solid rgba(55,120,255,.10);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #7f9bbb;
  font-size: .9rem;
}
.site-footer .footer-inner {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 1fr);
  gap: 1.75rem 2rem;
  align-items: start;
}
.site-footer .footer-brand { max-width: 340px; }
.site-footer .footer-logo { display: inline-flex; }
.site-footer .footer-logo img { height: 26px; width: auto; opacity: .95; }
.site-footer .footer-tagline {
  margin: .85rem 0 0;
  font-size: .86rem;
  line-height: 1.6;
  color: #6a86a6;
}
.site-footer .footer-h {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #93a9c8;
  margin: 0 0 .85rem;
}
.site-footer .footer-col ul { list-style: none; margin: 0; padding: 0; }
.site-footer .footer-col li { margin: 0 0 .55rem; }
.site-footer a { color: #7f9bbb; text-decoration: none; transition: color .18s ease; }
.site-footer a:hover, .site-footer a:focus-visible { color: #bcd4f5; text-decoration: underline; }
.site-footer .footer-bottom {
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(55,120,255,.08);
  font-size: .8rem;
  color: #5f7a99;
}
@media (max-width: 820px) {
  .site-footer .footer-inner { grid-template-columns: 1fr 1fr; }
  .site-footer .footer-brand { grid-column: 1 / -1; max-width: none; }
}
@media (max-width: 480px) {
  .site-footer { padding: 2rem 0 1.2rem; margin-top: 2.5rem; }
  .site-footer .footer-inner { grid-template-columns: 1fr; gap: 1.4rem; }
}
