/* ============================================================================
 * Quiz JCB — design system
 * Brand primary #6d071a (burgundy), accent bronze. Inter + Material Symbols.
 * Light / dark themes through [data-theme] on <html> (see theme-init.js).
 * No inline styles anywhere: the CSP forbids them.
 * ========================================================================== */

/* ---------- Tokens ---------- */
:root, :root[data-theme="light"] {
  --primary: #6d071a;
  --primary-hover: #880921;
  --primary-soft: #fbeef0;
  --primary-ink: #ffffff;
  --primary-grad: linear-gradient(135deg, #3d0410 0%, #6d071a 50%, #a3142f 100%);
  --accent: #9a8350;
  --accent-soft: #f5f0e3;

  --bg-body: #f7f4f4;
  --bg-card: #ffffff;
  --bg-elev: #faf8f8;
  --bg-header: #2c0408;
  --bg-row-hover: #fbf3f4;

  --text: #1c1214;
  --text-secondary: #4f4346;
  --text-muted: #85777a;
  --text-on-dark: #f8eff1;

  --border: #ece4e5;
  --border-strong: #d6c9cb;

  --shadow-xs: 0 1px 2px rgba(44, 4, 8, .05);
  --shadow-sm: 0 1px 2px rgba(44, 4, 8, .04), 0 1px 3px rgba(44, 4, 8, .06);
  --shadow-md: 0 4px 14px rgba(44, 4, 8, .07), 0 2px 5px rgba(44, 4, 8, .04);
  --shadow-lg: 0 18px 40px rgba(44, 4, 8, .12), 0 6px 14px rgba(44, 4, 8, .06);
  --shadow-glow: 0 0 0 4px rgba(109, 7, 26, .14);

  --ok: #15803d;   --ok-bg: #ecfdf3;   --ok-border: #a7e3bd;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-border: #f5d58a;
  --err: #c81e3a;  --err-bg: #fef1f3;  --err-border: #f5b5c0;
  --info: #0e7490; --info-bg: #ecfbfe; --info-border: #a5e1ee;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --motion-fast: 150ms;
  --motion-base: 220ms;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --header-h: 68px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --primary: #f0768d;
  --primary-hover: #f597a9;
  --primary-soft: rgba(240, 118, 141, .15);
  --primary-ink: #1d0509;
  --primary-grad: linear-gradient(135deg, #3d0410 0%, #8a1027 55%, #d2405c 100%);
  --accent: #d4bd86;
  --accent-soft: rgba(212, 189, 134, .14);

  --bg-body: #110b0c;
  --bg-card: #1b1315;
  --bg-elev: #241a1d;
  --bg-header: #0b0607;
  --bg-row-hover: #261b1e;

  --text: #f6eff0;
  --text-secondary: #d9cdd0;
  --text-muted: #a8979b;
  --text-on-dark: #f6eff0;

  --border: #33262a;
  --border-strong: #4b3a3f;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .5), 0 2px 5px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, .6), 0 6px 14px rgba(0, 0, 0, .35);
  --shadow-glow: 0 0 0 4px rgba(240, 118, 141, .22);

  --ok: #6ee7a0;   --ok-bg: rgba(110, 231, 160, .12);  --ok-border: rgba(110, 231, 160, .35);
  --warn: #fcd34d; --warn-bg: rgba(252, 211, 77, .12); --warn-border: rgba(252, 211, 77, .35);
  --err: #fb7185;  --err-bg: rgba(251, 113, 133, .12); --err-border: rgba(251, 113, 133, .38);
  --info: #67e8f9; --info-bg: rgba(103, 232, 249, .1); --info-border: rgba(103, 232, 249, .3);
  color-scheme: dark;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--border-strong) transparent; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  background: var(--bg-body);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--motion-base) var(--ease), color var(--motion-base) var(--ease);
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

h1, h2, h3, h4 { letter-spacing: -.015em; line-height: 1.25; color: var(--text); }
h1 { font-size: clamp(1.5rem, 3vw, 1.9rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }

code, .mono { font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; }

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
  flex-shrink: 0;
}
.icon-sm { font-size: 16px !important; }
.icon-lg { font-size: 28px !important; }
.icon-fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Utilities ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container--narrow { max-width: 760px; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--center { justify-content: center; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.05rem;
  font-size: .9rem; font-weight: 600; line-height: 1.2;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-decoration: none !important;
  white-space: nowrap;
  transition: background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease),
              box-shadow var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .6; cursor: not-allowed; }
.btn .material-symbols-outlined { font-size: 19px; }

.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: var(--shadow-glow); }

.btn-secondary { background: var(--bg-card); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }

