/* Криспи: тёмная тема с фиолетовыми акцентами по умолчанию. */
:root {
  --tg-theme-bg-color: #0B0B10;
  --tg-theme-text-color: #F5F3FF;
  --tg-theme-hint-color: #9B97B0;
  --tg-theme-link-color: #A78BFA;
  --tg-theme-button-color: #8B5CF6;
  --tg-theme-button-text-color: #F8F5FF;
  --tg-theme-secondary-bg-color: #16161F;
  --tg-theme-header-bg-color: #0B0B10;
  --tg-theme-section-bg-color: #16161F;
  --tg-theme-subtitle-text-color: #C4C0D4;
  --tg-theme-destructive-text-color: #F87171;

  --bg: #0B0B10;
  --text: #F5F3FF;
  --muted: #9B97B0;
  --card: #16161F;
  --card-2: #1C1C28;
  --line: rgba(245, 243, 255, 0.08);
  --accent: #8B5CF6;
  --accent-2: #A78BFA;
  --accent-text: #F8F5FF;
  --subtitle: #C4C0D4;
  --ok: #34D399;
  --ok-bg: rgba(52, 211, 153, 0.14);
  --bad: #F87171;
  --bad-bg: rgba(248, 113, 113, 0.14);
  --warn: #FBBF24;
  --warn-bg: rgba(251, 191, 36, 0.14);
  --radius: 24px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Unbounded', var(--font);
  --nav-h: 86px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --glow: 0 8px 32px rgba(139, 92, 246, 0.35);
  --teal: #2DD4BF;
  --blue: #60A5FA;
  --amber: #FBBF24;
  --violet: #A78BFA;
}

[data-theme='light'] {
  --bg: #F4F1FA;
  --text: #1C1630;
  --muted: #6F6A80;
  --card: #FFFFFF;
  --card-2: #EDE9F8;
  --line: rgba(28, 22, 48, 0.08);
  --accent: #7C3AED;
  --accent-2: #8B5CF6;
  --accent-text: #F8F5FF;
  --subtitle: #534D66;
  --ok: #0F7A55;
  --ok-bg: rgba(15, 122, 85, 0.12);
  --bad: #B42318;
  --bad-bg: rgba(180, 35, 24, 0.1);
  --warn: #B45309;
  --warn-bg: rgba(180, 83, 9, 0.12);
  --shadow: 0 10px 30px rgba(28, 22, 48, 0.08);
  --glow: 0 8px 28px rgba(124, 58, 237, 0.22);
  --teal: #0F766E;
  --blue: #1D4ED8;
  --amber: #B45309;
  --violet: #6D28D9;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; background: var(--bg); }
body {
  min-height: 100%;
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(139, 92, 246, 0.16), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[data-theme='light'] body {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(139, 92, 246, 0.12), transparent 55%),
    var(--bg);
}

#app {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px);
}
#app.no-nav { padding-bottom: 16px; }

img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent-2); }

.page {
  width: min(460px, 100%);
  margin: 0 auto;
  padding: 16px 16px 24px;
  animation: rise 0.35s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand img, .brand svg { width: 36px; height: 36px; border-radius: 12px; }
.brand-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.03em;
}
.brand-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }

.hello h1, .greet h1 {
  font-family: var(--display);
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.04em;
  margin: 0 0 6px;
  font-weight: 600;
}
.hello p, .greet p { margin: 0; color: var(--subtitle); font-size: 14px; }

.greet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.greet-copy { min-width: 0; }
.greet-ava {
  width: 56px; height: 56px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--glow);
  border: 2px solid rgba(167, 139, 250, 0.45);
}
.greet-ava .avatar-svg, .greet-ava svg { display: block; width: 100%; height: 100%; }

