/* ============================================================
   AI AUTOMATION BLUEPRINT — Academy cabinet
   Dark premium LMS layout: sidebar + topbar + content.
   Type: Bricolage Grotesque (display) + Outfit (body)
   Shape rule: cards 20px, buttons pill, inputs 12px
   Motion: ease-out cubic-bezier(0.23,1,0.32,1), UI under 300ms
   ============================================================ */

:root {
  --bg: #0c0f12;
  --surface: #13171c;
  --surface-2: #181d23;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --ink: #f2f6f4;
  --muted: #93a09b;
  --accent: #3ee6a8;
  --accent-deep: #18b87f;
  --accent-ink: #06241a;
  --gold: #f4c95d;

  --r-card: 20px;
  --r-input: 12px;

  --sidebar-w: 280px;
  --topbar-h: 66px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --font-display: "Bricolage Grotesque", sans-serif;
  --font-body: "Outfit", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- background: near-black base + liquid aurora light.
   One organic glow cluster, slowly breathing. Blueprint rails
   frame the content column (see #app::before/::after). */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background: linear-gradient(180deg, #0b0e12 0%, #080a0d 55%, #060809 100%);
}
.bg::before { /* liquid light: bright enough to read through the glass */
  content: "";
  position: absolute;
  inset: -22%;
  background:
    radial-gradient(38% 26% at 66% 16%, rgba(62, 230, 168, 0.34), transparent 66%),
    radial-gradient(26% 20% at 84% 36%, rgba(34, 205, 196, 0.22), transparent 68%),
    radial-gradient(20% 16% at 52% 8%, rgba(170, 255, 220, 0.16), transparent 68%),
    radial-gradient(30% 24% at 22% 64%, rgba(40, 190, 170, 0.13), transparent 70%),
    radial-gradient(32% 26% at 8% 96%, rgba(50, 120, 220, 0.14), transparent 70%);
  filter: blur(32px);
  will-change: transform;
  animation: aurora 17s var(--ease-in-out) infinite alternate;
}
@keyframes aurora {
  from { transform: translate3d(-2%, -1.5%, 0) scale(1) rotate(-1deg); }
  to { transform: translate3d(2.5%, 2%, 0) scale(1.09) rotate(1.5deg); }
}

/* trendy film grain: overlay blend makes it live in the lit areas
   (grainy-gradient look) and stay quiet on the blacks */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent); color: var(--accent-ink); }

/* keyboard focus: visible ring on any focusable element, never on mouse click */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid rgba(62, 230, 168, 0.75);
  outline-offset: 2px;
  border-radius: 6px;
}
.btn:focus-visible, .nav-btn:focus-visible, .switch:focus-visible { outline-offset: 3px; border-radius: 999px; }

/* subtle top light edge + grounding shadow on raised surfaces */
.welcome, .mod-card, .badge, .lesson-row,
.video-placeholder, .materials, .deliverable, .edit-panel {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 10px 30px -18px rgba(0, 0, 0, 0.6);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232a31; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #2e3740; }
/* Firefox parity for the dark theme */
html { scrollbar-width: thin; scrollbar-color: #232a31 transparent; }

/* screen-reader-only utility (search live region etc.) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   SHELL LAYOUT
   ============================================================ */
.shell { display: flex; min-height: 100dvh; }

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

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 60;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  flex: 0 0 auto;
}
.side-brand em { font-style: normal; color: var(--accent); }
.side-brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(62, 230, 168, 0.35));
}

.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
}

.side-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 12px 8px;
}

.side-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 12px;
  margin-bottom: 2px;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.side-item:hover { background: rgba(255, 255, 255, 0.04); }
.side-item:active { background: rgba(255, 255, 255, 0.07); }
.side-item.active { background: rgba(62, 230, 168, 0.1); }
.side-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.side-item img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
  transition: transform 200ms var(--ease-out);
}
.side-item:hover img { transform: scale(1.12); }

.side-item .si-body { flex: 1; min-width: 0; }
.side-item .si-title {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-item.active .si-title { color: var(--accent); }
.side-item .si-meta {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1px;
}
.side-item .si-state {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 30px;
  text-align: right;
}
.side-item.done .si-state { color: var(--accent); }

.side-item.dash img { width: 26px; height: 26px; }

/* sidebar footer */
.side-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-foot-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
.side-foot-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.04); }
.side-foot-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
body.edit-mode #edit-toggle { color: var(--gold); }
body.edit-mode #edit-toggle .dot {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(244, 201, 93, 0.7);
}

.data-wrap { position: relative; }
#data-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  min-width: 236px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: scale(0.95);
  transform-origin: bottom left;
  pointer-events: none;
  /* visibility keeps the closed menu's buttons out of the Tab order */
  visibility: hidden;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out),
              visibility 0s 150ms;
  z-index: 70;
}
#data-menu.open {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  visibility: visible;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out),
              visibility 0s;
}
#data-menu button {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
#data-menu button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 clamp(16px, 3vw, 32px);
  background: rgba(12, 15, 18, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 9px;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
}
.burger span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