.btn-danger { background: var(--err); color: #fff; border-color: var(--err); }
:root[data-theme="dark"] .btn-danger { color: #1d0509; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 0 0 4px var(--err-bg); }

.btn-danger-ghost { color: var(--err); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--err-bg); }

.btn-sm { padding: .4rem .7rem; font-size: .82rem; }
.btn-lg { padding: .85rem 1.5rem; font-size: 1rem; border-radius: var(--radius-md); }
.btn-block { width: 100%; }
.btn-icon { padding: .45rem; aspect-ratio: 1; }
.btn-icon.btn-sm { padding: .3rem; }

.btn.is-loading::after {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}
.card--flush { padding: 0; overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.card-header h2, .card-header h3 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1.5rem; }
.card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: .75rem; flex-wrap: wrap;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: var(--bg-elev);
}

.section-title {
  display: flex; align-items: center; gap: .6rem;
  font-size: 1.05rem; font-weight: 700; margin-bottom: 1rem;
}
.section-title__icon {
  width: 32px; height: 32px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}

/* ---------- Chips & badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .65rem;
  border-radius: 999px;
  font-size: .76rem; font-weight: 600; line-height: 1.4;
  background: var(--bg-elev); color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip .material-symbols-outlined { font-size: 15px; }
.chip-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chip-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: transparent; }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip-err  { background: var(--err-bg);  color: var(--err);  border-color: transparent; }
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.code-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .25rem .2rem .7rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-weight: 600; font-size: .9rem; letter-spacing: .12em;
  color: var(--text);
}
.code-chip button {
  display: inline-flex; border: 0; background: transparent; color: var(--text-muted);
  padding: .2rem; border-radius: 6px;
}
.code-chip button:hover { background: var(--bg-card); color: var(--primary); }
.code-chip--lg { font-size: 1.25rem; padding: .35rem .35rem .35rem 1rem; }

/* ---------- Alerts / flash ---------- */
.alert {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: .9rem;
}
.alert .material-symbols-outlined { margin-top: 1px; }
.alert-success { background: var(--ok-bg);   border-color: var(--ok-border);   color: var(--ok); }
.alert-error   { background: var(--err-bg);  border-color: var(--err-border);  color: var(--err); }
.alert-warning { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.alert-info    { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }
.alert__body { flex: 1; color: var(--text); }
.alert__close { border: 0; background: transparent; color: inherit; opacity: .6; display: inline-flex; }
.alert__close:hover { opacity: 1; }
.flash-stack { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.25rem; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 2000;
  display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: .6rem;
  min-width: 240px; max-width: 420px;
  padding: .8rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-lg);
  font-size: .88rem; font-weight: 500;
  pointer-events: auto;
  animation: toast-in var(--motion-base) var(--ease-out);
}
.toast.is-leaving { animation: toast-out var(--motion-base) var(--ease) forwards; }
.toast-success { border-left-color: var(--ok); }
.toast-success .material-symbols-outlined { color: var(--ok); }
.toast-error { border-left-color: var(--err); }
.toast-error .material-symbols-outlined { color: var(--err); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(20px); opacity: 0; } }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 1.25rem; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field > label, .field-label { font-size: .84rem; font-weight: 600; color: var(--text-secondary); }
.field .optional { font-weight: 400; color: var(--text-muted); }

.input, .field input[type="text"], .field input[type="password"], .field input[type="number"],
.field select, .field textarea {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: .95rem;
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--shadow-glow);
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field select, select.input {
  appearance: none;
  padding-right: 2.3rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2385777a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
}
.hint { font-size: .8rem; color: var(--text-muted); }
.field-error { font-size: .8rem; color: var(--err); font-weight: 500; display: flex; align-items: center; gap: .3rem; }
.is-invalid, .field .is-invalid { border-color: var(--err) !important; }
.is-invalid:focus { box-shadow: 0 0 0 4px var(--err-bg) !important; }

.input-icon { position: relative; }
.input-icon > .material-symbols-outlined {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none;
}
.input-icon > input { padding-left: 2.6rem !important; }

/* Switch (checkbox) */
.switch {
  display: flex; align-items: flex-start; gap: .85rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-elev);
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease);
}
.switch:hover { border-color: var(--border-strong); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  position: relative; flex-shrink: 0;
  width: 40px; height: 24px; margin-top: 1px;
  border-radius: 999px; background: var(--border-strong);
  transition: background var(--motion-fast) var(--ease);
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--motion-base) var(--ease-out);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--shadow-glow); }
.switch__text { display: flex; flex-direction: column; gap: .1rem; }
.switch__title { font-weight: 600; font-size: .92rem; }
.switch__desc { font-size: .8rem; color: var(--text-muted); }

