/* Tech Brains AI Quiz Platform — design system
   Palette lifted from the logo ring: navy → violet → flame. */
:root {
  --ink: #16204A;
  --ink-2: #2B3570;
  --violet: #5B3DB5;
  --flame: #F26A1B;
  --flame-deep: #D9550A;
  --amber: #FFB020;
  --paper: #F4F6FB;
  --surface: #FFFFFF;
  --line: #E1E5F0;
  --muted: #5E6688;
  --soft: #EEF0F8;
  --good: #128A5A;
  --good-bg: #E3F6EE;
  --bad: #C2362B;
  --bad-bg: #FDECEA;
  --warn: #9A5B00;
  --warn-bg: #FFF4DC;
  --synapse: linear-gradient(100deg, #16204A 0%, #5B3DB5 52%, #F26A1B 100%);
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --shadow: 0 1px 2px rgba(22, 32, 74, .06), 0 8px 24px -12px rgba(22, 32, 74, .18);
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-w: 236px;
  --top-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--violet); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--flame-deep); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 1em; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--flame); outline-offset: 2px; border-radius: 4px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.synapse-band { height: 3px; background: var(--synapse); position: sticky; top: 0; z-index: 60; }

/* ---------- Top bar & shell ---------- */
.topbar {
  position: sticky; top: 3px; z-index: 50;
  height: var(--top-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.brand img { width: 36px; height: 36px; border-radius: 50%; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.role-tag { font-size: .8rem; color: var(--muted); display: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: #fff; text-decoration: none;
  font-family: var(--font-display); font-size: .8rem; font-weight: 600;
}
.avatar:hover { color: #fff; background: var(--violet); }
.logout-link { font-size: .85rem; color: var(--muted); text-decoration: none; display: none; }
.icon-btn { background: none; border: 0; padding: 8px; margin-left: -8px; color: var(--ink); cursor: pointer; border-radius: var(--r-sm); }
.icon-btn svg { width: 24px; height: 24px; }

.shell { display: flex; min-height: calc(100vh - var(--top-h) - 3px); }
.content { flex: 1; min-width: 0; padding: 20px 16px 96px; max-width: 1180px; margin: 0 auto; width: 100%; }
main.bare { min-height: calc(100vh - 3px); }

.sidenav {
  position: fixed; inset: calc(var(--top-h) + 3px) auto 0 0; z-index: 45;
  width: var(--nav-w); padding: 16px 12px;
  background: var(--ink); color: #C9CEE6;
  display: flex; flex-direction: column; gap: 2px;
  transform: translateX(-100%); transition: transform .22s ease;
  overflow-y: auto;
}
.sidenav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: inherit; text-decoration: none; font-weight: 500; font-size: .95rem;
}
.sidenav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidenav a.is-active { background: rgba(242, 106, 27, .16); color: #fff; box-shadow: inset 3px 0 0 var(--flame); }
.sidenav .sidenav-logout { margin-top: auto; opacity: .75; }
.nav-open .sidenav { transform: none; }
.nav-scrim { position: fixed; inset: 0; background: rgba(22, 32, 74, .4); z-index: 40; display: none; }
.nav-open .nav-scrim { display: block; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px; text-decoration: none; color: var(--muted); font-size: .74rem; font-weight: 500;
}
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.is-active { color: var(--flame-deep); }

@media (min-width: 720px) {
  .role-tag, .logout-link { display: inline; }
  .content { padding: 28px 28px 48px; }
}
@media (min-width: 1000px) {
  .nav-toggle { display: none; }
  .sidenav { transform: none; }
  .role-admin .shell, .role-super_admin .shell, .role-manager .shell { padding-left: var(--nav-w); }
  .nav-scrim { display: none !important; }
}
@media (min-width: 720px) {
  .role-student .bottomnav {
    position: static; border: 0; background: none; padding: 0;
    justify-content: flex-start; gap: 4px; max-width: 1180px; margin: 0 auto;
  }
  .role-student .bottomnav { position: fixed; top: 3px; left: 50%; transform: translateX(-50%); bottom: auto; width: auto; height: var(--top-h); align-items: center; z-index: 55; }
  .role-student .bottomnav a { flex-direction: row; font-size: .92rem; padding: 8px 12px; border-radius: var(--r-sm); gap: 8px; }
  .role-student .bottomnav a svg { width: 18px; height: 18px; }
  .role-student .bottomnav a.is-active { background: var(--soft); }
  .role-student .content { padding-bottom: 48px; }
}

/* ---------- Flash ---------- */
.flash {
  display: flex; align-items: flex-start; gap: 12px; justify-content: space-between;
  padding: 12px 14px; border-radius: var(--r-sm); margin: 0 0 16px;
  font-weight: 500; border: 1px solid transparent;
}
.flash button { background: none; border: 0; font-size: 1.2rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.flash-success { background: var(--good-bg); color: var(--good); border-color: #BDE8D5; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: #F6C9C4; }
.flash-info { background: var(--soft); color: var(--ink-2); border-color: var(--line); }
.flash-warn { background: var(--warn-bg); color: var(--warn); border-color: #F5DFA8; }
.bare .flash { max-width: 440px; margin: 16px auto 0; }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; margin-bottom: 18px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
}

/* Stat strip: one bordered strip, not floating cards */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 18px; overflow: hidden; }
.stat { padding: 16px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat:nth-child(2n) { border-right: 0; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(var(--cols, 4), 1fr); }
  .stat { border-bottom: 0; }
  .stat:nth-child(2n) { border-right: 1px solid var(--line); }
  .stat:last-child { border-right: 0; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px;
  font: 600 .95rem/1.2 var(--font-body);
  border-radius: 999px; border: 1.5px solid var(--ink);
  background: var(--ink); color: #fff; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.btn svg { width: 18px; height: 18px; }
.btn-flame { background: var(--flame); border-color: var(--flame); }
.btn-flame:hover { background: var(--flame-deep); border-color: var(--flame-deep); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--soft); color: var(--ink); border-color: #C8CDE0; }
.btn-danger { background: #fff; color: var(--bad); border-color: #F0C2BD; }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn-sm { min-height: 34px; padding: 6px 13px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { background: none; border: 0; padding: 0; color: var(--violet); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=url], input[type=datetime-local], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: 400 1rem/1.4 var(--font-body); color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(91, 61, 181, .15); }
input[type=file] { width: 100%; font: inherit; padding: 10px; border: 1.5px dashed #C8CDE0; border-radius: var(--r-sm); background: var(--soft); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--flame); }
.form-row { display: grid; gap: 0 14px; }
@media (min-width: 600px) { .form-row { grid-template-columns: 1fr 1fr; } .form-row-3 { grid-template-columns: 1fr 1fr 1fr; } }
.inline-form { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 160px; flex: 1 1 160px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 10px 10px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
table.data td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.is-qualified td { background: #FFF7EF; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: .82rem; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 640px) {
  table.data.stack thead { display: none; }
  table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
  table.data.stack tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.data.stack td { border: 0; padding: 3px 0; }
  table.data.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  table.data.stack .num { text-align: left; }
}

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill-live { background: var(--good-bg); color: var(--good); }
.pill-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-done { background: var(--soft); color: var(--ink-2); }
.pill-muted { background: var(--soft); color: var(--muted); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-flame { background: #FFEBDD; color: var(--flame-deep); }
.qualified-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--synapse); color: #fff; font-weight: 600; font-size: .8rem; }
.rank { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 999px; background: var(--soft); font-family: var(--font-display); font-weight: 700; font-size: .85rem; }
.rank-1 { background: #FFD66B; } .rank-2 { background: #E3E6EF; } .rank-3 { background: #F6C9A2; }

/* ---------- Auth pages ---------- */
.auth { min-height: calc(100vh - 3px); display: grid; }
@media (min-width: 900px) { .auth { grid-template-columns: 1.05fr 1fr; } }
.auth-side {
  display: none; position: relative; overflow: hidden;
  background: var(--ink); color: #fff; padding: 48px;
}
@media (min-width: 900px) { .auth-side { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-side::after {
  content: ""; position: absolute; width: 640px; height: 640px; right: -260px; bottom: -260px;
  border-radius: 50%; border: 56px solid transparent;
  background: var(--synapse) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; opacity: .55;
}
.auth-side h1 { font-size: clamp(2rem, 1.2rem + 2.2vw, 3.1rem); font-weight: 800; max-width: 12ch; letter-spacing: -.025em; color: #fff; }
.auth-side p { color: #BFC5E3; max-width: 40ch; font-size: 1.05rem; }
.auth-side .brand { color: #fff; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: 12px; align-items: center; color: #DDE1F2; }
.auth-points li svg { color: var(--amber); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 28px 18px 40px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .logo-lg { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 14px; }
.auth-card h2 { text-align: center; font-size: 1.5rem; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); }
.college-lock { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r-sm); background: var(--soft); font-weight: 600; margin-bottom: 14px; }

/* ---------- Landing ---------- */
.landing-hero { padding: 40px 18px 24px; max-width: 1100px; margin: 0 auto; display: grid; gap: 28px; align-items: center; }
@media (min-width: 860px) { .landing-hero { grid-template-columns: 1.2fr 1fr; padding-top: 72px; } }
.landing-hero h1 { font-size: clamp(2.1rem, 1.3rem + 3vw, 3.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.landing-hero .lede { font-size: 1.15rem; color: var(--muted); max-width: 46ch; }
.landing-hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.landing-art { position: relative; justify-self: center; width: min(340px, 80vw); aspect-ratio: 1; }
.landing-art img { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 30px 60px -30px rgba(22, 32, 74, .45); }
.journey { max-width: 1100px; margin: 0 auto; padding: 24px 18px 64px; }
.journey ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; counter-reset: step; border-top: 1px solid var(--line); }
@media (min-width: 760px) { .journey ol { grid-template-columns: repeat(4, 1fr); } }
.journey li { padding: 20px 18px 20px 0; border-bottom: 1px solid var(--line); counter-increment: step; }
@media (min-width: 760px) { .journey li { border-bottom: 0; border-right: 1px solid var(--line); padding: 22px 20px; } .journey li:last-child { border-right: 0; } }
.journey li::before { content: counter(step); display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: .85rem; margin-bottom: 10px; }
.journey li:last-child::before { background: var(--flame); }
.journey h3 { margin-bottom: 4px; }
.journey p { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- Student home ---------- */
.welcome { position: relative; overflow: hidden; border-radius: var(--r-lg); background: var(--ink); color: #fff; padding: 22px 20px; margin-bottom: 20px; }
.welcome::after { content: ""; position: absolute; inset: auto -40px -80px auto; width: 220px; height: 220px; border-radius: 50%; border: 28px solid; border-color: var(--flame) var(--violet) var(--violet) var(--flame); opacity: .45; }
.welcome h1 { color: #fff; margin-bottom: 4px; position: relative; z-index: 1; }
.welcome p { color: #C5CBE6; margin: 0; position: relative; z-index: 1; }
.quiz-card { display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; }
.quiz-card.is-live { border-color: #F7C2A2; box-shadow: inset 4px 0 0 var(--flame); }
.quiz-card h3 { margin: 0; font-size: 1.1rem; }
.quiz-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .88rem; }
.quiz-meta span { display: inline-flex; align-items: center; gap: 5px; }
.quiz-meta svg { width: 16px; height: 16px; }
.quiz-card .btn { align-self: flex-start; }
.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-clean > li:last-child { border-bottom: 0; }

/* ---------- Rules screen ---------- */
.rules { counter-reset: r; list-style: none; padding: 0; margin: 0 0 18px; }
.rules li { position: relative; padding: 10px 0 10px 40px; border-bottom: 1px solid var(--line); }
.rules li::before { counter-increment: r; content: counter(r); position: absolute; left: 0; top: 9px; width: 26px; height: 26px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }

/* ---------- Quiz taking ---------- */
.quiz-page { background: #fff; }
.quiz-page .bottomnav { display: none; }
.quiz-top {
  position: sticky; top: 3px; z-index: 30; background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.quiz-top .q-title { font-family: var(--font-display); font-weight: 600; font-size: .95rem; line-height: 1.25; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-top .q-progress { color: var(--muted); font-size: .8rem; }
.timer { margin-left: auto; position: relative; width: 58px; height: 58px; flex: none; }
.timer svg { width: 58px; height: 58px; transform: rotate(-90deg); }
.timer .t-track { stroke: var(--soft); stroke-width: 6; fill: none; }
.timer .t-bar { stroke-width: 6; fill: none; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer .t-text { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: .82rem; font-variant-numeric: tabular-nums; }
.timer.is-low .t-text { color: var(--bad); }
.timer.is-low { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.quiz-body { max-width: 760px; margin: 0 auto; padding: 18px 16px 150px; }
.q-card { display: none; }
.q-card.is-current { display: block; }
.q-num { font-family: var(--font-display); font-weight: 700; color: var(--flame-deep); font-size: .9rem; margin-bottom: 6px; }
.q-text { font-size: 1.15rem; font-weight: 600; line-height: 1.45; margin-bottom: 18px; white-space: pre-line; }
.opts { display: grid; gap: 10px; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt label {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; min-height: 54px;
  border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: pointer; background: #fff;
  transition: border-color .12s, background .12s;
}
.opt label:hover { border-color: #C3C9E0; }
.opt .key { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-weight: 700; font-size: .85rem; font-family: var(--font-display); }
.opt input:checked + label { border-color: var(--violet); background: #F3F0FC; }
.opt input:checked + label .key { background: var(--violet); color: #fff; }
.opt input:focus-visible + label { outline: 3px solid var(--flame); outline-offset: 2px; }
.quiz-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.quiz-foot-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.quiz-foot .grow { flex: 1; }
.palette-toggle { font-size: .85rem; }
.palette { display: none; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 8px; max-width: 760px; margin: 0 auto 10px; }
.palette.is-open { display: grid; }
.palette button { height: 40px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: #fff; font-weight: 700; font-family: var(--font-display); cursor: pointer; color: var(--ink); }
.palette button.answered { background: var(--ink); border-color: var(--ink); color: #fff; }
.palette button.current { border-color: var(--flame); box-shadow: 0 0 0 2px var(--flame); }
.save-state { font-size: .78rem; color: var(--muted); }
.no-select { -webkit-user-select: none; user-select: none; }
.warn-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(22, 32, 74, .7); display: none; align-items: center; justify-content: center; padding: 20px; }
.warn-overlay.is-open { display: flex; }
.warn-box { background: #fff; border-radius: var(--r-lg); padding: 24px; max-width: 400px; text-align: center; }
.warn-box h2 { color: var(--bad); }

/* ---------- Result ---------- */
.ring { position: relative; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--soft); stroke-width: 10; }
.ring-bar { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-text strong { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; line-height: 1; }
.ring-text small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.ring-text span { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.result-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.result-hero .facts { display: grid; grid-template-columns: repeat(2, auto); gap: 6px 22px; }
.result-hero .facts dt { color: var(--muted); font-size: .82rem; }
.result-hero .facts dd { margin: 0 0 4px; font-weight: 700; font-family: var(--font-display); }
.review { list-style: none; padding: 0; margin: 0; }
.review > li { padding: 16px 0; border-bottom: 1px solid var(--line); }
.review > li:last-child { border-bottom: 0; }
.review .rq { font-weight: 600; margin-bottom: 10px; white-space: pre-line; }
.review .ropts { display: grid; gap: 6px; margin-bottom: 10px; }
.review .ropt { padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); font-size: .93rem; display: flex; gap: 8px; }
.review .ropt.correct { border-color: #9ED9BF; background: var(--good-bg); }
.review .ropt.wrong { border-color: #F2B5AE; background: var(--bad-bg); }
.review .ropt b { flex: none; }
.review .tag { margin-left: auto; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.explain { background: var(--soft); border-radius: var(--r-sm); padding: 10px 12px; font-size: .92rem; }
.explain strong { color: var(--violet); }
.ai-feedback { border-left: 3px solid var(--violet); padding: 4px 0 4px 14px; white-space: pre-line; }

/* ---------- Admin question editor ---------- */
.qedit { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; margin-bottom: 12px; background: #fff; }
.qedit.is-approved { border-color: #A9DCC4; box-shadow: inset 4px 0 0 var(--good); }
.qedit-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.qedit-head .n { font-family: var(--font-display); font-weight: 700; }
.qedit .opt-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.qedit .opt-row input[type=radio] { width: 20px; height: 20px; accent-color: var(--good); }
.ai-panel { background: var(--ink); color: #fff; border: 0; }
.ai-panel label { color: #E3E6F5; }
.ai-panel .hint, .ai-panel p { color: #B9C0E0; }
.ai-panel h2 { color: #fff; }
.progress-bar { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--synapse); }

/* ---------- AI tools ---------- */
.tools-grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .tools-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .tools-grid { grid-template-columns: repeat(3, 1fr); } }
.tool { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.tool-top { display: flex; gap: 12px; align-items: center; }
.tool-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.5rem; background: var(--soft); flex: none; }
.tool h3 { margin: 0; }
.tool .price { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.tool .price small { font-family: var(--font-body); font-weight: 500; color: var(--muted); font-size: .8rem; }
.tool .desc { color: var(--muted); font-size: .93rem; flex: 1; }
.tool-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; font-size: .88rem; font-weight: 500; }
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Charts & misc ---------- */
.chart-box { position: relative; height: 300px; }
.bar-list { display: grid; gap: 10px; }
.bar-item .bar-label { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 4px; }
.empty { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty h3 { color: var(--ink); }
.qr-box { display: grid; place-items: center; padding: 10px; background: #fff; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-size: .85rem; }
dialog { border: 0; border-radius: var(--r-lg); padding: 22px; max-width: min(520px, 92vw); width: 100%; box-shadow: 0 30px 80px -20px rgba(22, 32, 74, .5); }
dialog::backdrop { background: rgba(22, 32, 74, .5); }
.kbd-note { font-size: .82rem; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .topbar, .sidenav, .bottomnav, .synapse-band, .page-actions, .no-print { display: none !important; }
  .role-admin .shell, .role-super_admin .shell, .role-manager .shell { padding-left: 0; }
  body { background: #fff; }
}