/* search */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 460px;
}
.search-ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}
#search {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 18px 10px 40px;
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
#search::placeholder { color: var(--muted); }
#search:focus {
  outline: none;
  border-color: rgba(62, 230, 168, 0.5);
  background: var(--surface-2);
}

#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 28px 70px -20px rgba(0, 0, 0, 0.8);
  max-height: min(60dvh, 480px);
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top center;
  pointer-events: none;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
  z-index: 55;
}
#search-results.open { opacity: 1; transform: none; pointer-events: auto; }

.sr-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 130ms var(--ease-out);
}
.sr-item:hover, .sr-item.sel { background: rgba(62, 230, 168, 0.09); }
.sr-item img { width: 28px; height: 28px; object-fit: contain; flex: 0 0 auto; }
.sr-item .sr-body { flex: 1; min-width: 0; }
.sr-item .sr-title {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-item .sr-title mark {
  background: rgba(62, 230, 168, 0.25);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
}
.sr-item .sr-mod {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}
.sr-item .sr-done { color: var(--accent); font-size: 0.8rem; flex: 0 0 auto; }
.sr-empty {
  padding: 14px 16px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

/* topbar right */
.top-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  flex: 0 0 auto;
}
.top-progress { flex: 0 0 auto; }
.ring {
  --p: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(closest-side, var(--bg) 76%, transparent 77% 100%),
    conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255, 255, 255, 0.08) 0);
}
.ring span {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 13px 26px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: transform 140ms var(--ease-out), box-shadow 200ms var(--ease-out),
              background-color 160ms var(--ease-out), border-color 160ms var(--ease-out),
              color 160ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(180deg, #4af0b1, var(--accent) 45%, #2bd092);
  color: var(--accent-ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 8px 28px -10px rgba(62, 230, 168, 0.55);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #5ef7bd, #54f0b6 45%, #35dd9d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 12px 36px -10px rgba(62, 230, 168, 0.65);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.03); }

.btn-done {
  background: rgba(62, 230, 168, 0.12);
  color: var(--accent);
  border-color: rgba(62, 230, 168, 0.35);
}

.btn-gold { background: var(--gold); color: #241a04; }
.btn-gold:hover { background: #ffd97a; transform: translateY(-1px); }

.btn.small { padding: 9px 18px; font-size: 0.85rem; }

/* ============================================================
   CONTENT AREA
   ============================================================ */
#app {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(20px, 3.5vh, 36px) clamp(16px, 3vw, 36px) 110px;
  position: relative;
}
/* blueprint rails framing the content column */
#app::before, #app::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.09),
    rgba(255, 255, 255, 0.035) 40%,
    rgba(255, 255, 255, 0.015));
  pointer-events: none;
}
#app::before { left: 0; }
#app::after { right: 0; }

.section-title {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.015em;
  margin: 38px 0 6px;
}
.section-title::before {
  content: "";
  flex: 0 0 auto;
  width: 4px;
  height: 1.05em;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 0 12px rgba(62, 230, 168, 0.45);
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent 85%);
}
.section-sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 20px;
}

/* ============================================================
   DASHBOARD: welcome panel
   ============================================================ */
.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  align-items: center;
  gap: 20px;
  /* frosted glass fill + gradient hairline border */
  border: 1px solid transparent;
  background:
    linear-gradient(rgba(18, 24, 30, 0.38), rgba(18, 24, 30, 0.38)) padding-box,
    linear-gradient(135deg, rgba(62, 230, 168, 0.45), rgba(255, 255, 255, 0.1) 30%,
      rgba(255, 255, 255, 0.05) 65%, rgba(62, 230, 168, 0.18)) border-box;
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border-radius: var(--r-card);
  padding: 30px 34px;
  animation: rise 480ms var(--ease-out) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 8px;
}
.welcome-title em { font-style: normal; color: var(--accent); }
.welcome-progress {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  margin: -2px 0 10px;
}
.welcome-progress em { font-style: normal; color: var(--accent); font-size: 1.35rem; }
.welcome-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 20px; max-width: 36em; }

.welcome-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.welcome-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--muted);
}
.welcome-stats b {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--ink);
  margin-right: 4px;
}

/* inline "what's your name?" prompt, hidden once saved */
.name-ask {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  max-width: 340px;
}
.name-ask input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 16px;
  transition: border-color 160ms var(--ease-out);
}
.name-ask input::placeholder { color: var(--muted); }
.name-ask input:focus { outline: none; border-color: rgba(62, 230, 168, 0.5); }