/* Segmented choice (radio pills) */
.segmented { display: flex; flex-wrap: wrap; gap: .4rem; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span {
  display: inline-flex; padding: .45rem .85rem;
  border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: var(--text-secondary);
  background: var(--bg-card); cursor: pointer;
  transition: all var(--motion-fast) var(--ease);
}
.segmented input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.segmented input:focus-visible + span { box-shadow: var(--shadow-glow); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: .75rem 1.25rem; background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.table td { padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--motion-fast) var(--ease); }
.table tbody tr:hover { background: var(--bg-row-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table-title { font-weight: 600; color: var(--text); }
.table-title:hover { color: var(--primary); }
.table-sub { font-size: .8rem; color: var(--text-muted); }

/* Search toolbar */
.toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.search {
  display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 220px; max-width: 420px;
  padding: 0 .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.search:focus-within { border-color: var(--primary); box-shadow: var(--shadow-glow); }
.search .material-symbols-outlined { color: var(--text-muted); }
.search input { flex: 1; border: 0; background: transparent; padding: .6rem 0; outline: none; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 3.5rem 1.5rem;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--bg-card); color: var(--text-muted);
}
.empty-state__icon {
  width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.empty-state__icon .material-symbols-outlined { font-size: 32px; }
.empty-state h3 { color: var(--text); margin-bottom: .35rem; }
.empty-state p { max-width: 420px; margin: 0 auto 1.25rem; }

/* ============================================================================
 * Admin shell
 * ========================================================================== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-header);
  color: var(--text-on-dark);
  box-shadow: 0 2px 16px rgba(0, 0, 0, .22);
}
.header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, #6d071a, #c2a46a, #6d071a);
  opacity: .85;
}
.header-inner {
  max-width: 1400px; margin: 0 auto; height: var(--header-h);
  padding: 0 1.5rem;
  display: flex; align-items: center; gap: 1.5rem;
}
.brand {
  display: flex; align-items: center; gap: .7rem; color: inherit;
  padding: .3rem .5rem; margin-left: -.5rem; border-radius: var(--radius-sm);
}
.brand:hover { text-decoration: none; background: rgba(255, 255, 255, .07); }
.brand__logo {
  width: 40px; height: 40px; border-radius: 10px; padding: 4px;
  background: #fff; object-fit: contain;
}
.brand__titles { display: flex; flex-direction: column; line-height: 1.15; }
.brand__title { font-weight: 800; font-size: 1rem; letter-spacing: -.01em; }
.brand__subtitle { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255, 255, 255, .55); font-weight: 600; }

.header-nav { display: flex; align-items: center; gap: .2rem; }
.header-nav a {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .85rem; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 500; color: rgba(255, 255, 255, .75);
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.header-nav a:hover { text-decoration: none; background: rgba(255, 255, 255, .08); color: #fff; }
.header-nav a.active { background: rgba(255, 255, 255, .14); color: #fff; }
.header-nav a .material-symbols-outlined { font-size: 19px; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.header-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  height: 38px; min-width: 38px; padding: 0 .6rem;
  border: 0; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .08); color: var(--text-on-dark);
  font-size: .85rem; font-weight: 500;
  transition: background var(--motion-fast) var(--ease);
}
.header-btn:hover { background: rgba(255, 255, 255, .16); text-decoration: none; color: #fff; }

/* Theme toggle icon swap */
[data-theme="light"] .theme-icon-dark, [data-theme="dark"] .theme-icon-light { display: none; }

/* User menu (native <details>, no JS needed) */
.user-menu { position: relative; }
.user-menu summary { list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-grad); color: #fff; font-weight: 700; font-size: .8rem;
  text-transform: uppercase; box-shadow: 0 0 0 2px rgba(255, 255, 255, .2);
}
.user-menu__panel {
  position: absolute; right: 0; top: calc(100% + .5rem);
  min-width: 230px; padding: .4rem;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: pop var(--motion-base) var(--ease-out);
}
.user-menu__head { padding: .6rem .75rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.user-menu__name { font-weight: 700; }
.user-menu__item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .55rem .75rem; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font-size: .88rem; text-align: left;
}
.user-menu__item:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.user-menu__item .material-symbols-outlined { color: var(--text-muted); font-size: 19px; }
.user-menu__item:hover .material-symbols-outlined { color: var(--primary); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.admin-main { flex: 1; padding: 2rem 0 4rem; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.75rem;
}
.page-header__titles { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.page-header p { color: var(--text-muted); }
.page-header__meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }
.page-header__actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: .3rem; font-size: .82rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .material-symbols-outlined { font-size: 16px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  --c: var(--primary); --c-soft: var(--primary-soft);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: .35rem;
  padding: 1.35rem 1.4rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform var(--motion-base) var(--ease-out), box-shadow var(--motion-base) var(--ease);
}
a.stat-card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c);
}
.stat-card[data-color="accent"] { --c: var(--accent); --c-soft: var(--accent-soft); }
.stat-card[data-color="ok"] { --c: var(--ok); --c-soft: var(--ok-bg); }
.stat-card[data-color="warn"] { --c: var(--warn); --c-soft: var(--warn-bg); }
.stat-card__icon {
  width: 42px; height: 42px; border-radius: 12px; margin-bottom: .4rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-soft); color: var(--c);
}
.stat-card__value { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat-card__label { font-size: .84rem; color: var(--text-muted); font-weight: 500; }

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.quick-actions { display: flex; flex-direction: column; gap: .6rem; }
.quick-action {
  display: flex; align-items: center; gap: .85rem;
  padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text); background: var(--bg-card);
  transition: border-color var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}
.quick-action:hover { text-decoration: none; border-color: var(--primary); transform: translateX(3px); }
.quick-action__icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.quick-action strong { display: block; font-size: .92rem; }
.quick-action small { color: var(--text-muted); }

.hero-banner {
  position: relative; overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 2rem 2.25rem;
  margin-bottom: 1.75rem;
  background: var(--primary-grad);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.hero-banner::after {
  content: ''; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 70%);
}
.hero-banner h1 { color: #fff; }
.hero-banner p { color: rgba(255, 255, 255, .8); margin-top: .35rem; }
.hero-banner .eyebrow { color: rgba(255, 255, 255, .75); }
.hero-banner__inner { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.hero-banner .btn-secondary { background: #fff; color: #6d071a; border-color: #fff; }
.hero-banner .btn-secondary:hover { color: #6d071a; box-shadow: 0 0 0 4px rgba(255, 255, 255, .25); }

.eyebrow { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); }

/* Settings form layout */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.danger-zone { border-color: var(--err-border); }
.danger-zone h3 { color: var(--err); }

/* ============================================================================
 * Quiz builder
 * ========================================================================== */
.builder-summary { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.q-list { display: flex; flex-direction: column; gap: .85rem; counter-reset: q; }
.q-card {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 1rem; align-items: start;
  padding: 1.1rem 1.15rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--motion-base) var(--ease), border-color var(--motion-base) var(--ease), transform var(--motion-base) var(--ease), opacity var(--motion-base) var(--ease);
}
.q-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.q-card:focus-within { border-color: var(--border-strong); }
.q-card.is-dragging { opacity: .45; transform: scale(.99); }
.q-card.is-drop-target { border-color: var(--primary); box-shadow: var(--shadow-glow); }
.q-card.is-new { animation: flash-in 1.2s var(--ease-out); }
@keyframes flash-in { 0% { box-shadow: 0 0 0 4px var(--primary-soft); border-color: var(--primary); } }

.q-card__handle {
  border: 0; background: transparent; color: var(--text-muted); cursor: grab;
  padding: .25rem; margin-top: .1rem; border-radius: 6px; touch-action: none;
}
.q-card__handle:hover { background: var(--bg-elev); color: var(--text); }
.q-card__handle:active { cursor: grabbing; }
.q-card__num {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: .9rem;
}
.q-card__body { min-width: 0; display: flex; flex-direction: column; gap: .6rem; }
.q-card__text { font-weight: 600; font-size: 1rem; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-line; }
.q-card__media { display: flex; gap: .75rem; align-items: flex-start; }
.q-card__thumb {
  width: 72px; height: 72px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg-elev);
}
.q-card__answers { display: flex; flex-wrap: wrap; gap: .4rem; }
.answer-pill {
  display: inline-flex; align-items: center; gap: .4rem; max-width: 100%;
  padding: .3rem .65rem .3rem .3rem; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border);
  font-size: .82rem; color: var(--text-secondary);
}
.answer-pill__letter {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border-strong);
  font-size: .7rem; font-weight: 700;
}
.answer-pill img { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }
.answer-pill.is-correct { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); font-weight: 600; }
.answer-pill.is-correct .answer-pill__letter { background: var(--ok); border-color: var(--ok); color: #fff; }
:root[data-theme="dark"] .answer-pill.is-correct .answer-pill__letter { color: #04210f; }
.q-card__info { display: flex; gap: .4rem; font-size: .84rem; color: var(--text-muted); }
.q-card__info .material-symbols-outlined { font-size: 17px; color: var(--accent); }
.q-card__actions { display: flex; gap: .15rem; }

.add-question {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; padding: 1.1rem;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: transparent; color: var(--text-secondary); font-weight: 600;
  transition: all var(--motion-fast) var(--ease);
}
.add-question:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ---------- Dialogs (modal + drawer) ---------- */
dialog {
  border: 0; padding: 0; color: var(--text); background: transparent;
  max-width: none; max-height: none;
}
dialog::backdrop { background: rgba(20, 4, 8, .55); backdrop-filter: blur(3px); }

.modal {
  margin: auto; width: min(460px, calc(100% - 2rem));
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal[open] { animation: modal-pop var(--motion-base) var(--ease-out); }
@keyframes modal-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal__body { padding: 1.5rem; display: flex; gap: 1rem; }
.modal__icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--err-bg); color: var(--err);
}
.modal__title { font-size: 1.05rem; font-weight: 700; margin-bottom: .3rem; }
.modal__text { color: var(--text-secondary); font-size: .92rem; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: .6rem;
  padding: 1rem 1.5rem; background: var(--bg-elev); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.drawer {
  margin: 0 0 0 auto; height: 100%; height: 100dvh; width: min(720px, 100%);
  background: var(--bg-body); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.drawer[open] { display: flex; flex-direction: column; animation: drawer-in 280ms var(--ease-out); }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
.drawer__form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.drawer__header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.5rem; background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.drawer__header h2 { font-size: 1.15rem; }
.drawer__body { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.drawer__footer {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: 1rem 1.5rem; background: var(--bg-card); border-top: 1px solid var(--border);
}
.kbd {
  display: inline-block; padding: .05rem .4rem; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .72rem; color: var(--text-muted);
  background: var(--bg-card);
}

.editor-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; }
.editor-section__title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.editor-section__title h3 { display: flex; align-items: center; gap: .5rem; font-size: .95rem; }

/* Image drop zone */
.dropzone {
  position: relative;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: .3rem;
  min-height: 120px; padding: 1rem;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-elev); color: var(--text-muted);
  text-align: center; font-size: .85rem; cursor: pointer;
  transition: all var(--motion-fast) var(--ease);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone strong { color: var(--text); }
.dropzone.has-image { padding: .5rem; min-height: 0; border-style: solid; cursor: default; }
.dropzone.has-image input[type="file"] { display: none; }
.dropzone.has-image > :not(.dropzone__preview):not(.dropzone__tools) { display: none; }
.dropzone__preview { max-height: 200px; border-radius: 8px; object-fit: contain; margin: 0 auto; }
.dropzone__tools { position: absolute; top: .4rem; right: .4rem; display: flex; gap: .3rem; }
.dropzone__tools .btn { background: var(--bg-card); box-shadow: var(--shadow-sm); }
.dropzone--sm { min-height: 0; width: 64px; height: 64px; padding: 0; flex-shrink: 0; }
.dropzone--sm.has-image { padding: 0; }
.dropzone--sm .dropzone__preview { width: 100%; height: 100%; max-height: none; object-fit: cover; border-radius: 10px; }
.dropzone--sm .dropzone__tools { top: -8px; right: -8px; }
.dropzone--sm .dropzone__tools .btn { padding: .1rem; border-radius: 50%; }
.dropzone--sm .dropzone__tools .material-symbols-outlined { font-size: 15px; }

/* Answer rows in the editor */
.answers-editor { display: flex; flex-direction: column; gap: .6rem; }
.answer-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .6rem .55rem .55rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-card);
  transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}
.answer-row:focus-within { border-color: var(--border-strong); }
.answer-row.is-correct { border-color: var(--ok-border); background: var(--ok-bg); }
.answer-row__correct { position: relative; display: inline-flex; }
.answer-row__correct input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.answer-row__letter {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--border-strong); background: var(--bg-card);
  font-weight: 800; font-size: .88rem; color: var(--text-secondary);
  transition: all var(--motion-fast) var(--ease);
  cursor: pointer;
}
.answer-row__correct input:focus-visible + .answer-row__letter { box-shadow: var(--shadow-glow); }
.answer-row__correct:hover .answer-row__letter { border-color: var(--ok); color: var(--ok); }
.answer-row.is-correct .answer-row__letter { background: var(--ok); border-color: var(--ok); color: #fff; }
:root[data-theme="dark"] .answer-row.is-correct .answer-row__letter { color: #04210f; }
.answer-row__text { flex: 1; min-width: 0; }
.answer-row__text input {
  width: 100%; border: 0; background: transparent; padding: .45rem .25rem; font-size: .95rem; outline: none;
}
.answer-row__badge { display: none; }
.answer-row.is-correct .answer-row__badge { display: inline-flex; }
.answers-help { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--text-muted); }

/* ============================================================================
 * Public site
 * ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-card) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .header-inner { height: 64px; }
.site-header .brand:hover { background: var(--primary-soft); }
.site-header .brand__logo { background: transparent; padding: 0; }
.site-header .brand__subtitle { color: var(--text-muted); }
.site-header .header-btn { background: var(--bg-elev); color: var(--text-secondary); border: 1px solid var(--border); }
.site-header .header-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--bg-card); }

.public-main { flex: 1; display: flex; flex-direction: column; }

.hero {
  position: relative; isolation: isolate; overflow: hidden;
  flex: 1; display: flex; align-items: center;
  padding: clamp(2.5rem, 7vw, 5.5rem) 0;
  background: #2c0408;
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -2;
  background: url("../img/cabosse.jpg") center / cover no-repeat;
  opacity: .5;
  filter: saturate(.9);
}
.hero::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(163, 20, 47, .55), transparent 60%),
    linear-gradient(160deg, rgba(44, 4, 8, .92) 0%, rgba(109, 7, 26, .78) 55%, rgba(44, 4, 8, .9) 100%);
}
.hero__grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 3rem; align-items: center; }
.hero__copy { color: #fff; }
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .85rem; margin-bottom: 1.25rem;
  border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18);
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
}
.hero__title {
  font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.05;
  color: #fff;
}
.hero__title em {
  font-style: normal;
  background: linear-gradient(110deg, #f3d9a4 10%, #c2a46a 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__lead { margin-top: 1.1rem; font-size: 1.08rem; color: rgba(255, 255, 255, .8); max-width: 34rem; }

.join-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
  border: 1px solid var(--border);
}
.join-card h2 { margin-bottom: .25rem; }
.join-card > p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .92rem; }
.code-input {
  width: 100%;
  padding: 1rem 1.1rem;
  border: 2px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-elev);
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: 1.7rem; font-weight: 700; letter-spacing: .35em; text-align: center; text-transform: uppercase;
  color: var(--text);
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}
.code-input::placeholder { color: var(--border-strong); letter-spacing: .35em; }
.code-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--shadow-glow); background: var(--bg-card); }
.join-card .btn-lg { margin-top: 1rem; }

.site-footer { background: var(--bg-card); border-top: 1px solid var(--border); padding: 1.75rem 0; }
.site-footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.partners { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.partners__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--text-muted); }
.partners img { height: 40px; width: auto; max-width: 120px; object-fit: contain; }
:root[data-theme="dark"] .partners img, :root[data-theme="dark"] .footer-brand img {
  background: #fff; padding: 4px 8px; border-radius: 8px;
}
.footer-brand { display: flex; align-items: center; gap: .75rem; font-size: .82rem; color: var(--text-muted); }
.footer-brand img { height: 36px; width: auto; }
.footer-brand a { color: var(--text-muted); }
.footer-brand a:hover { color: var(--primary); }

/* Centered single card pages (intro, result, login, errors) */
.center-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2.5rem 1rem; }
.center-card {
  width: 100%; max-width: 560px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.center-card--sm { max-width: 420px; }
.center-card__band {
  position: relative; padding: 2rem 2rem 1.75rem; color: #fff; background: var(--primary-grad);
}
.center-card__band::after {
  content: ''; position: absolute; right: -50px; top: -70px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 70%);
}
.center-card__band h1 { color: #fff; font-size: 1.6rem; position: relative; }
.center-card__band p { color: rgba(255, 255, 255, .82); margin-top: .4rem; position: relative; }
.center-card__band .eyebrow { color: rgba(255, 255, 255, .7); position: relative; }
.center-card__body { padding: 1.75rem 2rem 2rem; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1.5rem; }
.fact {
  display: flex; flex-direction: column; align-items: center; gap: .2rem; text-align: center;
  padding: .9rem .5rem; border-radius: var(--radius-md); background: var(--bg-elev); border: 1px solid var(--border);
}
.fact .material-symbols-outlined { color: var(--primary); }
.fact strong { font-size: 1.05rem; }
.fact span:last-child { font-size: .76rem; color: var(--text-muted); }

.login-brand { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin-bottom: 1.5rem; text-align: center; }
.login-brand img { width: 72px; height: 72px; object-fit: contain; }
.login-brand p { color: var(--text-muted); font-size: .9rem; }

/* ============================================================================
 * Play
 * ========================================================================== */
.play-body { background: var(--bg-body); }
.play-shell { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 920px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }

.play-top {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1rem; margin-bottom: 1rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.play-top__quit { color: var(--text-muted); }
.play-top__title { font-weight: 700; min-width: 0; flex: 1; }
.play-top__title small { display: block; font-weight: 500; color: var(--text-muted); font-size: .78rem; }
.play-top__score { display: flex; align-items: center; gap: .35rem; font-weight: 700; color: var(--accent); font-size: .9rem; }

.progress { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin-bottom: 1.25rem; }
.progress__bar { display: block; height: 100%; background: var(--primary-grad); border-radius: inherit; transition: width .5s var(--ease-out); }
progress.progress { appearance: none; width: 100%; border: 0; }
progress.progress::-webkit-progress-bar { background: var(--border); border-radius: 999px; }
progress.progress::-webkit-progress-value { background: var(--primary-grad); border-radius: 999px; }
progress.progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }

.timer {
  position: relative; width: 52px; height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 4; }
.timer__track { stroke: var(--border); }
.timer__ring { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke var(--motion-base) var(--ease); }
.timer__value { font-weight: 800; font-size: 1rem; font-variant-numeric: tabular-nums; }
.timer.is-warning .timer__ring { stroke: var(--warn); }
.timer.is-danger .timer__ring { stroke: var(--err); }
.timer.is-danger .timer__value { color: var(--err); animation: pulse 1s ease-in-out infinite; }
.timer.is-stopped .timer__ring { stroke: var(--border-strong); }
@keyframes pulse { 50% { transform: scale(1.12); } }

.question-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: clamp(1.25rem, 4vw, 2.25rem);
}
.question-card__label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: .5rem; }
.question-card__text { font-size: clamp(1.2rem, 2.6vw, 1.55rem); font-weight: 700; line-height: 1.35; letter-spacing: -.01em; white-space: pre-line; overflow-wrap: anywhere; }
.question-card__media { margin: 1.25rem auto 0; display: flex; justify-content: center; }
.question-card__media img { max-height: 280px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); object-fit: contain; }

