/* Clube Amplexo Educação — design system (vermelho, branco e dourado) */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/fonts/nunito-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url("/static/fonts/baloo2-latin.woff2") format("woff2");
}

:root {
  --red-900: #4a0505;
  --red-800: #660707;
  --red-700: #8a0e0e;
  --red-600: #b3171b;
  --red-500: #d42a2f;
  --red-100: #fde8e8;
  --gold-700: #8a6a1f;
  --gold-600: #b08a2e;
  --gold-500: #d4af37;
  --gold-400: #e6c65c;
  --gold-200: #f6e7b6;
  --white: #ffffff;

  --bg: #fbf8f3;
  --bg-soft: #f4eee4;
  --surface: #ffffff;
  --surface-2: #fffaf2;
  --text: #2a1414;
  --text-soft: #6b5353;
  --border: #ead9c2;
  --primary: var(--red-700);
  --primary-strong: var(--red-800);
  --primary-contrast: #ffffff;
  --accent: var(--gold-500);
  --accent-strong: var(--gold-700);
  --success: #1f7a45;
  --danger: #c0262c;
  --shadow: 0 1px 2px rgba(74, 5, 5, .06), 0 8px 24px rgba(74, 5, 5, .08);
  --shadow-lg: 0 20px 60px rgba(74, 5, 5, .18);
  --radius: 18px;
  --radius-sm: 12px;
  --ring: 0 0 0 3px rgba(212, 175, 55, .55);
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Baloo 2", "Nunito", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #140b0b;
  --bg-soft: #1c1010;
  --surface: #221313;
  --surface-2: #2a1717;
  --text: #f8efe4;
  --text-soft: #cdb8aa;
  --border: #3d2424;
  --primary: #e0474c;
  --primary-strong: var(--red-500);
  --accent: var(--gold-400);
  --accent-strong: var(--gold-400);
  --success: #4cc27f;
  --danger: #ff6b6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  transition: background-color .3s ease, color .3s ease;
}
img { max-width: 100%; display: block; }
svg { max-width: 100%; }
svg.icon { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 2.2vw, 1.5rem); }
h3, .h3 { font-size: 1.15rem; }
h2 svg.icon, h3 svg.icon { margin-right: .4rem; color: var(--accent-strong); }
p { margin: 0 0 1em; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--bg-soft); padding: .1rem .4rem; border-radius: 6px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: .6rem 1rem; border-radius: 10px; background: var(--accent); color: var(--red-900); font-weight: 800; }
.skip-link:focus { top: 1rem; }
.muted { color: var(--text-soft); }
.small { font-size: .875rem; }
.center { text-align: center; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.error-text { color: var(--danger); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid.tight { gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.grid.align-start { align-items: start; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin-bottom: .2rem; }
.page-head p { margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: .35rem; font-weight: 800; margin-bottom: 1rem; }

/* Golden sparkle background */
#sparkles { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; opacity: .55; }
[data-theme="dark"] #sparkles { opacity: .8; }
@media (prefers-reduced-motion: reduce) {
  #sparkles { display: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Layout */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 1.25rem 1rem;
  background:
    radial-gradient(400px 260px at 0% 0%, rgba(212, 175, 55, .18), transparent 70%),
    linear-gradient(180deg, var(--red-800), var(--red-900));
  color: #fff;
  display: flex; flex-direction: column; gap: 1rem;
  box-shadow: var(--shadow-lg);
}
.sidebar .brand { display: flex; align-items: center; justify-content: center; padding: .5rem .25rem 1rem; border-bottom: 1px solid rgba(230, 198, 92, .25); }
.sidebar .brand img { width: 190px; height: auto; }
.nav { display: flex; flex-direction: column; gap: .2rem; }
.nav a, .nav-logout {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .9rem; border-radius: 12px;
  color: #f8e9d9; font-weight: 700; font: inherit; font-weight: 700;
  transition: background .2s ease, transform .2s ease, color .2s ease;
}
.nav a svg, .nav-logout svg { width: 20px; height: 20px; flex: none; }
.nav a:hover, .nav-logout:hover { background: rgba(255, 255, 255, .08); text-decoration: none; transform: translateX(3px); }
.nav a.active { background: linear-gradient(90deg, rgba(212, 175, 55, .3), rgba(212, 175, 55, .08)); color: var(--gold-200); box-shadow: inset 3px 0 0 var(--gold-500); }
.nav .nav-section { margin: .8rem .9rem .2rem; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: rgba(246, 231, 182, .65); font-weight: 800; }
.nav-logout { width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; }
.sidebar .spacer { flex: 1; }
.sidebar .mini-profile { display: flex; align-items: center; gap: .65rem; padding: .6rem; border-radius: 14px; background: rgba(0, 0, 0, .2); color: #fff; }
.sidebar .mini-profile:hover { text-decoration: none; background: rgba(0, 0, 0, .3); }
.sidebar .mini-profile .avatar-svg { width: 46px; height: 46px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2px rgba(230, 198, 92, .7); }
.sidebar .mini-profile .avatar-svg svg { width: 100%; height: 100%; }
.sidebar .mini-profile strong { display: block; font-size: .92rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .mini-profile span span { font-size: .76rem; color: var(--gold-200); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.75rem;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50vw; }
.content { padding: 1.75rem; max-width: 1200px; width: 100%; margin: 0 auto; flex: 1; }
.chip-btn.menu-toggle { display: none; }
.footer { padding: 1.25rem 1.75rem; color: var(--text-soft); font-size: .8rem; text-align: center; }

/* Toggles (theme/lang) */
.toggles { display: flex; align-items: center; gap: .5rem; }
.chip-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .75rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
  transition: transform .15s ease, border-color .2s ease;
}
.chip-btn:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.chip-btn svg { width: 16px; height: 16px; }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }
[data-theme="dark"] .theme-icon-light { display: none; }
.logo-on-dark { display: none; }
[data-theme="dark"] .logo-on-dark { display: block; }
[data-theme="dark"] .logo-on-light { display: none; }

/* Cards */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.gold { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 10%, var(--surface)), var(--surface)); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }
.card.hover { transition: transform .2s ease, box-shadow .2s ease; }
.card.hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.hero {
  position: relative; overflow: hidden;
  border-radius: calc(var(--radius) + 6px);
  padding: 1.75rem;
  background:
    radial-gradient(1200px 300px at 110% -20%, rgba(212, 175, 55, .38), transparent 60%),
    linear-gradient(135deg, var(--red-700), var(--red-900));
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.hero h1 { color: #fff; margin-bottom: .25rem; }
.hero p { color: #f6e7d7; margin: 0; }
.hero .hero-grid { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 1.5rem; align-items: center; }
.hero .hero-avatar { display: block; width: 132px; height: 132px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, var(--gold-200), var(--gold-500)); padding: 4px; box-shadow: 0 0 0 4px rgba(255, 255, 255, .15), 0 10px 30px rgba(0, 0, 0, .3); overflow: hidden; transition: transform .25s ease; }
.hero .hero-avatar:hover { transform: scale(1.05) rotate(-3deg); }
.hero .hero-avatar svg { width: 100%; height: 100%; border-radius: 50%; }
.hero .hero-xp { margin-top: .4rem; color: var(--gold-200); font-weight: 700; }
.hero.compact .hero-grid { grid-template-columns: auto 1fr auto; }
.hero .hero-logo { width: 84px; height: 84px; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .35)); }
.hero .shine { position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .12) 45%, transparent 60%); transform: translateX(-100%); animation: shine 7s ease-in-out infinite; pointer-events: none; }
@keyframes shine { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Level / XP */
.level-badge { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .75rem; border-radius: 999px; background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); color: var(--red-900); font-weight: 900; font-size: .85rem; box-shadow: 0 4px 14px rgba(212, 175, 55, .4); }
.xp-bar { height: 12px; border-radius: 999px; background: rgba(255, 255, 255, .18); overflow: hidden; margin-top: .6rem; }
.card .xp-bar { background: var(--bg-soft); }
.xp-bar.big { height: 16px; }
.xp-bar.thin { height: 6px; margin: .2rem 0 0; }
.xp-bar > span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold-400), var(--gold-600)); box-shadow: 0 0 12px rgba(230, 198, 92, .6); transition: width 1s cubic-bezier(.2, .8, .2, 1); }

