/* ═══════════════════════════════════════════════════════════════════
   Tokki 2.0 — Design System
   Tokens → Reset → Layout → Components → Views → Responsive
   ═══════════════════════════════════════════════════════════════════ */

/* ───────── Design Tokens — Light ───────── */
:root {
  --bg: #f5f7fb;
  --bg-gradient-a: rgba(124,58,237,.12);
  --bg-gradient-b: rgba(37,99,235,.12);
  --panel: rgba(255,255,255,.82);
  --panel-strong: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15,23,42,.10);
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --success: #15803d;
  --danger: #dc2626;
  --shadow: 0 16px 40px rgba(15,23,42,.12);
  --radius: 24px;
  --transition-bg: background-color 0.3s ease, color 0.3s ease;
}

/* ───────── Dark Theme (default) ───────── */
body.dark {
  --bg: #07101f;
  --bg-gradient-a: rgba(124,58,237,.18);
  --bg-gradient-b: rgba(37,99,235,.15);
  --panel: rgba(15,23,42,.80);
  --panel-strong: #0f172a;
  --text: #e5eefc;
  --muted: #9fb2cf;
  --border: rgba(255,255,255,.08);
  --accent: #60a5fa;
  --accent-2: #a78bfa;
  --success: #22c55e;
  --danger: #f87171;
  --shadow: 0 20px 50px rgba(0,0,0,.40);
}

/* ───────── Amber Theme ───────── */
body.amber {
  --bg: #1c1208;
  --bg-gradient-a: rgba(217,119,6,.22);
  --bg-gradient-b: rgba(234,88,12,.14);
  --panel: rgba(41,24,4,.78);
  --panel-strong: #2a1a04;
  --text: #fef3c7;
  --muted: #d97706;
  --border: rgba(251,191,36,.14);
  --accent: #f59e0b;
  --accent-2: #ea580c;
  --success: #86efac;
  --danger: #fb7185;
  --shadow: 0 16px 40px rgba(0,0,0,.40);
}

/* ───────── Butter Theme ───────── */
body.butter {
  --bg: #fdfbd4;
  --bg-gradient-a: rgba(202,138,4,.10);
  --bg-gradient-b: rgba(180,120,0,.07);
  --panel: rgba(253,247,200,.85);
  --panel-strong: #faf5c8;
  --text: #2d2007;
  --muted: #7c5e1a;
  --border: rgba(180,140,0,.16);
  --accent: #b45309;
  --accent-2: #ca8a04;
  --success: #166534;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(100,60,0,.10);
}

/* ───────── Sakura Theme ───────── */
body.sakura {
  --bg: #fedfe1;
  --bg-gradient-a: rgba(180,60,90,.10);
  --bg-gradient-b: rgba(200,80,100,.07);
  --panel: rgba(255,235,237,.82);
  --panel-strong: #fff0f2;
  --text: #2d1a1e;
  --muted: #8a4a58;
  --border: rgba(160,60,80,.14);
  --accent: #9b2335;
  --accent-2: #c0404e;
  --success: #166534;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(120,30,50,.12);
}

/* ───────── Matcha Theme ───────── */
body.matcha {
  --bg: #e4f8ba;
  --bg-gradient-a: rgba(120,190,60,.12);
  --bg-gradient-b: rgba(90,160,30,.08);
  --panel: rgba(244,255,227,.88);
  --panel-strong: #f4ffe3;
  --text: #2f3e1f;
  --muted: #5a7a3a;
  --border: rgba(80,140,30,.14);
  --accent: #4f8a1e;
  --accent-2: #7bbf2e;
  --success: #166534;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(60,100,20,.10);
}

/* ───────── Lavender Theme ───────── */
body.lavender {
  --bg: #f0e8fc;
  --bg-gradient-a: rgba(147,90,219,.10);
  --bg-gradient-b: rgba(113,56,179,.07);
  --panel: rgba(242,234,255,.88);
  --panel-strong: #f7f2ff;
  --text: #2c1a4a;
  --muted: #7a5aaa;
  --border: rgba(120,70,180,.14);
  --accent: #7c3aed;
  --accent-2: #a855f7;
  --success: #166534;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(80,40,140,.10);
}