/* Hero carousel */
.hero-wrap { position: relative; margin: 4px 0 16px; }
.hero-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 12px;
  scrollbar-width: none;
}
.hero-track::-webkit-scrollbar { display: none; }
.hero-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  position: relative;
  min-height: 168px;
  padding: 22px 20px 20px;
  border-radius: var(--radius);
  color: #F8F5FF;
  overflow: hidden;
  text-decoration: none;
  background:
    radial-gradient(420px 180px at 90% 0%, rgba(167, 139, 250, 0.55), transparent 60%),
    linear-gradient(135deg, #3B1D63 0%, #5B21B6 45%, #8B5CF6 100%);
  box-shadow: var(--glow);
}
.hero-slide.alt {
  background:
    radial-gradient(420px 180px at 90% 0%, rgba(244, 196, 48, 0.28), transparent 55%),
    linear-gradient(135deg, #1F1638 0%, #4C1D95 60%, #7C3AED 100%);
}
.hero-slide.review {
  background:
    radial-gradient(420px 180px at 90% 0%, rgba(52, 211, 153, 0.28), transparent 55%),
    linear-gradient(135deg, #10201C 0%, #164E3B 50%, #5B21B6 100%);
}
.hero-kicker {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 700; opacity: 0.85; margin-bottom: 8px;
}
.hero-slide h2 {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: -0.04em;
  margin: 0 0 8px;
  font-weight: 600;
  max-width: 80%;
}
.hero-slide p { margin: 0 0 16px; font-size: 13px; opacity: 0.9; max-width: 85%; }
.pill-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: #3B1D63;
  font-weight: 800;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}
.hero-dots {
  display: flex; justify-content: center; gap: 6px; margin-top: 10px;
}
.hero-dots i {
  width: 6px; height: 6px; border-radius: 99px; background: var(--muted); opacity: 0.4;
}
.hero-dots i.on { width: 16px; background: var(--accent-2); opacity: 1; }

/* Chips */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.chip, .filter-chip {
  flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--subtitle);
  white-space: nowrap;
}
.filter-chip.on, .chip.on {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
  box-shadow: var(--glow);
}