/* Stats */
.stat { display: flex; align-items: center; gap: 1rem; }
.stat .icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.stat .icon.gold { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-strong); }
.stat .icon svg { width: 26px; height: 26px; }
.stat .value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat .label { color: var(--text-soft); font-size: .85rem; font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.2rem; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 800; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--primary-contrast);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; }
.btn.gold { background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); color: var(--red-900); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--accent); box-shadow: none; }
.btn.ghost.on-dark { color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.google { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.google:hover { border-color: #4285f4; box-shadow: 0 6px 16px rgba(66, 133, 244, .2); }
.btn.sm { padding: .45rem .8rem; font-size: .85rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; min-width: 0; }
.field label, .label { font-weight: 800; font-size: .9rem; }
.input, .field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="url"],
.field input[type="number"], .field input[type="date"], .field input[type="time"], .field input[type="file"],
.field select, .field textarea, .toolbar select {
  width: 100%; padding: .7rem .85rem; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; transition: border-color .2s ease, box-shadow .2s ease;
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.field .hint { font-size: .8rem; color: var(--text-soft); }
.field .row select { width: auto; flex: 1; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 700; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.input-prefix { display: flex; align-items: stretch; min-width: 0; }
.input-prefix span { display: grid; place-items: center; padding: 0 .75rem; border: 1px solid var(--border); border-right: 0; border-radius: 12px 0 0 12px; background: var(--bg-soft); font-weight: 800; color: var(--text-soft); white-space: nowrap; font-size: .85rem; }
.input-prefix input { border-radius: 0 12px 12px 0 !important; min-width: 0; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.25rem; align-items: start; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1.25rem; }
.toolbar select { width: auto; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; display: flex; align-items: center; }
.search svg.icon { position: absolute; left: .85rem; color: var(--text-soft); }
.search input { width: 100%; padding: .65rem .9rem .65rem 2.4rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.copy-row { display: flex; gap: .5rem; align-items: center; }
.copy-row .input { font-size: .8rem; }

/* Alerts */
.alert { padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 700; border: 1px solid; }
.alert.error { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.alert.success { background: color-mix(in srgb, var(--success) 10%, transparent); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.alert.info { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); }
.alert.credentials code { font-size: 1.05rem; color: var(--text); }
.alert.credentials p + p { margin-top: .35rem; }

/* Badges & tags */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 800; background: var(--bg-soft); color: var(--text-soft); border: 1px solid var(--border); white-space: nowrap; }
.badge svg.icon { width: 13px; height: 13px; }
.badge.red { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); border-color: transparent; }
.badge.gold { background: color-mix(in srgb, var(--accent) 24%, transparent); color: var(--accent-strong); border-color: transparent; }
.badge.green { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); border-color: transparent; }

/* Lessons */
.lesson-card { overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.lesson-card .thumb { position: relative; aspect-ratio: 16 / 9; background: radial-gradient(400px 200px at 80% 0%, rgba(212, 175, 55, .35), transparent 60%), linear-gradient(135deg, var(--red-700), var(--red-900)); display: grid; place-items: center; overflow: hidden; }
.lesson-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.lesson-card .thumb img.placeholder { width: 72px; height: 72px; object-fit: contain; opacity: .9; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35)); }
.lesson-card .thumb .play { position: absolute; width: 58px; height: 58px; border-radius: 50%; background: rgba(255, 255, 255, .92); display: grid; place-items: center; color: var(--red-700); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); transition: transform .2s ease; opacity: 0; }
.lesson-card:hover .thumb .play, .lesson-card:focus-within .thumb .play { opacity: 1; transform: scale(1.08); }
.lesson-card .thumb .play svg { width: 26px; height: 26px; margin-left: 3px; fill: currentColor; }
.lesson-card .thumb .done { position: absolute; top: .6rem; right: .6rem; background: var(--success); color: #fff; }
.lesson-card .body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.lesson-card .body h3 { margin: 0; font-size: 1.05rem; }
.lesson-card .body p { margin: 0; }
.lesson-card .meta, .material-card .meta { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: auto; padding-top: .4rem; }
.lesson-card a.cover { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.lesson-card a.cover:focus-visible { box-shadow: inset var(--ring); }
.lesson-card.preview { border-radius: var(--radius); }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.lesson-title { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
.player { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow-lg); }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player .empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .5rem; color: #fff; text-align: center; padding: 1rem; background: radial-gradient(600px 300px at 80% 0%, rgba(212, 175, 55, .3), transparent 60%), linear-gradient(135deg, var(--red-800), #1a0505); }
.player .empty svg { width: 48px; height: 48px; color: var(--gold-400); }
.reward .reward-xp { display: flex; align-items: center; gap: .5rem; font-family: var(--font-display); font-size: 1.3rem; color: var(--accent-strong); margin-bottom: .8rem; }
.reward .alert { margin: 0; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.filters .chip-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.continue { display: flex; gap: 1rem; align-items: flex-start; }
.continue-thumb { flex: none; width: 150px; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: linear-gradient(135deg, var(--red-700), var(--red-900)); }
.continue-thumb img { width: 100%; height: 100%; object-fit: cover; }
.continue-thumb img.placeholder { width: 44px; height: 44px; }
.continue h3 { margin: .1rem 0 .4rem; }

/* Materials */
.material-card { display: flex; gap: 1rem; align-items: flex-start; }
.material-card h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.material-card p { margin: 0; }
.material-card .related { display: inline-flex; align-items: center; gap: .3rem; margin-top: .5rem; font-weight: 700; }
.material-card > .btn { flex: none; align-self: center; }

/* Lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .85rem; padding: .7rem 0; border-bottom: 1px dashed var(--border); }
.list li:last-child { border-bottom: 0; }
.list .title { font-weight: 800; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.list a.title:hover { color: var(--primary); }
.list .muted.small { display: block; }
.list .title.wrap { white-space: normal; }
.list .grow .badge { margin-top: .3rem; }
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow); }
table.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: .75rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.table .actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: nowrap; }
.table .person { display: flex; align-items: center; gap: .6rem; color: var(--text); }
.file-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); flex: none; }
.file-icon svg { width: 22px; height: 22px; }
.file-icon.big { width: 56px; height: 56px; border-radius: 16px; }
.file-icon.big svg { width: 28px; height: 28px; }
.mini-avatar { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; flex: none; display: block; box-shadow: 0 0 0 2px var(--border); }
.mini-avatar svg { width: 100%; height: 100%; display: block; }
.rank { width: 2rem; font-family: var(--font-display); font-weight: 800; color: var(--accent-strong); }
.date-chip { flex: none; width: 48px; border-radius: 12px; padding: .3rem 0; text-align: center; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); line-height: 1.1; }
.date-chip.personal { background: color-mix(in srgb, var(--accent) 24%, transparent); color: var(--accent-strong); }
.date-chip strong { display: block; font-family: var(--font-display); font-size: 1.2rem; }
.date-chip small { font-size: .7rem; font-weight: 800; text-transform: uppercase; }

/* Activity chart */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: .6rem; align-items: end; height: 160px; padding-top: .5rem; }
.bars .bar { display: flex; flex-direction: column; align-items: center; gap: .35rem; height: 100%; justify-content: flex-end; }
.bars .bar span.fill { width: 100%; max-width: 34px; height: 3%; border-radius: 10px 10px 4px 4px; background: linear-gradient(180deg, var(--accent), var(--primary)); min-height: 4px; transition: height .8s cubic-bezier(.2, .8, .2, 1); }
.bars .bar.today span.fill { box-shadow: 0 0 14px rgba(212, 175, 55, .7); }
.bars .bar small { font-size: .72rem; color: var(--text-soft); font-weight: 800; }
.bars .bar.today small { color: var(--accent-strong); }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cal-title { margin: 0 .25rem; font-size: clamp(1.3rem, 2.4vw, 1.7rem); min-width: 10ch; text-align: center; }
.cal-scroll { overflow-x: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; min-width: 320px; }
.cal-dow { text-align: center; font-size: .74rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--text-soft); padding: .3rem 0; }
.cal-day { min-height: 108px; padding: .4rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-day.out { opacity: .45; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day .num { font-weight: 900; font-size: .85rem; }
.cal-day.today .num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--red-900); }
.cal-ev { display: block; font-size: .72rem; font-weight: 800; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; background: var(--red-700); }
.cal-ev.personal { background: var(--gold-500); color: var(--red-900); }
.cal-ev:hover { text-decoration: none; filter: brightness(1.1); }
.cal-more { font-size: .7rem; font-weight: 800; color: var(--text-soft); padding-left: 4px; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; font-weight: 700; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: .4rem; vertical-align: -1px; background: var(--red-700); }
.legend span.personal::before { background: var(--gold-500); }
.integration + .integration { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px dashed var(--border); }
.integration h3 { display: flex; align-items: center; gap: .4rem; }
.event-detail h1 { margin-top: .75rem; }
.event-when { display: flex; align-items: center; gap: .35rem; font-weight: 700; margin-bottom: .4rem; }
.event-form [hidden] { display: none; }

/* Avatar builder */
.avatar-builder { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 1.5rem; align-items: start; }
.avatar-stage { position: sticky; top: 90px; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.avatar-stage .stage { width: 100%; aspect-ratio: 1; border-radius: 32px; overflow: hidden; box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 45%, transparent), var(--shadow-lg); animation: float-soft 6s ease-in-out infinite; }
.avatar-stage .stage svg { width: 100%; height: 100%; display: block; }
@keyframes float-soft { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.opt-group { border: 0; margin: 0 0 1.25rem; padding: 0; min-width: 0; }
.opt-group legend { padding: 0; }
.opt-group h3 { font-size: .95rem; margin-bottom: .6rem; }
.opts { display: flex; flex-wrap: wrap; gap: .5rem; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt label { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border-radius: 12px; border: 2px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 800; font-size: .85rem; transition: border-color .15s ease, transform .15s ease; }
.opt label:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.opt input:checked + label { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); box-shadow: 0 4px 12px rgba(212, 175, 55, .3); }
.opt input:focus-visible + label { box-shadow: var(--ring); }
.opt.locked label { opacity: .5; cursor: not-allowed; transform: none; }
.opt.locked label svg.icon { width: 14px; height: 14px; }
.swatch label { position: relative; width: 40px; height: 40px; padding: 0; border-radius: 50%; justify-content: center; }
.swatch label svg:not(.icon) { width: 28px; height: 28px; display: block; }
.swatch.locked label svg.icon { position: absolute; right: -4px; bottom: -4px; background: var(--surface); border-radius: 50%; padding: 1px; }

/* Profile */
.profile-edit { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.profile-preview .preview-avatar { width: 170px; height: 170px; margin: 0 auto 1rem; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 45%, transparent), var(--shadow); }
.profile-preview .preview-avatar svg { width: 100%; height: 100%; display: block; }
.profile-preview h2 { margin-bottom: .1rem; }
.profile-card { padding: 0; overflow: hidden; }
.profile-cover { height: 170px; background: radial-gradient(600px 170px at 85% 0%, rgba(230, 198, 92, .55), transparent 60%), linear-gradient(135deg, var(--red-700), var(--red-900)); }
.profile-head { display: flex; gap: 1.25rem; align-items: flex-end; margin-top: -75px; padding: 0 1.5rem; flex-wrap: wrap; }
.big-avatar { display: block; width: 150px; height: 150px; border-radius: 50%; border: 5px solid var(--surface); box-shadow: var(--shadow-lg); overflow: hidden; flex: none; }
.big-avatar svg { width: 100%; height: 100%; display: block; }
.big-avatar.small { width: 96px; height: 96px; border-width: 3px; }
.profile-head .info { padding-bottom: .5rem; }
.profile-head .info h1 { margin-bottom: 0; }
.profile-head .handle { color: var(--text-soft); font-weight: 800; }
.profile-body { padding: 1.25rem 1.5rem 1.75rem; }
.profile-body .bio { font-size: 1.05rem; }
.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; }
.achievement { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1rem .5rem; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border)); background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface)); text-align: center; font-weight: 800; font-size: .85rem; }
.achievement .medal { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); color: var(--red-900); box-shadow: 0 6px 16px rgba(212, 175, 55, .45); }
.achievement .medal svg { width: 26px; height: 26px; }
.achievement.locked { filter: grayscale(1); opacity: .5; }
.student-head { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.student-head h1 { margin-bottom: .1rem; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* Auth / public pages */
.auth-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  position: relative; overflow: hidden;
  background: radial-gradient(900px 400px at 100% 0%, rgba(212, 175, 55, .35), transparent 60%), linear-gradient(150deg, var(--red-700), var(--red-900));
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
}
.auth-art .logo { width: 260px; height: auto; }
.auth-art h1 { font-size: clamp(2rem, 4vw, 3rem); color: #fff; max-width: 14ch; }
.auth-art p { color: #f6e7d7; max-width: 42ch; font-size: 1.05rem; }
.auth-art .floating { position: absolute; right: -60px; bottom: -60px; width: 360px; height: auto; opacity: .14; transform: rotate(-12deg); animation: float 9s ease-in-out infinite; pointer-events: none; }
@keyframes float { 0%, 100% { transform: rotate(-12deg) translateY(0); } 50% { transform: rotate(-8deg) translateY(-18px); } }
.auth-art .pills { display: flex; gap: .5rem; flex-wrap: wrap; }
.auth-art .pills span { padding: .4rem .8rem; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(230, 198, 92, .35); font-weight: 700; font-size: .85rem; }
.motto { position: relative; margin: 0; padding-left: 1rem; border-left: 3px solid var(--gold-400); max-width: 34ch; }
.motto p { font-family: var(--font-display); font-size: 1.35rem; font-style: italic; color: #fff; margin: 0 0 .25rem; }
.motto cite { font-style: normal; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-200); }
.auth-form { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 2rem; }
.auth-form .box { width: 100%; max-width: 420px; }
.auth-form .top { display: flex; justify-content: flex-end; width: 100%; max-width: 420px; margin-bottom: 2rem; }
.auth-form .mobile-logo { display: none; width: 200px; height: auto; margin: 0 auto 1.5rem; }
.contact-note { margin-top: 1.5rem; padding: 1rem 1.1rem; border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); font-size: .92rem; }
.contact-note strong { color: var(--primary); }
.error-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 2rem; gap: .5rem; }
.error-wrap h1 { font-size: 4rem; margin: 0; color: var(--primary); }
.error-logo { width: 110px; height: auto; filter: drop-shadow(0 10px 24px rgba(138, 14, 14, .35)); }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--text-soft); }
.empty-state svg.icon { width: 56px; height: 56px; margin: 0 auto 1rem; display: block; color: var(--accent); }