/* frame-by-frame waving robot (stands ~2s, waves, stands) */
.robot-stage {
  position: relative;
  width: 100%;
  max-width: 230px;
  aspect-ratio: 1;
  justify-self: center;
}
img.robot-video { filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.5)); }
/* video mascot: GPU-decoded, ~2MB, lighter than frame stacks */
.robot-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
video.robot-video {
  /* true alpha webm: floats over the glass, casts its own shadow */
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.45));
}

.robot-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  will-change: opacity;
}

/* dashboard robot speech bubble */
.robot-say {
  position: absolute;
  bottom: calc(100% - 18px);
  left: 50%;
  transform: translateX(-50%) translateY(8px) scale(0.92);
  transform-origin: bottom center;
  max-width: 240px;
  width: max-content;
  text-align: center;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.45;
  background: var(--ink);
  color: #11161a;
  border-radius: 16px;
  padding: 11px 16px;
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
  z-index: 2;
}
.robot-say::after { /* tail */
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--ink);
  border-bottom: 0;
}
.robot-say.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.robot-frame.f1 { opacity: 1; animation: wave-f1 5s linear infinite; }
.robot-frame.f2 { animation: wave-f2 5s linear infinite; }
.robot-frame.f3 { animation: wave-f3 5s linear infinite; }
.robot-frame.f4 { animation: wave-f4 5s linear infinite; }

@keyframes wave-f1 {
  0%, 42% { opacity: 1; }
  42.01%, 89.99% { opacity: 0; }
  90%, 100% { opacity: 1; }
}
@keyframes wave-f2 {
  0%, 42% { opacity: 0; }
  42.01%, 47% { opacity: 1; }
  47.01%, 84.99% { opacity: 0; }
  85%, 90% { opacity: 1; }
  90.01%, 100% { opacity: 0; }
}
@keyframes wave-f3 {
  0%, 47% { opacity: 0; }
  47.01%, 55% { opacity: 1; }
  55.01%, 62.99% { opacity: 0; }
  63%, 71% { opacity: 1; }
  71.01%, 78.99% { opacity: 0; }
  79%, 85% { opacity: 1; }
  85.01%, 100% { opacity: 0; }
}
@keyframes wave-f4 {
  0%, 55% { opacity: 0; }
  55.01%, 63% { opacity: 1; }
  63.01%, 70.99% { opacity: 0; }
  71%, 79% { opacity: 1; }
  79.01%, 100% { opacity: 0; }
}

/* ============================================================
   MODULE CARDS (dashboard grid)
   ============================================================ */
.mod-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.mod-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 22px;
  overflow: hidden;
  transition: transform 220ms var(--ease-out), border-color 220ms var(--ease-out),
              box-shadow 260ms var(--ease-out), background-color 220ms var(--ease-out);
  animation: rise 460ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

@media (hover: hover) and (pointer: fine) {
  .mod-card:hover {
    transform: translateY(-4px);
    border-color: rgba(62, 230, 168, 0.35);
    background: var(--surface-2);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.045),
      0 24px 54px -26px rgba(0, 0, 0, 0.8),
      0 0 0 1px rgba(62, 230, 168, 0.08);
  }
  .mod-card:hover .mod-icon { transform: scale(1.1) rotate(-4deg); }
}
.mod-card:active { transform: translateY(-1px) scale(0.99); }

/* Coordinated icon float: one shared rhythm, phase shifted by card index,
   so the motion reads as a gentle wave across the grid.
   Animation lives on the wrap; hover scale lives on the icon — no conflict. */
.mod-icon-wrap {
  position: relative;
  width: 74px;
  height: 74px;
  margin-bottom: 16px;
  display: grid;
  place-items: center;
  animation: icon-float 4.2s var(--ease-in-out) infinite;
  animation-delay: calc(var(--i, 0) * -0.45s);
}
.mod-icon-wrap::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(62, 230, 168, 0.14), transparent 70%);
}
.mod-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.45));
  transition: transform 260ms var(--ease-out);
}
@keyframes icon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.mod-code {
  position: absolute;
  top: 16px;
  right: 16px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 11px;
  transition: color 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .mod-card:hover .mod-code { color: var(--accent); border-color: rgba(62, 230, 168, 0.4); }
}
.mod-card.complete .mod-code {
  color: var(--accent);
  border-color: rgba(62, 230, 168, 0.35);
  background: rgba(62, 230, 168, 0.08);
}

.mod-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.mod-body > span { display: block; }
.mod-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 5px;
}
.mod-tagline {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
  flex: 1;
}
.mod-foot { display: flex !important; align-items: center; gap: 10px; margin-top: auto; }
.mod-count {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.mod-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.mod-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transition: width 500ms var(--ease-out);
}
.mod-pct {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 34px;
  text-align: right;
}
.mod-card.complete .mod-pct::after { content: " ✓"; }