/* ───────── Sora Theme ───────── */
body.sora {
  --bg: #e0f7fc;
  --bg-gradient-a: rgba(6,182,212,.10);
  --bg-gradient-b: rgba(14,165,233,.07);
  --panel: rgba(224,248,255,.88);
  --panel-strong: #f0fbff;
  --text: #0a2a38;
  --muted: #2e7a9a;
  --border: rgba(14,165,233,.14);
  --accent: #0284c7;
  --accent-2: #06b6d4;
  --success: #166534;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(6,100,140,.10);
}

/* ───────── Peach Theme ───────── */
body.peach {
  --bg: #ffe5cf;
  --bg-gradient-a: rgba(255,158,109,.12);
  --bg-gradient-b: rgba(255,179,138,.08);
  --panel: rgba(255,241,230,.88);
  --panel-strong: #fff1e6;
  --text: #2a2a2a;
  --muted: #8a5a3a;
  --border: rgba(255,214,189,.40);
  --accent: #e07830;
  --accent-2: #ff9e6d;
  --success: #166534;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(180,90,30,.10);
}

/* ───────── Reset & Base ───────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  margin: 0; padding: 0;
  min-height: 100%;
  overflow-x: hidden;
  background-color: var(--bg);
  transition: var(--transition-bg);
}

body {
  margin: 0; padding: 0; min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, var(--bg-gradient-a), transparent 26%),
    radial-gradient(circle at top right, var(--bg-gradient-b), transparent 28%),
    var(--bg);
  color: var(--text);
  transition: background-color 0.28s ease, color 0.20s ease;
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* ───────── Text Selection Block ───────── */
body, .app, main, section, article, div, p, span, h1, h2, h3, h4, h5, h6, button, label {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}
input, textarea {
  user-select: text;
  -webkit-user-select: text;
  -ms-user-select: text;
}

/* ───────── App Layout ───────── */
#app { max-width: 1180px; margin: 0 auto; padding: 24px; }

.main-content {
  position: relative;
  transition: opacity 0.18s ease;
}
.main-content.fading { opacity: 0; }

/* ───────── Topbar ───────── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.topbar-brand { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.topbar-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  background: transparent;
}
.topbar-title { font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 8px 14px; border-radius: 14px; backdrop-filter: blur(10px);
  font-size: .88rem; font-weight: 600;
}
.btn-icon {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 9px 13px; border-radius: 14px; backdrop-filter: blur(10px);
  cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease;
  font-size: 1rem; font-weight: 600;
}
.btn-icon:hover { transform: translateY(-1px); border-color: rgba(37,99,235,.32); }

/* ───────── Views ───────── */
.view {
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 28px; padding: 26px; backdrop-filter: blur(16px);
  animation: fadeSlide .22s ease;
}

/* ───────── Animations ───────── */
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* ───────── Hero / Home ───────── */
.hero {
  min-height: 72vh; display: grid; place-items: center;
}
.hero-card {
  width: min(840px, 100%); text-align: center; padding: 48px 24px;
}
.hero-emoji {
  font-size: 5rem; line-height: 1; margin-bottom: 20px;
  animation: pulse 3s ease-in-out infinite;
  display: block;
}

/* ── Tokki Logo SVG ── */
.tokki-logo {
  object-fit: contain;
  display: block;
  /* El SVG contiene raster embebido; sin filter para preservar colores reales */
}
.tokki-logo--topbar {
  width: 44px;
  height: 44px;
  /* Sin filter: mostrar colores naturales del logo */
}
.tokki-logo--hero {
  width: 210px;
  height: 210px;
  margin: 0 auto 28px;
  animation: pulse 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 28px rgba(37,99,235,.22));
}
.tokki-logo--card {
  width: 64px;
  height: 64px;
}
.kicker {
  display: inline-flex; gap: 10px; align-items: center;
  padding: 8px 16px; border-radius: 999px;
  background: rgba(37,99,235,.10); color: var(--accent);
  font-weight: 700; margin-bottom: 18px; font-size: .9rem;
  border: 1px solid rgba(37,99,235,.15);
}
.hero h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); line-height: 1.05; margin-bottom: 16px; font-weight: 900; }
.subtitle {
  color: var(--muted); font-size: 1.08rem; max-width: 680px;
  margin: 0 auto 32px; line-height: 1.6;
}
.footer-note { margin-top: 20px; color: var(--muted); font-size: .9rem; }