.review-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 14px;
  padding: 16px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #5B21B6, #8B5CF6 70%);
  color: #fffdf8;
  text-decoration: none;
  box-shadow: var(--glow);
}
.review-cta strong { display: block; font-size: 15px; }
.review-cta span { font-size: 12px; opacity: 0.9; }
.review-cta .chev { margin-left: auto; font-size: 22px; opacity: 0.9; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title a { font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 700; }

/* Bento course cards */
.bento, .course-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.bento-card, .course-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 168px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.course-card {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
}
.card-ico {
  width: 36px; height: 36px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: white;
  margin-bottom: 16px;
}
.card-ico svg { width: 18px; height: 18px; }
.card-arrow {
  position: absolute;
  top: 16px; right: 16px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card-2);
  color: var(--muted);
  font-size: 16px;
}
.bento-card h2, .course-card h2 {
  margin: auto 0 6px;
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: -0.03em;
  font-weight: 600;
  line-height: 1.2;
}
.bento-card p, .course-card p { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.progress-row { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--subtitle); }
.bar {
  flex: 1;
  height: 6px;
  background: var(--tg-theme-secondary-bg-color);
  border-radius: 99px;
  overflow: hidden;
}
[data-theme='dark'] .bar { background: #2A2A38; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7C3AED, #A78BFA); width: 0; }

.accent-teal { background: linear-gradient(135deg, #0F766E, #2DD4BF); }
.accent-blue { background: linear-gradient(135deg, #1D4ED8, #60A5FA); }
.accent-amber { background: linear-gradient(135deg, #B45309, #F59E0B); }
.accent-violet { background: linear-gradient(135deg, #6D28D9, #A78BFA); }

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 6px;
}
.quick-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  min-height: 110px;
}
.quick-card strong { font-family: var(--display); font-size: 16px; letter-spacing: -0.03em; }
.quick-card span { font-size: 12px; color: var(--muted); margin-top: auto; }
.quick-card .card-ico { margin-bottom: 0; }

.notice, .draft {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.45;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--subtitle);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 44px;
}
.course-hero {
  padding: 22px 18px 18px;
  border-radius: var(--radius);
  color: white;
  margin-bottom: 18px;
  box-shadow: var(--glow);
  background: linear-gradient(135deg, #3B1D63, #8B5CF6);
}
.course-hero.accent-teal { background: linear-gradient(135deg, #134E4A, #0F766E 40%, #8B5CF6); }
.course-hero.accent-blue { background: linear-gradient(135deg, #1E3A8A, #1D4ED8 40%, #8B5CF6); }
.course-hero.accent-amber { background: linear-gradient(135deg, #78350F, #B45309 40%, #7C3AED); }
.course-hero.accent-violet { background: linear-gradient(135deg, #3B1D63, #6D28D9, #8B5CF6); }
.course-hero .kicker { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; font-weight: 700; }
.course-hero h1 { margin: 6px 0 8px; font-family: var(--display); font-size: 24px; letter-spacing: -0.04em; font-weight: 600; }
.course-hero p { margin: 0 0 14px; opacity: 0.92; font-size: 14px; }
.course-hero .progress-row { color: rgba(255,255,255,0.9); }
.course-hero .bar { background: rgba(255,255,255,0.25); }
.course-hero .bar > i { background: white; }

.module { margin-bottom: 18px; }
.module h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.lesson-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 14px;
  background: var(--card);
  border-radius: 20px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
}
.lesson-row.locked { opacity: 0.55; pointer-events: none; }
.num {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  background: var(--card-2);
}
.lesson-row.done .num { background: var(--ok-bg); color: var(--ok); }
.lesson-row h3 { margin: 0; font-size: 15px; }
.lesson-row small { color: var(--muted); font-size: 12px; }
.status { font-size: 11px; font-weight: 700; color: var(--muted); }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: var(--card-2);
  border-radius: 16px;
  margin: 12px 0 16px;
}
.tabs a {
  text-align: center;
  text-decoration: none;
  color: var(--subtitle);
  font-weight: 700;
  font-size: 13px;
  padding: 9px 6px;
  border-radius: 12px;
}
.tabs a.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.video-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0A0A10;
  aspect-ratio: 16/10;
  margin-bottom: 12px;
  color: #f7f4ee;
  box-shadow: var(--shadow);
}
.video-frame iframe, .video-frame .poster {
  width: 100%; height: 100%; border: 0; display: block;
}
.video-frame .poster {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px;
  background:
    radial-gradient(circle at 70% 20%, rgba(167,139,250,0.35), transparent 40%),
    linear-gradient(180deg, rgba(11,11,16,0.1), rgba(11,11,16,0.85)),
    var(--course-accent, #8B5CF6);
}
.play {
  position: absolute; inset: 0; margin: auto;
  width: 62px; height: 62px; border-radius: 50%;
  background: rgba(255,255,255,0.2); backdrop-filter: blur(8px);
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,0.3);
}
.play::after {
  content: '';
  width: 0; height: 0;
  border-left: 16px solid white;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  margin-left: 4px;
}
.badge {
  position: absolute; top: 12px; left: 12px;
  font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 4px 8px;
  border-radius: 999px;
}
.theory, .q-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  border: 1px solid var(--line);
}
.theory h2, .card h2, .q-card h2 {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  font-weight: 600;
}
.theory p, .lead { margin: 0 0 12px; font-size: 15px; color: var(--text); }
.keypoints { display: grid; gap: 8px; margin: 14px 0; }
.keypoints div {
  background: var(--card-2);
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  border-left: 3px solid var(--accent);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7C3AED, #8B5CF6 50%, #A78BFA);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
  margin-top: 8px;
  box-shadow: var(--glow);
  border: 0;
}
.btn.secondary {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.ghost {
  background: transparent;
  box-shadow: none;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.q-meta { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 8px; letter-spacing: 0.04em; text-transform: uppercase; }
.options { display: grid; gap: 8px; }
.option {
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--card-2);
  border: 1px solid var(--line);
  font-size: 15px;
}
.option.selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.option.correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.option.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.option:disabled { cursor: default; }

.explain {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
}
.explain.ok { background: var(--ok-bg); color: var(--ok); }
.explain.bad { background: var(--bad-bg); color: var(--bad); }
.explain strong { display: block; margin-bottom: 4px; }

.score-card {
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.score-card .big {
  font-family: var(--display);
  font-size: 48px;
  letter-spacing: -0.05em;
  margin: 8px 0;
}
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card-2);
}
.accounts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chat { display: flex; flex-direction: column; gap: 0; }
.chat-log { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; max-height: none; }
.bubble {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  white-space: pre-wrap;
}
.bubble.bot { background: var(--card); border-bottom-left-radius: 6px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.bubble.me {
  align-self: flex-end;
  background: linear-gradient(135deg, #7C3AED, #8B5CF6);
  color: var(--accent-text);
  border-bottom-right-radius: 6px;
}
.mode-banner {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--warn-bg);
  color: var(--warn);
  margin-bottom: 12px;
}
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  padding: 8px 0 10px;
  margin-top: 8px;
}
.composer input {
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0 16px;
}
.composer button {
  min-width: 48px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7C3AED, #A78BFA);
  color: var(--accent-text);
  font-weight: 800;
  box-shadow: var(--glow);
}

/* Floating pill nav */
.nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  height: 64px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--card) 86%, transparent);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 999px;
  z-index: 20;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.nav a {
  text-decoration: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 700;
  position: relative;
  border-radius: 999px;
}
.nav a.active {
  color: var(--accent-text);
  background: linear-gradient(135deg, #7C3AED, #8B5CF6);
  box-shadow: var(--glow);
}
.nav .dot {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--bad);
  color: white;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.nav a.active .dot { top: 2px; }

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 8px);
  transform: translateX(-50%);
  background: #1C1630;
  color: #F5F3FF;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: var(--glow);
  border: 1px solid rgba(167,139,250,0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.typing { font-size: 13px; color: var(--muted); padding: 0 4px; }

@media (prefers-reduced-motion: reduce) {
  .page, .toast, .levelup-card, .confetti i, .levelup-avatar,
  .avatar-svg .ava-motion,
  .avatar-svg .ava-actor,
  .avatar-svg .ava-sparkles i,
  .avatar-svg.ava-happy .ava-motion { animation: none !important; transition: none; }
}

/* Живые иллюстрированные персонажи: дыхание, покачивание, прыжок, искры. */
.avatar-svg.avatar-illust {
  --ava-delay: 0s;
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 50%;
  flex-shrink: 0;
  line-height: 0;
}
.avatar-illust .ava-root { position: absolute; inset: 0; }
.avatar-illust .ava-bg,
.avatar-illust .ava-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.avatar-illust .ava-bg { z-index: 0; }
.avatar-illust .ava-motion {
  position: absolute;
  inset: 0;
  z-index: 1;
  transform-origin: 50% 92%;
  animation: ava-hop-cycle 7.6s var(--ava-delay) ease-in-out infinite;
}
.avatar-illust.ava-pose-hop .ava-motion { animation-duration: 5.6s; }
.avatar-illust .ava-actor {
  position: absolute;
  inset: 0;
  transform-origin: 50% 92%;
  animation: ava-breathe-sway 3.4s var(--ava-delay) ease-in-out infinite;
}
.avatar-illust .ava-sprite {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.avatar-illust .ava-frame { z-index: 3; }
.avatar-illust .ava-sparkles {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
}
.avatar-illust.ava-happy .ava-sparkles { opacity: 1; }
.avatar-illust .ava-sparkles i {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #F4C430;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  top: calc(18% + var(--i) * 10%);
  left: calc(14% + (var(--i) * 13%) * (var(--i) * 0.3 + 1));
  offset: none;
  animation: ava-spark 0.8s ease-out both;
  animation-delay: calc(var(--i) * 0.06s);
}
.avatar-illust .ava-sparkles i:nth-child(1) { top: 16%; left: 22%; }
.avatar-illust .ava-sparkles i:nth-child(2) { top: 12%; left: 58%; background: #A78BFA; }
.avatar-illust .ava-sparkles i:nth-child(3) { top: 34%; left: 78%; }
.avatar-illust .ava-sparkles i:nth-child(4) { top: 28%; left: 12%; background: #F8F5FF; }
.avatar-illust .ava-sparkles i:nth-child(5) { top: 62%; left: 80%; background: #F472B6; }
.avatar-illust .ava-sparkles i:nth-child(6) { top: 70%; left: 18%; }
.avatar-illust.ava-happy .ava-motion {
  animation: ava-jump 0.72s ease;
}
@keyframes ava-breathe-sway {
  0%, 100% { transform: rotate(0deg) scale(1, 1); }
  30% { transform: rotate(-1.15deg) scale(1.004, 1.018); }
  50% { transform: rotate(0deg) scale(1, 1.022); }
  80% { transform: rotate(1.15deg) scale(1.004, 1.016); }
}
@keyframes ava-hop-cycle {
  0%, 88%, 100% { transform: translateY(0); }
  91% { transform: translateY(-6%); }
  94% { transform: translateY(0); }
  96.5% { transform: translateY(-2.5%); }
}
@keyframes ava-jump {
  0%, 100% { transform: translateY(0); }
  28% { transform: translateY(-11%); }
  52% { transform: translateY(0); }
  70% { transform: translateY(-4%); }
}
@keyframes ava-spark {
  0% { transform: scale(0.2) rotate(0deg); opacity: 0; }
  35% { transform: scale(1.15) rotate(20deg); opacity: 1; }
  100% { transform: scale(0.4) rotate(50deg) translateY(-8px); opacity: 0; }
}

.hero-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  box-shadow: var(--shadow);
  min-height: 44px;
}
.hero-chip-ava {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.hero-chip-ava .avatar-svg, .hero-chip-ava svg { display: block; width: 100%; height: 100%; }
.hero-chip-meta { min-width: 72px; }
.hero-chip-meta strong { display: block; font-size: 12px; line-height: 1.2; }
.hero-chip-meta .bar { width: 72px; margin-top: 4px; }

.watched-note {
  margin: 8px 0;
  font-size: 13px;
  color: var(--ok);
  font-weight: 600;
}

.char-hero {
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 16px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.char-ava {
  width: 128px; height: 128px;
  margin: 0 auto 10px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: var(--glow);
  border: 2px solid rgba(167, 139, 250, 0.4);
}
.char-ava .avatar-svg, .char-ava svg { display: block; width: 100%; height: 100%; }
.char-name { font-family: var(--display); font-size: 22px; letter-spacing: -0.03em; font-weight: 600; }
.char-role { color: var(--muted); font-size: 13px; margin-top: 2px; }
.char-level { margin: 8px 0 12px; font-weight: 700; font-size: 14px; }
.xp-track .bar { height: 8px; }
.xp-track span { display: block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--subtitle); }

.skill-list { display: grid; gap: 10px; }
.skill-row {
  background: var(--card);
  border-radius: 20px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.skill-lab { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.skill-lab strong { display: block; font-size: 14px; }
.skill-lab small { color: var(--muted); font-size: 12px; }
.skill-ico { width: 36px; height: 36px; border-radius: 12px; }
.skill-ico svg { width: 18px; height: 18px; }
.skill-bar { height: 8px; }
.accent-bar-teal i { background: var(--teal); }
.accent-bar-blue i { background: var(--blue); }
.accent-bar-amber i { background: var(--amber); }
.accent-bar-violet i { background: var(--violet); }

.looks, .swatches, .species-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.species-grid { grid-template-columns: repeat(3, 1fr); }
.look, .pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 10px;
  border-radius: 18px;
  background: var(--card);
  border: 2px solid transparent;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  position: relative;
}
.look svg, .pick svg, .look .avatar-svg, .pick .avatar-svg { border-radius: 50%; display: block; width: 64px; height: 64px; margin: 0 auto; }
.look.on, .pick.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.pick.locked { opacity: 0.45; }
.lock-tag {
  font-size: 9px; font-weight: 800; color: var(--accent-2); letter-spacing: 0.04em;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.swatch.on { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }

.badge-grid, .cert-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cert-list { grid-template-columns: 1fr; }
.badge-card, .cert-card {
  background: var(--card);
  border-radius: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  opacity: 0.45;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: inherit;
}
.badge-card.on, .cert-card.on { opacity: 1; box-shadow: var(--shadow); }
.badge-ico { font-size: 22px; line-height: 1; margin-bottom: 4px; }
.badge-card strong, .cert-card strong { font-size: 13px; }
.badge-card span, .cert-card span { font-size: 11px; color: var(--muted); font-weight: 500; }

.settings-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  color: inherit;
  text-decoration: none;
}
.settings-row:last-child { border-bottom: 0; }
.settings-row strong { display: block; font-size: 14px; }
.settings-row small { color: var(--muted); font-size: 12px; }

.toggle {
  width: 48px; height: 28px;
  border-radius: 999px;
  background: #2A2A38;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.toggle i {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}
.toggle.on { background: var(--accent); }
.toggle.on i { transform: translateX(20px); }

/* Setup / character creator */
.setup-page { padding-bottom: 32px; }
.setup-preview {
  display: grid;
  place-items: center;
  padding: 16px 0 8px;
}
.setup-preview .char-ava { width: 160px; height: 160px; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.segmented .segment {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 999px;
  min-height: 44px;
}
.segmented .segment.on {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--glow);
}
.setup-section { margin-top: 16px; }
.setup-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.cert-view {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid var(--line);
}
.cert-view canvas, .cert-view img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  background: #0B0B12;
}
.cert-actions { display: grid; gap: 8px; margin-top: 12px; }
.cert-note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.45; }

.levelup {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 6, 16, 0.72);
  display: grid;
  place-items: center;
  padding: 24px 16px;
  backdrop-filter: blur(8px);
}
.levelup-card {
  position: relative;
  width: min(360px, 100%);
  overflow: hidden;
  text-align: center;
  background: var(--card);
  color: var(--text);
  border-radius: 28px;
  padding: 28px 20px 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(167, 139, 250, 0.25);
  animation: pop 0.5s cubic-bezier(.2, 1.2, .3, 1);
}
@keyframes pop {
  from { transform: scale(0.86); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.levelup-avatar {
  width: 112px; height: 112px;
  margin: 8px auto 12px;
  border-radius: 50%;
  overflow: hidden;
  animation: bounce 0.7s ease;
  box-shadow: var(--glow);
}
.levelup-avatar .avatar-svg, .levelup-avatar svg { display: block; width: 100%; height: 100%; }
@keyframes bounce {
  0% { transform: scale(0.6) translateY(12px); }
  60% { transform: scale(1.08) translateY(-6px); }
  100% { transform: none; }
}
.levelup-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}
.levelup-card h2 {
  font-family: var(--display);
  font-size: 28px;
  letter-spacing: -0.04em;
  margin: 4px 0 2px;
}
.levelup-title { margin: 0; font-weight: 700; color: var(--accent-2); }
.levelup-note { margin: 8px 0 16px; font-size: 14px; color: var(--subtitle); }
.confetti { pointer-events: none; position: absolute; inset: 0; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -12px;
  width: 7px; height: 10px;
  border-radius: 2px;
  animation: fall linear forwards;
  opacity: 0.9;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(360px) rotate(260deg); opacity: 0; }
}