/* completed module: soft green tint */
.mod-card.complete {
  background:
    linear-gradient(145deg, rgba(62, 230, 168, 0.1), rgba(62, 230, 168, 0.025) 65%),
    var(--surface);
  border-color: rgba(62, 230, 168, 0.28);
}
@media (hover: hover) and (pointer: fine) {
  .mod-card.complete:hover {
    background:
      linear-gradient(145deg, rgba(62, 230, 168, 0.14), rgba(62, 230, 168, 0.04) 65%),
      var(--surface-2);
    border-color: rgba(62, 230, 168, 0.45);
  }
}

/* ============================================================
   BADGES
   ============================================================ */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.badge {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 20px 12px 16px;
  transition: transform 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .badge:hover { transform: translateY(-4px); }
  .badge.got:hover .badge-img { transform: scale(1.12) rotate(5deg); }
}
.badge-img {
  width: 60px;
  height: 60px;
  margin: 0 auto 10px;
  object-fit: contain;
  transition: transform 240ms var(--ease-out), filter 300ms var(--ease-out);
}
.badge.locked { opacity: 0.5; }
.badge.locked .badge-img { filter: grayscale(1) brightness(0.55); }
.badge.got {
  border-color: rgba(244, 201, 93, 0.45);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(244, 201, 93, 0.14), rgba(244, 201, 93, 0.02) 70%),
    var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 160, 0.12),
    0 10px 34px -14px rgba(244, 201, 93, 0.25);
}
.badge.got .badge-img {
  filter: brightness(1.08) drop-shadow(0 8px 20px rgba(244, 201, 93, 0.45));
}
.badge.got .badge-name { color: var(--gold); }
.badge-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 2px;
}
.badge-desc { font-size: 0.7rem; color: var(--muted); line-height: 1.4; }

/* legendary tier: ruby-red gradient highlight */
.badge.legendary { position: relative; overflow: hidden; }
.badge-tier {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  color: #ffb199;
  background: rgba(255, 100, 80, 0.12);
  border: 1px solid rgba(255, 110, 90, 0.35);
}
.badge.legendary.locked {
  opacity: 0.65;
  border-color: rgba(255, 100, 80, 0.22);
}
.badge.legendary.got {
  border-color: rgba(255, 110, 80, 0.55);
  background:
    radial-gradient(130% 100% at 50% 0%, rgba(255, 90, 60, 0.18), rgba(244, 150, 60, 0.04) 60%),
    var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 170, 130, 0.18),
    0 12px 44px -12px rgba(255, 90, 60, 0.4);
  animation: legend-pulse 3s var(--ease-in-out) infinite;
}
@keyframes legend-pulse {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 170, 130, 0.18), 0 12px 44px -12px rgba(255, 90, 60, 0.4); }
  50% { box-shadow: inset 0 1px 0 rgba(255, 170, 130, 0.18), 0 12px 58px -10px rgba(255, 90, 60, 0.62); }
}
.badge.legendary.got .badge-img {
  filter: brightness(1.08) drop-shadow(0 8px 24px rgba(255, 95, 65, 0.6));
}
.badge.legendary.got .badge-name,
.badge.legendary.got .badge-status {
  background: linear-gradient(90deg, #ff8a5c, #ffb86b, #f4c95d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  .badge.legendary.got { animation: none !important; }
}

/* badges page (#/badges): larger cards + status */
.badge-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 22px;
  max-width: 420px;
}
.badge-grid.page-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.badge.lg {
  padding: 28px 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.badge.lg .badge-img { width: 86px; height: 86px; margin-bottom: 14px; }
.badge.lg .badge-name { font-size: 0.95rem; }
.badge.lg .badge-desc { font-size: 0.76rem; }
.badge-status {
  margin-top: auto;
  padding-top: 14px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.badge.got .badge-status { color: var(--gold); }

/* ============================================================
   MODULE / LESSON PAGES
   ============================================================ */
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 24px;
  transition: color 140ms var(--ease-out), transform 140ms var(--ease-out);
}
.crumb:hover { color: var(--accent); transform: translateX(-2px); }

.page-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.page-sub { color: var(--muted); font-size: 0.95rem; max-width: 40em; }

.mod-head {
  display: flex;
  gap: 26px;
  align-items: center;
  margin-bottom: 30px;
  animation: rise 460ms var(--ease-out) both;
}
.mod-head-icon {
  flex: 0 0 auto;
  width: 116px;
  height: 116px;
  object-fit: contain;
  filter: drop-shadow(0 16px 26px rgba(0, 0, 0, 0.5));
  animation: icon-float 4.2s var(--ease-in-out) infinite;
}
.mod-head-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}
.mod-head-meta .mod-bar { max-width: 200px; }