/* ───────── Buttons ───────── */
.primary {
  border: none; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 15px 26px; border-radius: 18px; cursor: pointer;
  font-weight: 800; letter-spacing: .02em;
  box-shadow: 0 12px 28px rgba(37,99,235,.28);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.25s ease, box-shadow 0.25s ease;
}
.primary:hover { transform: translateY(-2px) scale(1.01); filter: brightness(1.05); }
.primary:active:not(:disabled) {
  transform: scale(0.97) translateY(1px);
  box-shadow: 0 6px 14px rgba(37,99,235,.20);
  transition-duration: 0.08s;
}
.primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.secondary {
  border: 1px solid var(--border); color: var(--text);
  background: var(--panel-strong); padding: 13px 20px;
  border-radius: 18px; cursor: pointer; font-weight: 700;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.25s ease;
}
.secondary:hover { transform: translateY(-1px); border-color: rgba(37,99,235,.28); }
.secondary:active:not(:disabled) { transform: scale(0.97); transition-duration: 0.08s; }

.ghost {
  border: 1px solid rgba(150,150,150,.15); color: var(--muted);
  background: transparent; padding: 12px 16px;
  border-radius: 18px; cursor: pointer; font-weight: 600;
  font-size: 0.95rem; transition: all .16s ease;
}
.ghost:hover { background: rgba(150,150,150,.05); color: var(--text); }

.danger {
  border: none; color: #fff;
  background: linear-gradient(135deg, #dc2626, #9f1239);
  padding: 13px 20px; border-radius: 18px; cursor: pointer;
  font-weight: 700; transition: filter .2s ease, transform .2s ease;
}
.danger:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* ───────── Grid & Cards ───────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.category-card {
  background: var(--panel-strong); border: 1px solid var(--border);
  border-radius: 22px; padding: 22px; cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.25s ease, box-shadow 0.25s ease;
  position: relative; overflow: hidden;
}
.category-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(37,99,235,.04));
  opacity: 0; transition: opacity .25s ease;
}
.category-card:hover::before { opacity: 1; }
.category-card:active { transform: scale(0.975); transition-duration: 0.08s; }
.category-card:hover {
  transform: translateY(-4px); border-color: rgba(37,99,235,.28);
  box-shadow: 0 16px 32px rgba(37,99,235,.12);
}
.category-card .card-icon {
  font-size: 1.6rem; margin-bottom: 10px; display: block;
}
.category-card h3 { font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.category-card .count { color: var(--muted); font-size: .88rem; }
.badge-demo {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--panel-hover);
  color: var(--text-primary);
  opacity: 0.8;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}