/* Admin */
details.inline-form > summary { cursor: pointer; list-style: none; }
details.inline-form > summary::-webkit-details-marker { display: none; }
details.inline-form > summary h2 { display: inline-flex; align-items: center; margin: 0; }
details.card.inline-form[open] > summary { margin-bottom: 1rem; }
details.inline-form > summary.btn { display: inline-flex; }
.nexus-card h2 { display: flex; align-items: center; }

/* Celebration */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(140%); z-index: 50; padding: .9rem 1.3rem; border-radius: 16px; background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); color: var(--red-900); font-weight: 900; box-shadow: var(--shadow-lg); transition: transform .45s cubic-bezier(.2, .9, .3, 1.3); }
.toast.show { transform: translateX(-50%) translateY(0); }
.confetti { position: fixed; top: -12px; z-index: 60; width: 10px; height: 14px; border-radius: 3px; pointer-events: none; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }

/* Responsive */
@media (max-width: 1100px) {
  .lesson-layout { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .3s ease; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; }
  .chip-btn.menu-toggle { display: inline-flex; }
  .content { padding: 1.1rem; }
  .topbar { padding: .7rem 1.1rem; }
  .hero .hero-grid, .hero.compact .hero-grid { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .hero .row { justify-content: center; }
  .avatar-builder, .profile-edit, .form-layout { grid-template-columns: 1fr; }
  .avatar-stage { position: static; }
  .avatar-stage .stage { max-width: 280px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-form .mobile-logo.logo-on-light { display: block; }
  [data-theme="dark"] .auth-form .mobile-logo.logo-on-light { display: none; }
  [data-theme="dark"] .auth-form .mobile-logo.logo-on-dark { display: block; }
  .cal-day { min-height: 78px; }
  .cal-ev { font-size: .62rem; padding: 1px 4px; }
}
@media (max-width: 560px) {
  .topbar .toggles .label-text { display: none; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .grid-4 .stat { flex-direction: column; align-items: flex-start; gap: .6rem; padding: 1rem; }
  .grid-4 .stat .icon { width: 42px; height: 42px; border-radius: 12px; }
  .grid-4 .stat .value { font-size: 1.4rem; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 60px; padding: .25rem; }
  .continue { flex-direction: column; }
  .continue-thumb { width: 100%; }
  .material-card { flex-wrap: wrap; }
  .material-card > .btn { width: 100%; }
  .profile-head { justify-content: center; text-align: center; }
  .profile-head .row { justify-content: center; }
}