.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 16px 22px;
  transition: transform 180ms var(--ease-out), border-color 180ms var(--ease-out),
              background-color 180ms var(--ease-out);
  animation: rise 420ms var(--ease-out) both;
}
.lesson-row:nth-child(2) { animation-delay: 40ms; }
.lesson-row:nth-child(3) { animation-delay: 80ms; }
.lesson-row:nth-child(4) { animation-delay: 120ms; }
.lesson-row:nth-child(n+5) { animation-delay: 160ms; }
@media (hover: hover) and (pointer: fine) {
  .lesson-row:hover {
    transform: translateX(4px);
    border-color: rgba(62, 230, 168, 0.3);
    background: var(--surface-2);
  }
  .lesson-row:hover .lesson-arrow { opacity: 1; transform: translateX(0); }
}
.lesson-row:active { transform: scale(0.99); }

.lesson-check {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--muted);
  border: 1.5px solid var(--line-strong);
  transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out),
              border-color 200ms var(--ease-out);
}
.lesson-row.done .lesson-check {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.lesson-info { flex: 1; min-width: 0; }
.lesson-info .lesson-title, .lesson-info .lesson-meta { display: block; }
.lesson-title { font-weight: 600; font-size: 0.98rem; }
.lesson-row.done .lesson-title { color: var(--muted); }
.lesson-meta { font-size: 0.78rem; color: var(--muted); margin-top: 1px; }
.lesson-arrow {
  color: var(--accent);
  font-size: 1.05rem;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}

/* edit mode: delete button is a *sibling* of the row link (no button-in-link) */
.lesson-item { position: relative; }
.lesson-item .lesson-row { padding-right: 64px; }
.lesson-item .del-lesson {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}
.lesson-item .del-lesson:active { transform: translateY(-50%) scale(0.92); }

.add-lesson {
  margin-top: 14px;
  width: 100%;
  border-style: dashed;
  border-radius: var(--r-card);
}

/* lesson page */
.lesson-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.lesson-no {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(62, 230, 168, 0.08);
  border: 1px solid rgba(62, 230, 168, 0.2);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 12px;
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  background-size: cover;
  background-position: center;
  border-radius: var(--r-card);
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 32px;
}
.video-frame iframe, .video-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-card);
  padding: 40px 20px;
  margin-bottom: 32px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.video-placeholder img { width: 48px; height: 48px; object-fit: contain; opacity: 0.7; }

/* rendered markdown */
.content { font-size: 1.02rem; overflow-wrap: break-word; }
.content code { word-break: break-all; }
.content h2, .content h3, .content h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 1.9em 0 0.6em;
}
.content h2 { font-size: 1.4rem; }
.content h3 { font-size: 1.12rem; }
.content h2:first-child { margin-top: 0; }
.content p { margin: 0.85em 0; color: #c9d4cf; }
.content strong { color: var(--ink); font-weight: 600; }
.content ul, .content ol { margin: 0.85em 0 0.85em 1.5em; color: #c9d4cf; }
.content li { margin: 0.5em 0; }
.content li::marker { color: var(--accent); font-weight: 700; }
.content code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.86em;
  background: rgba(62, 230, 168, 0.08);
  border: 1px solid rgba(62, 230, 168, 0.15);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--accent);
}
.content blockquote {
  margin: 1.3em 0;
  padding: 16px 22px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 14px 14px 0;
}
.content blockquote p { margin: 0.3em 0; color: var(--ink); }
.content a { color: var(--accent); border-bottom: 1px solid rgba(62, 230, 168, 0.35); }
.content hr { border: 0; border-top: 1px solid var(--line); margin: 2.2em 0; }

.deliverable {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-top: 36px;
  padding: 22px 26px;
  background: linear-gradient(135deg, rgba(62, 230, 168, 0.09), rgba(62, 230, 168, 0.03));
  border: 1px solid rgba(62, 230, 168, 0.25);
  border-radius: var(--r-card);
}
.deliverable img { width: 50px; height: 50px; object-fit: contain; flex: 0 0 auto; }
.deliverable-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}
.deliverable p { color: var(--ink); }

.materials {
  margin-top: 18px;
  padding: 20px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}
.materials-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
}
.materials ul { list-style: none; }
.materials li { margin: 6px 0; }
.materials a {
  color: var(--accent);
  font-weight: 500;
  transition: opacity 140ms var(--ease-out);
}
.materials a:hover { opacity: 0.8; }

.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 44px;
  flex-wrap: wrap;
}
.lesson-nav .btn { max-width: 47%; }
/* ellipsis must live on a block-level child — .btn is inline-flex */
.lesson-nav .btn .ln-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   RESOURCES: CALCULATORS
   ============================================================ */
.calc-page { display: flex; flex-direction: column; gap: 12px; }

.calc-head { display: flex; align-items: center; gap: 12px; }
.calc-ico {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}
.calc-head h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.015em;
}
.calc-sub { font-size: 0.84rem; color: var(--muted); margin-left: 6px; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}
.kpi .result-num { font-size: 1.45rem; }

.calc-cols {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 12px;
  align-items: stretch;
}
.calc-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.calc-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.calc-right .result-card.grow { flex: 1; display: flex; flex-direction: column; }
.calc-right .result-card.grow .yrs { flex: 1; }
.calc-copy { margin-top: 6px; width: 100%; }