/* ───────── Section Header ───────── */
.section-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.section-head h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.section-head p { color: var(--muted); font-size: .95rem; }
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.badge {
  font-size: .85rem; padding: 4px 12px; border-radius: 999px;
  font-weight: 700; white-space: nowrap;
}
.badge--fire { background: rgba(245,158,11,.15); color: #d97706; }
.badge--time { background: rgba(16,185,129,.15); color: #059669; }

/* ───────── Mode Cards ───────── */
.modes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.mode-card {
  background: var(--panel-strong); border: 1px solid var(--border);
  border-radius: 26px; padding: 40px 32px; cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.25s ease, box-shadow 0.25s ease;
}
.mode-card:hover { transform: translateY(-4px); }
.mode-card:active { transform: scale(0.975); transition-duration: 0.08s; }
.mode-card__icon { font-size: 2.6rem; margin-bottom: 14px; line-height: 1; display: block; }
.mode-card h3 { font-size: 1.5rem; font-weight: 900; margin-bottom: 10px; }
.mode-card__desc { color: var(--muted); font-size: .97rem; line-height: 1.6; }

.mode-card--loop { border-color: rgba(220,38,38,.20); }
.mode-card--loop:hover {
  border-color: rgba(220,38,38,.50);
  box-shadow: 0 14px 32px rgba(220,38,38,.14);
}
.mode-card--random:hover {
  border-color: rgba(37,99,235,.40);
  box-shadow: 0 14px 32px rgba(37,99,235,.14);
}

/* ───────── Auth / Profile ───────── */
.auth-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
.panel {
  background: var(--panel-strong); border: 1px solid var(--border);
  border-radius: 22px; padding: 20px;
}
label { display: block; font-size: .9rem; font-weight: 700; margin-bottom: 8px; color: var(--muted); }
.field { margin-bottom: 16px; }
input, select {
  width: 100%; border-radius: 14px; border: 1.5px solid var(--border);
  background: transparent; color: var(--text);
  padding: 13px 14px; outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
input:focus, select:focus {
  border-color: rgba(37,99,235,.45);
  box-shadow: 0 0 0 4px rgba(37,99,235,.08);
}
.profile-mini { display: grid; gap: 10px; color: var(--muted); font-size: .95rem; }
.profile-mini strong { color: var(--text); }

/* ───────── Exam ───────── */
.exam-shell { display: grid; gap: 18px; }
.exam-top {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
}
.progress-wrap { display: grid; gap: 8px; }
.progress-meta {
  display: flex; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; color: var(--muted); font-size: .9rem; font-weight: 600;
}
.progress-bar {
  width: 100%; height: 10px; background: rgba(148,163,184,.18);
  border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px; transition: width .3s ease;
}
.q-card {
  background: var(--panel-strong); border: 1px solid var(--border);
  border-radius: 26px; padding: 24px; animation: fadeSlide .2s ease;
}
.question-text { font-size: 1.12rem; line-height: 1.75; margin-bottom: 28px; font-weight: 500; }
.question-line { margin-bottom: 8px; }
.math-display-wrap {
  margin: 32px 0; max-width: 100%;
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
}
.math-display {
  text-align: center; font-size: 1.3rem;
  padding: 14px 0; margin: 0 auto;
  min-width: min-content; color: var(--text);
}
mjx-container[display="true"] { margin: 0 !important; }

.options { display: grid; gap: 14px; }
.option {
  display: flex; gap: 16px; align-items: center; width: 100%; text-align: left;
  padding: 20px 22px; border-radius: 20px; min-height: 68px;
  border: 1.5px solid var(--border); background: transparent; color: var(--text);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
              border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}
.option:hover:not(.correct):not(.incorrect):not(:disabled) {
  transform: translateX(3px); border-color: rgba(37,99,235,.32);
  box-shadow: 0 4px 14px rgba(37,99,235,.08);
}
.option:active:not(.correct):not(.incorrect):not(:disabled) {
  transform: scale(0.985); transition-duration: 0.08s;
}
.option.correct  { border-color: rgba(21,128,61,.50);  background: rgba(34,197,94,.10); }
.option.incorrect{ border-color: rgba(220,38,38,.50);  background: rgba(248,113,113,.12); }
.option .letter {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(148,163,184,.18); font-weight: 800; font-size: .9rem;
}
.option.correct  .letter { background: rgba(34,197,94,.2);  color: var(--success); }
.option.incorrect .letter { background: rgba(248,113,113,.2); color: var(--danger); }
.option:disabled { cursor: default; opacity: .72; }
.option-content {
  flex: 1; overflow-x: auto; overflow-y: hidden;
  padding: 4px 0; min-width: 0; line-height: 1.75; font-size: 1.05rem;
}
.option-content::-webkit-scrollbar, .math-display-wrap::-webkit-scrollbar { height: 4px; }
.option-content::-webkit-scrollbar-thumb, .math-display-wrap::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,.3); border-radius: 4px;
}

.feedback { min-height: 26px; font-weight: 800; margin-top: 12px; font-size: 1rem; }
.feedback.ok  { color: var(--success); }
.feedback.bad { color: var(--danger); }
.explanation {
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(148,163,184,.09);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.6;
  opacity: .92;
}

.exam-actions {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  padding: 9px 14px; border-radius: 12px;
  background: var(--panel-strong); border: 1px solid var(--border);
  font-weight: 700; font-size: .9rem;
}

/* ── Confirm Banner (reemplaza window.confirm) ─────────────────── */
.confirm-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: rgba(220,38,38,.08);
  border: 1px solid rgba(220,38,38,.28);
  border-radius: 16px; padding: 14px 18px;
  margin-bottom: 14px;
  animation: fadeSlide .18s ease;
}
.confirm-banner__msg { font-weight: 700; font-size: .95rem; flex: 1; }
.confirm-banner__btns { display: flex; gap: 8px; flex-shrink: 0; }