.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; margin-top: 1.75rem; }
.option {
  position: relative;
  display: flex; align-items: center; gap: .85rem;
  width: 100%; padding: 1rem 1.1rem;
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-card); color: var(--text);
  text-align: left; font-size: 1rem; font-weight: 500;
  transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease),
              transform var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease), opacity var(--motion-base) var(--ease);
}
.option:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.option:disabled { cursor: default; }
.option__letter {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  font-weight: 800; font-size: .9rem; color: var(--text-secondary);
  transition: all var(--motion-fast) var(--ease);
}
.option:hover:not(:disabled) .option__letter { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.option__content { display: flex; flex-direction: column; gap: .6rem; min-width: 0; flex: 1; overflow-wrap: anywhere; }
.option__content img { max-height: 160px; border-radius: 10px; object-fit: contain; align-self: center; }
.option__state { margin-left: auto; display: none; }
.options--media .option { flex-direction: column; align-items: stretch; text-align: center; }
.options--media .option__letter { position: absolute; top: .6rem; left: .6rem; }
.options--media .option__content { padding-top: .25rem; }

.option.is-correct { border-color: var(--ok); background: var(--ok-bg); opacity: 1; }
.option.is-correct .option__letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.is-correct .option__state { display: inline-flex; color: var(--ok); }
.option.is-wrong { border-color: var(--err); background: var(--err-bg); opacity: 1; animation: shake .4s var(--ease); }
.option.is-wrong .option__letter { background: var(--err); border-color: var(--err); color: #fff; }
.option.is-wrong .option__state { display: inline-flex; color: var(--err); }
.option.is-dim { opacity: .5; }
.option.is-pending { border-color: var(--primary); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

.feedback {
  margin-top: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: rise var(--motion-base) var(--ease-out);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.feedback__head { display: flex; align-items: center; gap: .65rem; padding: .9rem 1.1rem; font-weight: 700; font-size: 1.05rem; }
.feedback__head .material-symbols-outlined { font-size: 26px; }
.feedback--ok .feedback__head { background: var(--ok-bg); color: var(--ok); }
.feedback--ko .feedback__head { background: var(--err-bg); color: var(--err); }
.feedback--timeout .feedback__head { background: var(--warn-bg); color: var(--warn); }
.feedback__info { padding: 1rem 1.1rem; display: flex; gap: .65rem; background: var(--bg-card); color: var(--text-secondary); font-size: .95rem; border-top: 1px solid var(--border); white-space: pre-line; }
.feedback__info .material-symbols-outlined { color: var(--accent); }

.play-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }
.play-actions .hint { display: flex; align-items: center; gap: .35rem; }

/* Result */
.score-ring { position: relative; width: 168px; height: 168px; margin: 0 auto 1.25rem; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring circle { fill: none; stroke-width: 12; }
.score-ring__track { stroke: var(--border); }
.score-ring__value { stroke: var(--primary); stroke-linecap: round; animation: ring-in 1.2s var(--ease-out); }
.score-ring[data-tone="good"] .score-ring__value { stroke: var(--ok); }
.score-ring[data-tone="mid"] .score-ring__value { stroke: var(--warn); }
@keyframes ring-in { from { stroke-dashoffset: 440; } }
.score-ring__label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring__label strong { font-size: 2.4rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.score-caption { text-align: center; margin: -.5rem 0 1.25rem; font-size: .9rem; font-weight: 600; color: var(--text-muted); }
.result-message { text-align: center; margin-bottom: 1.5rem; }
.result-message h2 { margin-bottom: .3rem; }
.result-message p { color: var(--text-muted); }

.review { display: flex; flex-direction: column; gap: .75rem; }
.review-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .85rem;
  padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-elev);
}
.review-item__icon {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.review-item--ok .review-item__icon { background: var(--ok-bg); color: var(--ok); }
.review-item--ko .review-item__icon { background: var(--err-bg); color: var(--err); }
.review-item__q { font-weight: 600; margin-bottom: .35rem; white-space: pre-line; overflow-wrap: anywhere; }
.review-item__line { font-size: .87rem; color: var(--text-secondary); }
.review-item__line strong { color: var(--text); }
.review-item__info { margin-top: .4rem; font-size: .84rem; color: var(--text-muted); font-style: italic; white-space: pre-line; }

details.disclosure { border-top: 1px solid var(--border); margin-top: 1.5rem; padding-top: 1rem; }
details.disclosure > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; padding: .25rem 0;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .material-symbols-outlined { transition: transform var(--motion-base) var(--ease); }
details.disclosure[open] > summary .material-symbols-outlined { transform: rotate(180deg); }
details.disclosure > .review { margin-top: 1rem; }

/* Review carousel (enabled by app.js) */
.review-nav { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.review-nav__dot {
  width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 2px solid transparent;
  font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
  transition: transform var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}
.review-nav__dot--ok { background: var(--ok-bg); color: var(--ok); }
.review-nav__dot--ko { background: var(--err-bg); color: var(--err); }
.review-nav__dot:hover { transform: scale(1.08); }
.review-nav__dot.is-active { border-color: currentColor; transform: scale(1.12); }
.review.is-carousel .review-item { min-height: 9rem; }
.review-controls { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.review-controls__count { font-size: .87rem; font-weight: 600; color: var(--text-muted); }

/* Error page */
.error-code { font-size: 4.5rem; font-weight: 800; letter-spacing: -.05em; line-height: 1; color: var(--primary); }
.debug-trace { margin-top: 1rem; max-height: 300px; overflow: auto; padding: 1rem; font-size: .75rem; background: var(--bg-elev); border-radius: var(--radius-sm); white-space: pre-wrap; text-align: left; }

/* ============================================================================
 * Responsive
 * ========================================================================== */
@media (max-width: 960px) {
  .hero__grid, .dash-grid, .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .hero__grid { gap: 2rem; }
}

@media (max-width: 820px) {
  .header-inner { gap: .75rem; }
  .brand__titles { display: none; }
  .header-nav a span:not(.material-symbols-outlined) { display: none; }
  .header-nav a { padding: .5rem .65rem; }
}

@media (max-width: 640px) {
  .container { padding: 0 1rem; }
  .admin-main { padding-top: 1.25rem; }
  .options { grid-template-columns: 1fr; }
  .options--media { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact { padding: .7rem .3rem; }
  .stat-card { padding: 1rem; }
  .stat-card__value { font-size: 1.6rem; }
  .q-card { grid-template-columns: auto minmax(0, 1fr); }
  .q-card__handle { display: none; }
  .q-card__actions { grid-column: 1 / -1; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: .6rem; }
  .table th:nth-child(n+3):not(.actions), .table td:nth-child(n+3):not(.actions) { display: none; }
  .join-card, .center-card__body { padding: 1.5rem; }
  .center-card__band { padding: 1.5rem; }
  .hero-banner { padding: 1.5rem; }
  .toasts { left: 1rem; right: 1rem; }
  .toast { max-width: none; }
  .play-actions .hint { display: none; }
  .page-header__actions { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