.cmp-foot {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.cmp-foot b { font-family: var(--font-display); font-size: 0.92rem; }
.accent-t { color: var(--accent); }
.warn-t { color: #ff9c6b; }
/* slider fields */
.sfield { display: flex; flex-direction: column; gap: 2px; }
.sfield-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.sfield-head span { font-size: 0.86rem; font-weight: 500; color: #c9d4cf; }
.sfield-head b {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}

.sfield input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.sfield input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--p, 50%), rgba(255, 255, 255, 0.09) var(--p, 50%));
}
.sfield input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(62, 230, 168, 0.001);
  transition: transform 120ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.sfield input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); }
.sfield input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 0 6px rgba(62, 230, 168, 0.18);
}
.sfield input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--p, 50%), rgba(255, 255, 255, 0.09) var(--p, 50%));
}
.sfield input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.calc-h {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  margin: 6px 0 0;
}
.calc-h:first-child { margin-top: 0; }

.calc-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}
.result-card.big {
  grid-column: 1 / -1;
  background:
    radial-gradient(400px 160px at 20% 0%, rgba(62, 230, 168, 0.1), transparent 70%),
    var(--surface);
}
.result-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.result-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.result-card.big .result-num { font-size: 2rem; }
.result-num.accent { color: var(--accent); }
.result-num.warn { color: #ff9c6b; }
.result-num small { font-size: 0.55em; font-weight: 600; color: var(--muted); }
.result-card.wide { grid-column: 1 / -1; }
.result-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 4px;
}

/* manual vs agent comparison bars */
.cmp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cmp-cut {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: rgba(62, 230, 168, 0.1);
  border: 1px solid rgba(62, 230, 168, 0.25);
  border-radius: 999px;
  padding: 3px 11px;
}
.cmp-cut.warn {
  color: #ff9c6b;
  background: rgba(255, 156, 107, 0.1);
  border-color: rgba(255, 156, 107, 0.3);
}
.cmp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.cmp-name {
  flex: 0 0 84px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.cmp-track {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.cmp-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transition: width 400ms var(--ease-out);
}
.cmp-fill.grey { background: rgba(255, 255, 255, 0.22); }
.cmp-val {
  flex: 0 0 86px;
  text-align: right;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
}

/* bar charts (5-year cumulative / MRR by month) */
.yrs {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 120px;
  min-height: 110px;
  padding-top: 6px;
}
.yrs.slim { gap: 4px; }
.yrs.slim .yr i { border-radius: 4px 4px 2px 2px; max-width: none; }
.yrs.slim .yr i.dim { opacity: 0.38; }
.yrs.slim .yr-lbl { font-size: 0.62rem; min-height: 1em; }
.yr {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 5px;
}
.yr i {
  display: block;
  width: 100%;
  max-width: 64px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 6px 18px -8px rgba(62, 230, 168, 0.5);
  transition: height 400ms var(--ease-out);
}
.yr i.neg { background: linear-gradient(180deg, #ff9c6b, #c96a40); box-shadow: none; }
.yr-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
}
.yr-val.warn { color: #ff9c6b; }
.yr-lbl { font-size: 0.7rem; font-weight: 600; color: var(--muted); }

.calc-note {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 4px 6px 0;
}

@media (max-width: 860px) {
  .calc-cols { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calc-sub { display: none; }
  .set-grid { grid-template-columns: 1fr; }
  .mat-row { flex-wrap: wrap; }
  .mat-source { order: 5; }
  .badge-grid.page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sf-inner { grid-template-columns: 1fr 1fr; }
  .sf-brand { grid-column: 1 / -1; }
  #app::before, #app::after { display: none; }
}

/* ============================================================
   MATERIALS
   ============================================================ */
.mat-list { display: flex; flex-direction: column; gap: 8px; }
.mat-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .mat-row:hover { border-color: rgba(62, 230, 168, 0.25); background: var(--surface-2); }
}
.mat-chip {
  flex: 0 0 76px;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 0;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}
.mat-chip.pdf { color: #ff9c8a; border-color: rgba(255, 156, 138, 0.35); }
.mat-chip.template { color: var(--gold); border-color: rgba(244, 201, 93, 0.35); }
.mat-chip.tool { color: var(--accent); border-color: rgba(62, 230, 168, 0.35); }
.mat-chip.link { color: #8ab6ff; border-color: rgba(138, 182, 255, 0.35); }
.mat-body { flex: 1; min-width: 0; }
.mat-title { display: block; font-weight: 600; font-size: 0.95rem; }
.mat-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mat-source {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
.mat-soon {
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  padding: 6px 14px;
}

/* ============================================================
   SETTINGS
   ============================================================ */
.set-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.set-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}
.set-card .field > span { color: var(--muted); }
.set-card .field input:focus, .set-card .field textarea:focus { border-color: rgba(62, 230, 168, 0.5); }
.set-hint { font-size: 0.76rem; color: var(--muted); }
.set-data-btns { display: flex; flex-wrap: wrap; gap: 8px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
}
.switch {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 44px;
  height: 25px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  position: relative;
  cursor: pointer;
  transition: background-color 200ms var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 200ms var(--ease-out);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(19px); }
.switch:active::after { transform: scale(0.92); }
.switch:checked:active::after { transform: translateX(19px) scale(0.92); }

.field select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-input);
  padding: 12px 16px;
}

body.no-mascot #mascot { display: none; }

/* ============================================================
   EDIT PANEL
   ============================================================ */
.edit-panel {
  margin: 18px 0 28px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid rgba(244, 201, 93, 0.4);
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise 300ms var(--ease-out) both;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}
.field input, .field textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-input);
  padding: 12px 16px;
  resize: vertical;
  transition: border-color 160ms var(--ease-out);
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row .field.grow { flex: 1; min-width: 240px; }
.edit-actions { display: flex; gap: 12px; }

.icon-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: color 140ms var(--ease-out), border-color 140ms var(--ease-out), transform 120ms var(--ease-out);
}
.icon-btn:hover { color: #ff7b7b; border-color: #ff7b7b; }
.icon-btn:active { transform: scale(0.92); }

/* ============================================================
   MASCOT
   ============================================================ */
#mascot {
  position: fixed;
  right: 24px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
#mascot-img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.5));
  animation: float 4.5s var(--ease-in-out) infinite;
  transition: transform 220ms var(--ease-out);
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
#mascot-shadow {
  width: 50px;
  height: 11px;
  margin-top: -7px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.5), transparent 70%);
  animation: shadow-pulse 4.5s var(--ease-in-out) infinite;
}
@keyframes shadow-pulse {
  0%, 100% { transform: scaleX(1); opacity: 0.9; }
  50% { transform: scaleX(0.82); opacity: 0.55; }
}
#mascot.celebrate #mascot-img { animation: hop 600ms var(--ease-in-out) infinite; }
@keyframes hop {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  35% { transform: translateY(-20px) rotate(-5deg); }
  70% { transform: translateY(0) rotate(3deg); }
}
#mascot-bubble {
  max-width: 220px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.45;
  background: var(--ink);
  color: #11161a;
  border-radius: 16px 16px 4px 16px;
  padding: 11px 15px;
  margin-bottom: 10px;
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(8px) scale(0.92);
  transform-origin: bottom right;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