/* ───────── Results ───────── */
.result-box { text-align: center; padding: 32px 18px; }
.result-box h2 { font-size: 2rem; margin-bottom: 8px; font-weight: 900; }
.result-stats-grid {
  background: var(--panel-strong); border: 1px solid var(--border);
  border-radius: 20px; padding: 24px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px; margin: 20px 0; text-align: left;
}
.result-stat { text-align: center; }
.result-stat__value { font-size: 2rem; font-weight: 900; }
.result-stat__label { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* ───────── Admin ───────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th {
  text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border);
  font-weight: 800; color: var(--muted); font-size: .82rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.admin-table td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(37,99,235,.025); }
.btn-sm {
  padding: 6px 12px; border-radius: 10px; font-size: .82rem;
  font-weight: 700; border: 1px solid var(--border); background: var(--panel-strong);
  color: var(--text); cursor: pointer; margin-right: 4px;
  transition: transform .12s ease, border-color .12s ease;
}
.btn-sm:hover { transform: translateY(-1px); border-color: rgba(37,99,235,.30); }
.tab-bar {
  display: flex; gap: 10px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border); padding-bottom: 12px; flex-wrap: wrap;
}

/* ───────── Utility ───────── */
.small { font-size: .88rem; color: var(--muted); }
.text-center { text-align: center; }
.loading-spinner {
  display: inline-block; width: 24px; height: 24px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .6s linear infinite;
}

/* ───────── Modals ───────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.60); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto; backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none !important; }
.modal-content {
  background: var(--panel-strong); color: var(--text);
  padding: 28px; border-radius: 24px;
  width: 95%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: fadeSlide .2s ease;
}
.modal-content h3 { margin-bottom: 16px; font-size: 1.1rem; }

/* ───────── Toast ───────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 13px 22px; border-radius: 16px; font-weight: 700; font-size: .92rem;
  z-index: 10001; animation: toastIn .3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
}
.toast.error   { background: var(--danger);  color: #fff; }
.toast.success { background: var(--success); color: #fff; }
.toast.info    { background: var(--accent);  color: #fff; }

/* ───────── Watermark ───────── */
#watermark-overlay {
  position: fixed; bottom: 22px; right: 26px;
  font-size: .88rem; font-weight: 800;
  color: rgba(148,163,184,0.12);
  pointer-events: none; z-index: 9999;
  transform: rotate(-14deg); letter-spacing: .06em;
  text-transform: uppercase; white-space: nowrap;
}

/* ───────── Theme Cycle Button (Apple-style) ───────── */
.theme-cycle-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px 7px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition:
    transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.25s ease;
  color: var(--text);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.theme-cycle-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(var(--theme-swatch-r, 100), var(--theme-swatch-g, 100), var(--theme-swatch-b, 100), 0.18), var(--shadow);
  border-color: rgba(148, 163, 184, 0.30);
}
.theme-cycle-btn:active {
  transform: scale(0.96);
  transition-duration: 0.08s;
}
.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}

/* ───────── Responsive ───────── */
@media (max-width: 880px) {
  .auth-grid { grid-template-columns: 1fr; }
  .exam-top  { grid-template-columns: 1fr; }
  .admin-table { font-size: .8rem; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
  .modes-grid { grid-template-columns: 1fr; }
  .mode-card  { padding: 28px 22px; }
}

@media (max-width: 600px) {
  #app { padding: 16px; max-width: 100%; }
  .hero { min-height: 56vh; }
  .hero-card { padding: 28px 0; }
  .hero h1   { font-size: clamp(1.8rem, 8.5vw, 2.8rem); }
  .subtitle  { font-size: .96rem; }
  .topbar    { flex-wrap: wrap; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .view { padding: 18px 16px; border-radius: 20px; }
  .math-display-wrap { margin: 18px 0; max-width: 100vw; }
  .math-display { font-size: 1.1rem; padding: 8px 0; }
  .option-content { font-size: 1rem; }
  mjx-container[display="true"] {
    max-width: 100%; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
}