#mascot-bubble.show { opacity: 1; transform: translateY(0) scale(1); }

/* ============================================================
   TOASTS
   ============================================================ */
#toasts {
  position: fixed;
  left: calc(var(--sidebar-w) + 20px);
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 14px 18px;
  min-width: 250px;
  max-width: 350px;
  box-shadow: 0 20px 50px -16px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
}
.toast.in { opacity: 1; transform: translateY(0) scale(1); }
.toast img { width: 42px; height: 42px; object-fit: contain; flex: 0 0 auto; }
.toast.badge { border-color: rgba(244, 201, 93, 0.45); overflow: visible; }

/* badge unlock: golden flash ring + spark burst around the toast */
.toast-flash {
  position: absolute;
  inset: -26px;
  border-radius: 30px;
  background: radial-gradient(closest-side, rgba(244, 201, 93, 0.4), rgba(244, 201, 93, 0.12) 55%, transparent 75%);
  pointer-events: none;
  opacity: 0;
  animation: toast-flash 950ms var(--ease-out) 120ms forwards;
}
@keyframes toast-flash {
  0% { opacity: 0; transform: scale(0.55); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.3); }
}
.spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--sz, 6px);
  height: var(--sz, 6px);
  border-radius: 50%;
  background: var(--c, var(--gold));
  box-shadow: 0 0 8px var(--c, var(--gold));
  pointer-events: none;
  opacity: 0;
  animation: spark-fly 850ms cubic-bezier(0.16, 1, 0.3, 1) calc(140ms + var(--dl, 0ms)) forwards;
}
@keyframes spark-fly {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.25); }
}
.toast-title { font-weight: 700; font-size: 0.88rem; }
.toast.badge .toast-title { color: var(--gold); }
.toast-body { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: rgba(10, 13, 16, 0.6);
}
.sf-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px clamp(16px, 3vw, 36px) 28px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
  gap: 28px;
}
.sf-brand { display: flex; align-items: flex-start; gap: 12px; }
.sf-brand img { width: 38px; height: 38px; object-fit: contain; opacity: 0.9; }
.sf-brand b {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}
.sf-brand em { font-style: normal; color: var(--accent); }
.sf-brand p { font-size: 0.8rem; color: var(--muted); margin-top: 3px; max-width: 22em; }
.sf-col { display: flex; flex-direction: column; gap: 7px; }
.sf-head {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.sf-col a {
  font-size: 0.84rem;
  font-weight: 500;
  color: #b9c6c0;
  transition: color 140ms var(--ease-out);
  width: fit-content;
}
.sf-col a:hover { color: var(--accent); }
.sf-copy {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px clamp(16px, 3vw, 36px) 22px;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--muted);
}

/* ============================================================
   BACKDROP (mobile sidebar)
   ============================================================ */
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 58;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1060px) {
  .mod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .badge-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .main { margin-left: 0; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 260ms var(--ease-out);
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.6);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .backdrop { display: block; opacity: 1; }
  .burger { display: flex; flex: 0 0 auto; }
  #top-continue { display: none; }
  #toasts { left: 16px; }

  .welcome { grid-template-columns: 1fr; padding: 24px; }
  .robot-stage { max-width: 170px; order: -1; margin-top: 34px; }
  .robot-say { max-width: 190px; font-size: 0.78rem; }
  .welcome-title { font-size: 1.4rem; }

  .mod-grid { grid-template-columns: 1fr; }
  .badge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .mod-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .mod-head-icon { width: 96px; height: 96px; }

  .lesson-nav .btn { max-width: 100%; flex: 1; }
  #mascot { right: 12px; bottom: 10px; }
  #mascot-img { width: 66px; height: 66px; }
  #mascot-bubble { max-width: 165px; font-size: 0.76rem; }

  /* lock page scroll behind the open drawer */
  body.nav-open { overflow: hidden; }

  /* ≥16px form controls so iOS Safari doesn't auto-zoom on focus */
  #search, .field input, .field textarea, .field select, .name-ask input { font-size: 1rem; }
}

/* comfortable touch targets on coarse pointers */
@media (pointer: coarse) {
  .sfield input[type="range"] { height: 40px; }
  .sfield input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -9.5px; }
  .sfield input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; }
  .icon-btn { width: 40px; height: 40px; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .mod-icon-wrap, .mod-head-icon, #mascot-img,
  #mascot-shadow, .robot-frame, .bg::before {
    animation: none !important;
  }
  .robot-frame { opacity: 0 !important; }
  .robot-frame.f1 { opacity: 1 !important; }
  #mascot.celebrate #mascot-img { animation: none !important; }
  .welcome, .mod-card, .lesson-row, .mod-head, .edit-panel {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ============================================================
   GLASSMORPHISM LAYER
   Frosted surfaces over the aurora background. Real backdrop
   blur + 1px inner light edge. Solid fallbacks below.
   ============================================================ */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {

  /* chrome: sidebar + topbar, deepest blur */
  .sidebar {
    background: rgba(13, 17, 22, 0.5);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
  }
  .topbar {
    background: rgba(9, 12, 16, 0.45);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  /* content surfaces: light frost so the aurora glows through */
  .mod-card, .lesson-row, .badge, .kpi, .result-card,
  .calc-form, .set-card, .mat-row, .materials,
  .video-placeholder, .edit-panel {
    background: rgba(18, 24, 30, 0.34);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
  }
  .mod-card:hover, .lesson-row:hover, .mat-row:hover {
    background: rgba(24, 31, 38, 0.44);
  }
  .mod-card.complete {
    background:
      linear-gradient(145deg, rgba(62, 230, 168, 0.12), rgba(62, 230, 168, 0.025) 65%),
      rgba(18, 24, 30, 0.34);
  }
  .mod-card.complete:hover {
    background:
      linear-gradient(145deg, rgba(62, 230, 168, 0.16), rgba(62, 230, 168, 0.04) 65%),
      rgba(24, 31, 38, 0.44);
  }
  .badge.got {
    background:
      radial-gradient(120% 90% at 50% 0%, rgba(244, 201, 93, 0.15), rgba(244, 201, 93, 0.02) 70%),
      rgba(18, 24, 30, 0.34);
  }
  .badge.legendary.got {
    background:
      radial-gradient(130% 100% at 50% 0%, rgba(255, 90, 60, 0.19), rgba(244, 150, 60, 0.04) 60%),
      rgba(18, 24, 30, 0.34);
  }

  /* floating chrome: menus, search, toasts */
  #data-menu, #search-results, .toast {
    background: rgba(20, 26, 32, 0.78);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    backdrop-filter: blur(24px) saturate(150%);
  }
  #search {
    background: rgba(22, 28, 34, 0.45);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
  #search:focus { background: rgba(26, 33, 40, 0.6); }
}

/* honest fallback: no transparency wanted or supported */
@media (prefers-reduced-transparency: reduce) {
  .sidebar, .topbar, .mod-card, .lesson-row, .badge, .kpi, .result-card,
  .calc-form, .set-card, .mat-row, .materials, .video-placeholder,
  .edit-panel, #data-menu, #search-results, .toast, #search, .welcome {
    background: var(--surface) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}
