/* ─── Design Tokens ──────────────────────────────────────────────────────── */
/* Palette informed by color psychology for learning: green (focus/rest), blue
   (calm productivity), orange (energy & CTAs), amber highlights used sparingly. */
:root {
  --font: 'Inter', system-ui, sans-serif;

  /* Dark theme (default) — cool blue-gray base, easier long reading sessions */
  --bg: #0a1018;
  --bg2: #0f1724;
  --surface: rgba(255,255,255,0.045);
  --surface-hover: rgba(255,255,255,0.09);
  --border: rgba(255,255,255,0.1);
  /* Primary text: cool off-white (readable on dark blue-gray UI) */
  --ink: #e8eef8;
  --ink2: #9cb4d8;
  --ink3: #6b829e;

  --focus-green: #3ecf8e;
  --focus-green-dim: rgba(62, 207, 142, 0.14);
  --focus-green-edge: rgba(62, 207, 142, 0.32);
  --calm-blue: #5b9cf5;
  --calm-blue-dim: rgba(91, 156, 245, 0.16);
  --calm-blue-edge: rgba(91, 156, 245, 0.35);
  --energy-orange: #f97316;
  --energy-orange-hot: #ea580c;
  --spot-amber: #fbbf24;
  --yellow-accent: #f5c842;
  --yellow-dim: rgba(245, 200, 66, 0.18);
  --yellow-edge: rgba(245, 200, 66, 0.45);

  --primary: var(--energy-orange);
  --primary-2: #fb923c;
  --primary-glow: rgba(249, 115, 22, 0.38);
  --accent: var(--spot-amber);
  --danger: #ef4444;
  --success: #22c55e;
  --green-glow: rgba(62, 207, 142, 0.22);
  --green-ring: rgba(62, 207, 142, 0.35);
  /* Brand wordmark + logo: tint of #0E21A0 for dark UI */
  --brand-blue: #c4c9f5;

  --sidebar-w: min(240px, 78vw);
  --topbar-h: 56px;
  --radius: 16px;
  --radius-sm: 10px;
  --trans: 0.22s ease;
  --content-max: 1120px;
}

[data-theme="light"] {
  --bg: #e8eef8;
  --bg2: #ffffff;
  --surface: rgba(14, 33, 160, 0.045);
  --surface-hover: rgba(22, 163, 74, 0.08);
  --border: rgba(14, 33, 160, 0.14);
  /* Primary body + headings — #0E21A0 family */
  --ink: #0e21a0;
  --ink2: #2a3390;
  --ink3: #4a5298;
  --focus-green: #0d9488;
  --focus-green-dim: rgba(13, 148, 136, 0.12);
  --focus-green-edge: rgba(13, 148, 136, 0.38);
  --green-glow: rgba(13, 148, 136, 0.18);
  --green-ring: rgba(13, 148, 136, 0.3);
  --brand-blue: #0e21a0;
  --calm-blue-dim: rgba(37, 99, 235, 0.1);
  --calm-blue-edge: rgba(37, 99, 235, 0.28);
  --primary-glow: rgba(249, 115, 22, 0.22);
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, video { max-width: 100%; height: auto; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  font-size: 106.25%;
  color-scheme: dark;
}
html[data-theme="light"] { color-scheme: light; }

body {
  overflow-x: hidden;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 70% 45% at 12% -10%, var(--focus-green-dim) 0%, transparent 55%),
    radial-gradient(ellipse 55% 40% at 92% 105%, var(--calm-blue-dim) 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.58;
  transition: background var(--trans), color var(--trans);
  -webkit-font-smoothing: antialiased;
}

/* ─── Glass Utility ──────────────────────────────────────────────────────── */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-color: color-mix(in srgb, var(--border) 85%, var(--focus-green) 15%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius);
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.12), inset 0 1px 0 var(--focus-green-dim);
}

[data-theme="light"] .glass {
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06), inset 0 1px 0 var(--focus-green-dim);
}

/* ─── Auth Overlay ───────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: flex-start; justify-content: center;
  background:
    radial-gradient(ellipse at 18% 28%, var(--focus-green-dim) 0%, transparent 58%),
    radial-gradient(ellipse at 82% 72%, var(--calm-blue-dim) 0%, transparent 52%),
    var(--bg);
  z-index: 1000;
  padding: 1rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.4s ease;
}

.practice-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 24, 0.45);
  z-index: 1100;
  padding: 1rem;
}

.practice-loading-card {
  min-width: 260px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 14px 40px rgba(0,0,0,0.3);
}

.practice-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--focus-green-dim);
  border-top-color: var(--focus-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.practice-loading-card p {
  font-size: 0.92rem;
  color: var(--ink2);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.auth-card {
  width: 100%; max-width: 420px;
  flex: 0 0 auto;
  margin-block: auto;
  margin-inline: 0;
  padding: 2.4rem 2rem;
  box-shadow: 0 32px 80px rgba(0,0,0,0.45);
  animation: slideUp 0.4s cubic-bezier(0.22,1,0.36,1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.8rem;
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-smoothing: antialiased;
}

.neuromath-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.neuromath-logo img {
  display: block;
  width: 100%;
  height: auto;
}

[data-theme="dark"] .neuromath-logo__light,
[data-theme="light"] .neuromath-logo__dark {
  display: none;
}

.neuromath-logo--auth {
  width: 9rem;
  max-width: 100%;
}

.neuromath-logo--sidebar {
  width: 7.75rem;
  max-width: calc(100% - 3rem);
}

.brand-title {
  font-size: clamp(2rem, 7vw, 2.85rem);
  font-weight: 800;
  color: var(--brand-blue);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.brand-tagline {
  color: var(--ink2);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-top: 0.55rem;
  max-width: 24rem;
  margin-inline: auto;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 1.6rem;
}

.auth-tab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink3);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans);
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--focus-green), #2dd4a8);
  color: #06281f;
  box-shadow: 0 4px 18px var(--green-glow), 0 0 0 1px var(--yellow-edge);
  font-weight: 600;
}

[data-theme="light"] .auth-tab.active {
  background: linear-gradient(135deg, #0d9488, #14b8a6);
  color: #fff;
  box-shadow: 0 4px 16px var(--green-glow), 0 0 0 1px var(--yellow-edge);
}

/* Auth Panel */
.auth-panel { display: none; }
.auth-panel.active { display: block; }

.auth-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

@media (max-height: 760px) {
  .auth-overlay {
    align-items: flex-start;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .auth-card {
    margin-block: 0;
    padding-block: 1.5rem;
  }

  .auth-brand {
    margin-bottom: 1rem;
  }

  .neuromath-logo--auth {
    width: 7.5rem;
  }
}

.auth-error.success {
  background: rgba(62,207,142,0.12);
  border-color: rgba(62,207,142,0.35);
  color: var(--focus-green);
}

.signup-verification {
  margin-bottom: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--focus-green-edge);
  border-radius: var(--radius-sm);
  background: var(--focus-green-dim);
  color: var(--ink2);
  font-size: 0.88rem;
}
.signup-verification p { margin-bottom: 0.6rem; }
.signup-verification .btn-secondary { margin: 0; }

.auth-switch {
  text-align: center;
  margin-top: 1.2rem;
  font-size: 0.85rem;
  color: var(--ink3);
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-switch a:hover { text-decoration: underline; }

/* ─── Form Fields ─────────────────────────────────────────────────────────── */
.field-group { margin-bottom: 1rem; }

.field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink2);
  margin-bottom: 0.45rem;
  letter-spacing: 0.02em;
}

.field-input {
  width: 100%;
  padding: 0.72rem 0.95rem;
  min-height: 46px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.05rem;
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
}

.field-input:focus {
  border-color: var(--focus-green-edge);
  box-shadow: 0 0 0 3px var(--green-ring);
}

.password-field { position: relative; }
.password-field .field-input { padding-right: 3.45rem; }
.password-field .field-input::-ms-reveal { display: none; }
.password-visibility {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink2);
  cursor: pointer;
}
.password-visibility:hover { color: var(--focus-green); }
.password-visibility:focus-visible { outline: 2px solid var(--focus-green); outline-offset: -3px; }

.field-input::placeholder { color: var(--ink3); }

select.field-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%233ecf8e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.2rem;
}
[data-theme="dark"] select { color-scheme: dark; background-color: #142033; color: #e8eef8; }
[data-theme="dark"] select option, [data-theme="dark"] select optgroup { background-color: #142033; color: #e8eef8; }
[data-theme="light"] select { color-scheme: light; background-color: #fff; color: #0e21a0; }
[data-theme="light"] select option, [data-theme="light"] select optgroup { background-color: #fff; color: #0e21a0; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.35rem;
  min-height: 46px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1.03rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans);
  box-shadow: 0 4px 20px var(--primary-glow), 0 0 0 1px var(--yellow-dim);
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px var(--primary-glow);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary.full-width { width: 100%; justify-content: center; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans);
}

.btn-secondary:hover {
  background: var(--focus-green-dim);
  border-color: var(--focus-green-edge);
  color: var(--ink);
}

.btn-secondary.full-width { width: 100%; justify-content: center; margin-bottom: 0.8rem; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── App Shell ───────────────────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* Mobile: dim content when menu open */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 1024px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 95;
    background: rgba(6, 12, 20, 0.52);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  [data-theme="light"] .sidebar-backdrop {
    background: rgba(15, 23, 42, 0.35);
  }
}

@media (min-width: 1025px) {
  .app.sidebar-collapsed .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 95;
    background: rgba(6, 12, 20, 0.52);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .app.sidebar-collapsed .sidebar-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  html[data-theme="light"] .app.sidebar-collapsed .sidebar-backdrop {
    background: rgba(15, 23, 42, 0.35);
  }

  .app.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w) - 8px));
    box-shadow: none;
  }

  .app.sidebar-collapsed .sidebar.open {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  }

  .app.sidebar-collapsed .content-area {
    margin-left: 0;
  }
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--bg2) 0%, color-mix(in srgb, var(--bg2) 92%, var(--focus-green) 8%) 100%);
  border-right: 1px solid var(--border);
  box-shadow: inset 3px 0 0 0 var(--focus-green-edge);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-text {
  font-size: clamp(1.12rem, 2.8vw, 1.35rem);
  font-weight: 800;
  color: var(--brand-blue);
  letter-spacing: -0.02em;
  min-width: 0;
  flex: 1;
}

.sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--ink2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--trans), color var(--trans);
}

.sidebar-close-btn:hover {
  background: var(--focus-green-dim);
  color: var(--ink);
}

.sidebar-close-btn .material-symbols-outlined {
  font-size: 1.35rem;
}

@media (max-width: 1024px) {
  .sidebar-close-btn {
    display: inline-flex;
  }
}

.sidebar-pin-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: calc(100% - 1.4rem);
  margin: 0.35rem 0.7rem 0.85rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink2);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--trans), border-color var(--trans), color var(--trans);
}

.sidebar-pin-btn:hover {
  background: var(--focus-green-dim);
  border-color: var(--focus-green-edge);
  color: var(--ink);
}

.sidebar-pin-btn .material-symbols-outlined {
  font-size: 1.15rem;
}

@media (min-width: 1025px) {
  .sidebar-pin-btn {
    display: inline-flex;
  }
}

.sidebar-nav {
  flex: 1;
  padding: 0.8rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.72rem 0.9rem;
  min-height: 48px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink2);
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
  background: var(--focus-green-dim);
  color: var(--ink);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--focus-green-dim), var(--yellow-dim));
  color: var(--focus-green);
  border: 1px solid var(--focus-green-edge);
  box-shadow: inset 3px 0 0 var(--spot-amber);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.35rem;
  width: 1.5rem;
  flex-shrink: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  opacity: 0.92;
}

.signout-btn .nav-icon {
  font-size: 1.25rem;
}

.menu-icon {
  font-size: 1.35rem;
  color: var(--ink);
}

.sidebar-footer {
  padding: 0.7rem;
  border-top: 1px solid var(--border);
}

.signout-btn { color: var(--ink3); }
.signout-btn:hover { background: rgba(239,68,68,0.1); color: var(--danger); }

/* ─── Content Area ────────────────────────────────────────────────────────── */
.content-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ─── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  min-height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 0 var(--focus-green-dim), 0 3px 0 0 var(--yellow-dim);
  display: flex;
  align-items: center;
  padding: 0.5rem max(1rem, env(safe-area-inset-right)) 0.5rem max(1rem, env(safe-area-inset-left));
  gap: 0.75rem;
  position: sticky; top: 0;
  z-index: 50;
  padding-top: max(0.5rem, env(safe-area-inset-top));
}

.mobile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--focus-green-dim);
  color: var(--ink);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.45rem 0.55rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--focus-green-edge);
  -webkit-tap-highlight-color: transparent;
  transition: background var(--trans), transform 0.15s ease;
}

.mobile-menu-btn:active {
  transform: scale(0.96);
}

.mobile-menu-btn[aria-expanded="true"] {
  border-color: var(--yellow-edge);
  background: linear-gradient(145deg, var(--yellow-dim), var(--focus-green-dim));
  box-shadow: 0 0 0 2px var(--yellow-dim);
}

.mobile-menu-btn[aria-expanded="true"] .menu-icon {
  color: var(--spot-amber);
}

.topbar-title {
  flex: 1;
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.75rem 0.35rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--focus-green-edge);
  border-radius: 999px;
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--focus-green), #0d9488);
  color: #06281f;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-theme="light"] .avatar {
  color: #fff;
}

.user-name {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink2);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: clamp(1rem, 3.5vw, 2rem) clamp(1rem, 4vw, 2.25rem);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  max-width: var(--content-max);
  width: 100%;
  margin-inline: auto;
}

/* ─── Page Routing ────────────────────────────────────────────────────────── */
.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }

/* ─── Page Header ─────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  letter-spacing: -0.02em;
}
.page-header h2::after {
  content: '';
  display: block;
  width: 3.25rem;
  height: 5px;
  margin-top: 0.5rem;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--spot-amber), var(--focus-green), var(--spot-amber));
}
.page-sub {
  color: var(--ink3);
  font-size: 1rem;
  line-height: 1.55;
  max-width: 52ch;
}

/* ─── Dashboard ───────────────────────────────────────────────────────────── */
.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  padding: clamp(1.2rem, 4vw, 1.75rem) clamp(1.2rem, 4vw, 1.85rem);
  margin-bottom: 1.4rem;
  background: linear-gradient(135deg, var(--focus-green-dim), var(--calm-blue-dim));
  border-color: var(--focus-green-edge);
}

.welcome-text {
  flex: 1 1 220px;
  min-width: 0;
}

.welcome-hint {
  margin-top: 0.55rem;
  font-size: 0.92rem;
  color: var(--ink2);
  line-height: 1.5;
  max-width: 36rem;
  border-left: 3px solid var(--spot-amber);
  padding: 0.35rem 0 0.35rem 0.85rem;
  background: linear-gradient(90deg, var(--focus-green-dim), transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.welcome-banner h2 {
  font-size: 1.55rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.welcome-banner p { color: var(--ink3); font-size: 0.98rem; line-height: 1.55; }

.welcome-summary-line {
  margin-top: 0.25rem;
  font-size: 0.94rem;
  color: var(--ink2);
  line-height: 1.5;
  max-width: 44rem;
}
.welcome-decor-icon {
  font-size: clamp(2.75rem, 10vw, 3.75rem);
  line-height: 1;
  color: var(--focus-green);
  opacity: 0.9;
  filter: drop-shadow(0 2px 10px var(--green-glow));
  flex-shrink: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 158px), 1fr));
  gap: clamp(0.75rem, 2vw, 1.1rem);
  margin-bottom: 1.4rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.05rem;
  border: 1px solid color-mix(in srgb, var(--border) 80%, var(--focus-green) 20%);
  transition: transform var(--trans), box-shadow var(--trans), border-color var(--trans);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16), 0 0 0 1px var(--focus-green-dim);
  border-color: var(--focus-green-edge);
}

.dashboard-attempt-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.dashboard-attempt-link .material-symbols-outlined { font-size: 1.2rem; }

.stat-card.link-card { cursor: pointer; text-align: left; }
.stat-card.link-card:focus-visible {
  outline: 2px solid var(--focus-green);
  outline-offset: 3px;
}

.stat-icon {
  font-size: 1.85rem;
  flex-shrink: 0;
  color: var(--focus-green);
  opacity: 0.95;
}
.stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}

#statAttempts { color: var(--focus-green) !important; }
.stat-label {
  font-size: 0.82rem;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dashboard-gamification-stack {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2.5vw, 1.35rem);
  margin-bottom: 0.5rem;
}

.dashboard-notification-widget { position: relative; width: fit-content; margin-bottom: 1.4rem; }
.notification-bell {
  position: relative; display: grid; place-items: center; width: 46px; height: 46px;
  border: 1px solid var(--border); border-radius: 50%; background: var(--bg2);
  color: var(--ink); cursor: pointer;
}
.notification-bell:hover, .notification-bell:focus-visible { border-color: var(--focus-green); color: var(--focus-green); }
.notification-unread-dot { position: absolute; right: 8px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--focus-green); }
.dashboard-notifications {
  position: absolute; z-index: 12; top: 100%; left: 0;
  width: min(390px, calc(100vw - 2.5rem)); max-height: min(70vh, 560px);
  overflow-y: auto; padding: 1.15rem; background: var(--bg2);
}
.dashboard-notifications-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.65rem; }
.notification-close { display: grid; place-items: center; border: 0; background: transparent; color: var(--ink2); cursor: pointer; }
.notification-close:hover, .notification-close:focus-visible { color: var(--focus-green); }
.summary-notice { border-top: 1px solid var(--border); padding: 0.8rem 0; }
.summary-notice--unread { border-left: 3px solid var(--focus-green); padding-left: 0.85rem; }
.summary-notice h4 { font-size: 0.95rem; margin-bottom: 0.3rem; }
.summary-notice p { color: var(--ink2); font-size: 0.9rem; }
.summary-read-button { margin-top: 0.4rem; border: 0; background: transparent; color: var(--focus-green); cursor: pointer; font: inherit; font-size: 0.85rem; }

.gamification-brain-card,
.gamification-badges-card {
  padding: clamp(1rem, 3vw, 1.35rem);
  min-width: 0;
  width: 100%;
}

.gamification-brain-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.gamification-brain-card h3 {
  font-size: 1.12rem;
  font-weight: 650;
  margin-bottom: 0.25rem;
}

.synaptic-map-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.heading-brain-emoji {
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.gamification-brain-sub {
  font-size: 0.88rem;
  color: var(--ink2);
  line-height: 1.5;
  max-width: 42rem;
}

.synapse-stat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.synapse-pill {
  font-size: 0.78rem;
  color: var(--ink2);
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--calm-blue-dim) 55%, transparent);
}

.synapse-pill strong {
  color: var(--focus-green);
  font-weight: 700;
}

.synapse-svg-wrap {
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 60% 60% at 48% 44%, rgba(30, 80, 180, 0.12) 0%, transparent 65%),
    radial-gradient(ellipse 40% 50% at 75% 70%, rgba(30, 60, 160, 0.08) 0%, transparent 60%),
    color-mix(in srgb, var(--bg) 94%, #0a1228);
  border: 1px solid var(--border);
  overflow: hidden;
  width: 100%;
  height: min(62vh, 640px);
  min-height: 320px;
}

.synapse-brain-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brain-silhouette-fill {
  fill: rgba(18, 60, 148, 0.28);
  stroke: none;
  pointer-events: none;
}

.brain-silhouette-stroke {
  stroke: #3a8cf0;
  stroke-width: 0.72;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
  opacity: 0.9;
}

.brain-sulcus {
  stroke: #3580e0;
  stroke-width: 0.3;
  stroke-linecap: round;
  opacity: 0.38;
  pointer-events: none;
}

.brain-sulcus--cereb {
  stroke-width: 0.24;
  opacity: 0.5;
}

.brain-fissure {
  stroke: #4a9ef5;
  stroke-width: 0.55;
  stroke-linecap: round;
  opacity: 0.55;
  pointer-events: none;
}

[data-theme="light"] .brain-silhouette-fill {
  fill: rgba(40, 100, 200, 0.14);
}

[data-theme="light"] .brain-silhouette-stroke {
  stroke: #2a6cc8;
  opacity: 0.7;
}

[data-theme="light"] .brain-sulcus {
  stroke: #2868c0;
  opacity: 0.35;
}

[data-theme="light"] .brain-fissure {
  stroke: #3070d0;
  opacity: 0.45;
}

.synapse-edge {
  stroke: #3a8cf0;
  fill: none;
  stroke-linecap: round;
}

.synapse-node {
  transition: opacity 0.35s ease, r 0.35s ease;
}

.synapse-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-top: 0.65rem;
  font-size: 0.78rem;
  color: var(--ink3);
}

.synapse-legend-swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.synapse-legend-swatch--dim { background: rgb(40, 90, 180); opacity: 0.55; }
.synapse-legend-swatch--mid { background: rgb(60, 160, 255); }
.synapse-legend-swatch--hot { background: rgb(160, 230, 255); }

.gamification-badges-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.gamification-badges-head h3 {
  font-size: 1.12rem;
  font-weight: 650;
}

.badge-progress {
  font-size: 0.85rem;
  color: var(--ink2);
  font-weight: 600;
}

.achievement-badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: 0.75rem;
  padding-right: 0.1rem;
}

.badges-empty {
  font-size: 0.9rem;
  color: var(--ink2);
  padding: 0.5rem 0;
}

.achievement-badge {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  text-align: left;
  transition: border-color var(--trans), box-shadow var(--trans), transform var(--trans);
}

.achievement-badge--locked {
  opacity: 0.48;
  filter: grayscale(0.35);
}

.achievement-badge--earned {
  border-color: var(--focus-green-edge);
  box-shadow: 0 0 0 1px var(--focus-green-dim);
  background: linear-gradient(145deg, var(--focus-green-dim), color-mix(in srgb, var(--surface) 80%, transparent));
}

.achievement-badge--earned:hover {
  transform: translateY(-1px);
}

.achievement-badge-icon {
  font-size: 1.65rem !important;
  color: var(--spot-amber);
  line-height: 1;
}

.achievement-badge--earned .achievement-badge-icon {
  color: var(--focus-green);
}

.achievement-badge-title {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.25;
}

.achievement-badge-desc {
  font-size: 0.72rem;
  color: var(--ink3);
  line-height: 1.4;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: clamp(0.75rem, 2vw, 1rem);
}

.action-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.05rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--focus-green);
  font-family: var(--font);
  color: var(--ink);
  cursor: pointer;
  transition: all var(--trans);
  text-align: left;
  border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
}

.action-card:hover {
  background: var(--focus-green-dim);
  transform: translateX(4px);
  border-color: var(--focus-green-edge);
  box-shadow: 0 6px 24px var(--green-glow);
}

.action-card:active {
  transform: translateX(2px);
}

.action-icon {
  font-size: 1.45rem;
  color: var(--focus-green);
  flex-shrink: 0;
}

.action-label { flex: 1; font-weight: 600; font-size: 1.02rem; }

.action-arrow {
  color: var(--spot-amber);
  font-size: 1.35rem;
  flex-shrink: 0;
  opacity: 0.95;
}

.attempts-panel {
  margin-top: 1.2rem;
  padding: clamp(1.1rem, 3vw, 1.7rem);
  border-top: 4px solid var(--focus-green);
  border-radius: var(--radius);
}

.attempts-head {
  margin-bottom: 0.8rem;
}

.attempts-head h3 {
  font-size: 1.12rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--focus-green);
}

.attempts-empty {
  color: var(--ink3);
  font-size: 0.9rem;
}

.attempt-group + .attempt-group {
  border-top: 1px solid var(--border);
  margin-top: 1.8rem;
  padding-top: 1.8rem;
}

.attempt-group-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.attempt-group-head h4 { font-size: 1rem; margin: 0 0 0.25rem; }
.attempt-group-head p { color: var(--ink3); font-size: 0.85rem; margin: 0; }

.attempt-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.8rem;
  background: var(--surface);
  overflow: hidden;
}

.attempt-card > summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.88rem;
  font-weight: 600;
  flex-wrap: wrap;
}

/* Keep sign-in narrow while giving the signup form room for paired inputs. */
.auth-card:has(#panel-signup.active) { max-width: 700px; }
.signup-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
.signup-field-grid > .field-group { min-width: 0; }
.signup-field-grid .field-input, .signup-school-fields .field-input { width: 100%; min-width: 0; }
.signup-school-fields { display: block; }
.signup-school-fields .field-group { margin-bottom: .5rem; }
#panel-signup .signup-legal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 620px) {
  .auth-card:has(#panel-signup.active) { max-width: 420px; }
  .signup-field-grid, #panel-signup .signup-legal { grid-template-columns: minmax(0, 1fr); }
}
.signup-legal { display: grid; gap: .65rem; margin: 1rem 0; font-size: .85rem; line-height: 1.45; }
.signup-legal .signup-consent { display: grid; grid-template-columns: 20px minmax(0,1fr); align-items: start; gap: .7rem; padding: .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.signup-legal .signup-consent:focus-within { border-color: var(--focus-green); }
.signup-legal input { width: 18px; height: 18px; margin: .08rem 0 0; accent-color: var(--focus-green); }
.signup-legal .signup-consent span { min-width: 0; }
.signup-legal a { color: var(--focus-green); text-decoration: underline; }
.password-rules { list-style: none; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .3rem .65rem; margin-top: .55rem; color: var(--ink2); font-size: .78rem; }
.password-rules li::before { content: '○'; margin-right: .35rem; }
.password-rules li.valid { color: var(--focus-green); }
.password-rules li.valid::before { content: '✓'; }
.password-validation { margin-top: .45rem; color: var(--danger); font-size: .8rem; }
.password-validation.valid { color: var(--focus-green); }
.welcome-modal { position: fixed; inset: 0; z-index: 1200; display: flex; justify-content: center; align-items: center; padding: 1rem; background: rgba(2,8,17,.73); }
.welcome-dialog { position: relative; width: min(100%,490px); padding: clamp(1.5rem,4vw,2.2rem); border-radius: var(--radius); box-shadow: 0 22px 70px rgba(0,0,0,.38); }
.welcome-dialog h2 { margin: .45rem 0 .7rem; }
.welcome-dialog p { color: var(--ink2); line-height: 1.5; }
.welcome-icon { font-size: 2.2rem; color: var(--focus-green); }
.welcome-close { position: absolute; top: .7rem; right: .7rem; border: 0; background: transparent; color: var(--ink2); min-width: 44px; min-height: 44px; cursor: pointer; }
/* A translucent glass panel over the dark scrim makes light-mode blue text
   unreadable. Give only the welcome dialog an opaque, accessible light surface. */
html[data-theme="light"] .welcome-modal { background: rgba(7, 20, 47, .58); }
html[data-theme="light"] .welcome-dialog {
  background: #fff;
  border-color: rgba(14, 33, 160, .22);
  color: #0e21a0;
  box-shadow: 0 24px 68px rgba(7, 20, 47, .28);
}
html[data-theme="light"] .welcome-dialog h2 { color: #0e21a0; }
html[data-theme="light"] .welcome-dialog p { color: #303b7b; }
html[data-theme="light"] .welcome-dialog .welcome-close { color: #303b7b; }
html[data-theme="light"] .welcome-dialog .btn-secondary {
  background: #eef2ff;
  border-color: #b5c2e9;
  color: #0e21a0;
}
html[data-theme="light"] .welcome-dialog .btn-primary {
  background: #b84305;
  color: #fff;
}
.welcome-actions, .result-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1.1rem; }
.welcome-actions > button, .result-actions > button { flex: 1 1 140px; }
.feedback-form { padding: clamp(1rem, 3vw, 1.5rem); display: grid; gap: 1rem; width: 100%; max-width: none; min-width: 0; box-sizing: border-box; }
#page-feedback { width: 100%; min-width: 0; }
#page-feedback .feedback-form .field-group { min-width: 0; }
.feedback-ratings { border: 1px solid var(--border); border-radius: var(--radius-sm); display: grid; gap: .8rem; padding: 1rem; min-width: 0; }
.feedback-ratings legend { color: var(--ink2); padding: 0 .4rem; }
.feedback-ratings label { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.feedback-ratings select { width: min(160px, 100%); }
.feedback-form textarea { resize: vertical; width: 100%; box-sizing: border-box; }
#feedbackStatus { min-height: 1.3em; margin: 0; color: var(--focus-green); }
@media (max-width: 600px) {
  .password-rules { grid-template-columns: 1fr; }
  .feedback-ratings label { align-items: stretch; flex-direction: column; gap: .35rem; }
  .feedback-ratings select { width: 100%; }
  .attempt-group-head { flex-wrap: wrap; }
}

.attempt-card > summary::-webkit-details-marker {
  display: none;
}

.attempt-card[open] > summary {
  border-bottom: 1px solid var(--border);
}

.attempt-questions {
  padding: 0.8rem;
}

.attempt-question {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.7rem;
}

.attempt-question.correct { border-left-color: var(--success); }
.attempt-question.incorrect { border-left-color: var(--danger); }

.attempt-q-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ink3);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.attempt-q-text {
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
  font-weight: 500;
}

.attempt-options {
  margin: 0 0 0.45rem 0;
  padding-left: 1rem;
  font-size: 0.88rem;
}

.attempt-opt {
  margin-bottom: 0.2rem;
}

.attempt-opt.selected {
  color: var(--accent);
}

.attempt-opt.correct {
  color: var(--success);
  font-weight: 600;
}

.attempt-ans {
  font-size: 0.84rem;
  color: var(--ink2);
  margin-bottom: 0.2rem;
}

.attempt-exp {
  font-size: 0.83rem;
  color: var(--ink3);
  margin-top: 0.35rem;
}

/* ─── Quiz ────────────────────────────────────────────────────────────────── */
#quiz-landing { margin-bottom: 1.4rem; }
#quiz-landing h2 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.35rem; }
#quiz-landing p {
  color: var(--ink3);
  font-size: 1rem;
  line-height: 1.55;
  margin-bottom: 1.2rem;
}

.quiz-progress-bar-wrap {
  height: 6px;
  background: var(--focus-green-dim);
  border-radius: 6px;
  margin-bottom: 1.4rem;
  overflow: hidden;
  border: 1px solid var(--focus-green-edge);
}

.quiz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--focus-green), var(--spot-amber), var(--primary));
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.quiz-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--focus-green-edge);
  border-radius: var(--radius-sm);
  background: var(--focus-green-dim);
  color: var(--ink2);
  font-size: 0.9rem;
  font-weight: 600;
}

.quiz-timer .material-symbols-outlined {
  font-size: 1.1rem;
  color: var(--focus-green);
}

.quiz-timer strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.quiz-timer.warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.10);
}

.quiz-timer.warning .material-symbols-outlined,
.quiz-timer.warning strong {
  color: var(--spot-amber);
}

.quiz-timer.danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.10);
}

.quiz-timer.danger .material-symbols-outlined,
.quiz-timer.danger strong {
  color: #fca5a5;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 3px solid var(--focus-green-edge);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1rem;
  transition: all var(--trans);
}

.question-card:hover {
  border-color: var(--focus-green-edge);
  box-shadow: 0 0 0 1px var(--focus-green-dim);
}

.question-card.question-needs-answer {
  border-color: rgba(239, 68, 68, 0.65);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.14);
}

.question-num {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--spot-amber);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.question-text {
  font-size: 1.07rem;
  font-weight: 500;
  line-height: 1.58;
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
}

.question-figure {
  margin: 0 0 1rem;
  text-align: center;
}

.question-figure figcaption { font-size: 0.85rem; color: var(--ink2); padding: 0.75rem; }
.question-figure img {
  display: inline-block;
  max-width: 100%;
  height: auto;
  max-height: min(360px, 50vh);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 55%, var(--bg2));
  object-fit: contain;
}

.choice-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--trans);
  position: relative;
}

.choice-label:hover {
  background: var(--focus-green-dim);
  border-color: var(--focus-green-edge);
}

.choice-label input[type="radio"] { display: none; }

.choice-marker {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all var(--trans);
  color: var(--ink3);
}

.choice-label:has(input:checked) {
  background: color-mix(in srgb, var(--focus-green-dim) 70%, var(--calm-blue-dim));
  border-color: var(--focus-green);
}

.choice-label:has(input:checked) .choice-marker {
  background: var(--focus-green);
  border-color: var(--focus-green);
  color: #06281f;
}

[data-theme="light"] .choice-label:has(input:checked) .choice-marker {
  color: #fff;
}

.quiz-submit-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Results */
.results-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 2rem;
  margin-bottom: 1.4rem;
}

.score-ring-wrap {
  position: relative;
  width: 120px; height: 120px;
  flex-shrink: 0;
}

.score-ring { width: 120px; height: 120px; transform: rotate(-90deg); }

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dasharray 1s cubic-bezier(0.22,1,0.36,1);
}

.score-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-pct { font-size: 1.55rem; font-weight: 700; }
.score-sub { font-size: 0.82rem; color: var(--ink3); }

.results-meta h2 { margin-bottom: 0.3rem; }
.results-meta p { color: var(--ink3); font-size: 0.9rem; margin-bottom: 1rem; }

.review-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin-bottom: 0.9rem;
}

.review-card.correct { border-left-color: var(--success); }
.review-card.incorrect { border-left-color: var(--danger); }

.review-status {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.review-card.correct .review-status { color: var(--success); }
.review-card.incorrect .review-status { color: var(--danger); }

.review-question {
  font-weight: 500;
  margin-bottom: 0.6rem;
  line-height: 1.5;
  font-size: 1.02rem;
}
.review-answer { font-size: 0.95rem; color: var(--ink2); margin-bottom: 0.3rem; }
.review-explanation { font-size: 0.92rem; color: var(--ink3); margin-top: 0.5rem; }

/* ─── Guidance ────────────────────────────────────────────────────────────── */
.guidance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.4rem 0 1rem;
}

.guidance-controls {
  max-width: 380px;
  margin: 0.8rem 0 0.4rem;
}

.guidance-card {
  padding: 1.4rem 1.5rem;
  border-left: 4px solid var(--focus-green);
}

.guidance-card h3 {
  font-size: 1.08rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--focus-green);
}

.guidance-card .card-hint {
  font-size: 0.82rem;
  color: var(--ink3);
  margin: 0 0 0.85rem;
  line-height: 1.4;
}

#guidanceTrend h3 {
  margin-bottom: 0.75rem;
}

.guidance-summary {
  margin-bottom: 0.9rem;
}

.guidance-summary-p {
  font-size: 0.88rem;
  color: var(--ink2);
  margin: 0 0 0.5rem;
  line-height: 1.45;
}

.guidance-summary-p:last-child {
  margin-bottom: 0;
}

.trend-label { font-size: 0.82rem; color: var(--ink3); margin-top: 0.5rem; }

.topic-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }

.topic-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.5rem 0.7rem;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.18);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.topic-rank {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--danger);
  width: 1.1rem;
  flex-shrink: 0;
  line-height: 1.35;
}

.topic-item-text {
  flex: 1;
  min-width: 0;
}

.topic-line {
  line-height: 1.35;
}

.topic-meta {
  font-size: 0.8rem;
  color: var(--ink3);
  margin-top: 0.25rem;
}

.topic-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex-shrink: 0; margin-top: 0.28rem; }

.notes-list { list-style: none; display: flex; flex-direction: column; gap: 0.65rem; }

.note-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--focus-green-dim);
  border: 1px solid var(--focus-green-edge);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.45;
}

.note-item-icon {
  flex-shrink: 0;
  font-size: 1.35rem;
  color: var(--focus-green);
  margin-top: 0.1rem;
}

.reco-body {
  flex: 1;
  min-width: 0;
}

.note-item.reco-item {
  align-items: flex-start;
}

.reco-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.35rem;
}

.reco-pill {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--yellow-edge);
  background: var(--yellow-dim);
  color: var(--ink2);
  white-space: nowrap;
}

.reco-meta {
  font-size: 0.83rem;
  color: var(--ink2);
  margin-bottom: 0.25rem;
}

.reco-path {
  font-size: 0.82rem;
  color: var(--ink3);
}

.reco-actions {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.85rem;
  color: var(--ink2);
  line-height: 1.45;
}

.reco-tip {
  font-size: 0.83rem;
  color: var(--ink3);
  margin-top: 0.2rem;
}

.reco-fallback {
  font-size: 0.83rem;
  color: var(--ink3);
  margin: 0.25rem 0 0;
  line-height: 1.4;
}

.chapter-guidance-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.chapter-topic {
  border: 1px solid var(--border);
  border-left: 4px solid var(--focus-green-edge);
  background: linear-gradient(90deg, var(--focus-green-dim), var(--surface));
  border-radius: var(--radius-sm);
  padding: 0.9rem;
}

.chapter-topic-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.chapter-topic-sub {
  font-size: 0.78rem;
  color: var(--ink3);
  margin-bottom: 0.55rem;
  line-height: 1.35;
}

.chapter-strand {
  font-size: 0.84rem;
  margin-bottom: 0.4rem;
  color: var(--ink2);
}

.chapter-path {
  font-size: 0.84rem;
  color: var(--ink3);
}

/* ─── Settings ────────────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}

.settings-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-left: 3px solid var(--focus-green-edge);
  transition: box-shadow var(--trans), border-color var(--trans);
}

.settings-card:hover {
  border-left-color: var(--focus-green);
  box-shadow: 0 8px 28px var(--green-glow);
}

.settings-card h3 {
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--focus-green);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.98rem;
  color: var(--ink2);
}

.field-help {
  margin-top: 0.45rem;
  color: var(--ink3);
  font-size: 0.82rem;
  line-height: 1.45;
}

.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { display: none; }

.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background var(--trans);
  cursor: pointer;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform var(--trans);
}

.toggle-switch input:checked + .toggle-track {
  background: linear-gradient(90deg, var(--focus-green), var(--spot-amber));
  box-shadow: 0 0 0 1px var(--yellow-dim);
}
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }

.inline-ok {
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 500;
}

.inline-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

/* ─── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── SVG Gradient ────────────────────────────────────────────────────────── */
svg defs { display: block; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --content-max: 100%;
  }

  .content-area {
    max-width: 100%;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w) - 8px));
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  }

  .content-area {
    margin-left: 0;
    width: 100%;
  }

  .main-content {
    padding: 1rem max(1rem, env(safe-area-inset-left)) 1.25rem max(1rem, env(safe-area-inset-right));
  }

  .topbar-title {
    font-size: 1rem;
  }

  .user-name {
    max-width: min(120px, 28vw);
  }

  .welcome-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .welcome-decor-icon {
    align-self: center;
  }

  .guidance-grid {
    grid-template-columns: 1fr;
  }

  .guidance-controls {
    max-width: none;
  }

  .results-header {
    flex-direction: column;
    text-align: center;
    padding: 1.35rem;
    gap: 1.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .quiz-submit-row {
    justify-content: stretch;
  }

  .quiz-submit-row .btn-primary {
    width: 100%;
  }

  #quiz-landing .btn-primary {
    width: 100%;
  }

  .page-header h2 {
    font-size: clamp(1.45rem, 5vw, 1.75rem);
  }

  .auth-card {
    margin-inline: auto;
  }
}

@media (max-width: 480px) {
  .topbar { gap: 0.4rem; padding-inline: 0.65rem; }
  .topbar-title { min-width: 0; font-size: 0.94rem; line-height: 1.2; }
  .user-chip { padding: 0.3rem; }
  .user-name { display: none; }

  .auth-card {
    padding: 1.65rem 1.15rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 1rem 0.95rem;
  }

  .question-card {
    padding: 1.1rem 1rem;
  }

  .choice-label {
    padding: 0.85rem 0.95rem;
    min-height: 48px;
    align-items: center;
  }

  .attempt-card > summary {
    flex-direction: column;
    align-items: flex-start;
    font-size: 0.85rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.practice-hint-banner {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  color: var(--ink2);
  font-size: 0.92rem;
  line-height: 1.5;
  border-left: 4px solid var(--focus-green);
}

.practice-topics-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.practice-topic {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
}

.practice-topic-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.practice-mistakes {
  font-size: 0.78rem;
  color: var(--ink2);
}

.practice-plan {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.practice-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
}

.practice-step-head {
  font-size: 0.83rem;
  color: var(--ink2);
  margin-bottom: 0.35rem;
}

.practice-actions {
  margin-bottom: 0.4rem;
}

.practice-quiz-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.practice-books {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.practice-book {
  font-size: 0.76rem;
  color: var(--ink2);
  background: var(--focus-green-dim);
  border: 1px solid var(--focus-green-edge);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.practice-book-empty {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.08);
}

.practice-tabs-wrap {
  padding: 1rem;
}

.practice-topic-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.practice-tab-btn {
  border: 1px solid var(--focus-green-edge);
  background: var(--focus-green-dim);
  color: var(--ink2);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  min-height: 40px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background var(--trans), border-color var(--trans), color var(--trans);
  -webkit-tap-highlight-color: transparent;
}

.practice-tab-btn:hover {
  border-color: var(--focus-green);
  color: var(--ink);
}

.practice-tab-btn.active {
  border-color: rgba(249, 115, 22, 0.55);
  background: rgba(249, 115, 22, 0.14);
  color: var(--ink);
  font-weight: 600;
}

.practice-topic-panel {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.practice-grade-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
}

.practice-grade-title {
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.practice-subtopic-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.practice-subtopic-btn {
  border: 1px solid var(--focus-green-edge);
  background: var(--focus-green-dim);
  color: var(--ink2);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.65rem;
  min-height: 40px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--trans), border-color var(--trans);
  -webkit-tap-highlight-color: transparent;
}

.practice-subtopic-btn:hover {
  border-color: var(--focus-green);
  color: var(--ink);
}

.practice-subtopic-btn.active {
  border-color: rgba(249, 115, 22, 0.65);
  background: rgba(249, 115, 22, 0.18);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.25) inset;
}


/* Dedicated practice-quiz view and fixed timer */
.floating-quiz-timer {
  position: fixed;
  top: 5.25rem;
  right: 1.5rem;
  z-index: 1200;
  margin: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.practice-quiz-page-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.practice-quiz-page-head .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.practice-batch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}

.practice-batch-head p {
  margin: 0.3rem 0 0;
  color: var(--ink3);
  font-size: 0.86rem;
}

.practice-batch-counter {
  flex: 0 0 auto;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink2);
  font-size: 0.82rem;
  font-weight: 700;
}

.practice-batch-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.practice-batch-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .floating-quiz-timer {
    position: sticky;
    top: calc(var(--topbar-h) + 0.5rem + env(safe-area-inset-top));
    right: auto;
    bottom: auto;
    left: auto;
    width: max-content;
    max-width: 100%;
    margin: 0 0 1rem auto;
    justify-content: center;
    z-index: 40;
  }

  .practice-quiz-page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .practice-batch-head,
  .practice-batch-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .practice-batch-actions button {
    width: 100%;
  }
}

/* ─── Header, sidebar controls & learning notification history ──────────── */
.sidebar-brand .sidebar-pin-btn {
  display: inline-flex;
  width: 42px;
  min-width: 42px;
  height: 42px;
  margin: 0 0 0 auto;
  padding: 0;
  border-radius: 12px;
}
.sidebar-brand .sidebar-pin-btn .sidebar-pin-icon { font-size: 1.45rem; }
.sidebar-brand .sidebar-pin-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (min-width: 1025px) {
  .app:not(.sidebar-collapsed) .mobile-menu-btn { display: none; }
}

.dashboard-attempt-cta {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: clamp(1rem, 2.5vw, 1.4rem);
  margin-bottom: 1.35rem;
  border: 1px solid var(--focus-green-edge);
  border-radius: var(--radius);
  background: linear-gradient(115deg, var(--focus-green-dim), var(--surface));
}
.dashboard-attempt-cta-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--focus-green-dim);
  color: var(--focus-green);
  font-size: 1.8rem;
}
.dashboard-attempt-cta-copy { flex: 1; min-width: 0; }
.dashboard-attempt-cta-copy h3 { font-size: 1.06rem; margin-bottom: 0.25rem; color: var(--ink); }
.dashboard-attempt-cta-copy p { font-size: 0.87rem; line-height: 1.55; color: var(--ink2); }
.dashboard-attempt-cta .dashboard-attempt-link {
  margin: 0;
  flex-shrink: 0;
  justify-content: center;
  white-space: nowrap;
}

.topbar .dashboard-notification-widget { position: relative; flex-shrink: 0; margin: 0; }
.topbar .notification-bell { height: 44px; width: 44px; border-radius: 13px; }
.topbar .dashboard-notifications {
  top: calc(100% + 0.75rem);
  right: 0;
  left: auto;
  width: min(390px, calc(100vw - 1.5rem));
  max-height: min(75vh, 600px);
  padding: 1rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
}
.dashboard-notifications-head { align-items: flex-start; }
.dashboard-notifications-head h3 { font-size: 1rem; }
.dashboard-notifications-head p { margin-top: .2rem; font-size: .76rem; color: var(--ink3); }
.notification-view-all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  margin-top: .7rem;
  padding: .78rem .8rem;
  border: 1px solid var(--focus-green-edge);
  border-radius: 10px;
  background: var(--focus-green-dim);
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.notification-view-all:hover, .notification-view-all:focus-visible { color: var(--focus-green); }
.notification-view-all .material-symbols-outlined { font-size: 1.15rem; }
.notification-history-card { padding: clamp(1rem, 2.5vw, 1.6rem); }
.notification-history-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: .8rem;
  margin-bottom: 1.15rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}
.notification-filter-field { display: grid; gap: .38rem; flex: 1 1 190px; min-width: 0; }
.notification-filter-field label { font-size: .85rem; font-weight: 600; color: var(--ink2); }
.notification-filter-field .field-input { min-width: 0; width: 100%; }
.notification-clear-date { flex-shrink: 0; }
.notification-history-list { display: grid; gap: .75rem; }
.notification-history-list > .summary-notice {
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.notification-history-list > .summary-notice--unread {
  border-left: 3px solid var(--focus-green);
}
.summary-notice h3 { margin: .4rem 0 .3rem; font-size: .95rem; color: var(--ink); }
.summary-notice p { line-height: 1.55; }
.notification-period-tag {
  display: inline-flex;
  width: fit-content;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--focus-green-dim);
  color: var(--focus-green);
  font-size: .72rem;
  font-weight: 700;
}
.summary-notice .notification-period-dates { margin: .15rem 0 .45rem; font-size: .75rem; color: var(--ink3); }
.summary-read-button { display: inline-flex; padding: .35rem 0; font-weight: 600; }
.summary-read-button:disabled { opacity: .5; cursor: wait; }
.notification-read-status { display: inline-block; margin-top: .6rem; font-size: .78rem; color: var(--ink3); }
.notification-history-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-top: 1.2rem;
}
.notification-history-pagination span { font-size: .82rem; color: var(--ink2); text-align: center; }
.notification-history-pagination button:disabled { opacity: .42; cursor: not-allowed; }
@media (max-width: 650px) {
  .dashboard-attempt-cta { flex-wrap: wrap; }
  .dashboard-attempt-cta-copy { flex-basis: calc(100% - 70px); }
  .dashboard-attempt-cta .dashboard-attempt-link { width: 100%; }
  .topbar .dashboard-notifications {
    position: fixed;
    top: calc(var(--topbar-h) + .55rem);
    right: .65rem;
    left: .65rem;
    width: auto;
    max-height: calc(100dvh - var(--topbar-h) - 1.5rem);
  }
  .notification-clear-date { flex: 1 1 100%; }
  .notification-history-pagination .btn-secondary { padding-inline: .6rem; }
}

/* Dashboard refinements: compact rail, score feedback, and attempt-paper titles. */
.sidebar-compact-brand { display: none; }
.sidebar-resize-control {
  padding: .5rem .7rem .65rem;
  border-top: 1px solid var(--border);
}
.sidebar-resize-control .sidebar-pin-btn {
  display: flex;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: .65rem .85rem;
  justify-content: flex-start;
  gap: .75rem;
  border-radius: var(--radius-sm);
}
.sidebar-resize-control .sidebar-pin-btn .sidebar-pin-icon { font-size: 1.45rem; }
.sidebar-resize-control .sidebar-pin-label {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
  overflow: visible;
  white-space: nowrap;
}
.sidebar-resize-control .sidebar-pin-btn:focus-visible,
.result-actions button:focus-visible {
  outline: 2px solid var(--focus-green);
  outline-offset: 3px;
}
@media (min-width: 1025px) {
  .app .mobile-menu-btn { display: none; }
  .app.sidebar-collapsed .sidebar {
    width: 76px;
    transform: translateX(0);
    box-shadow: inset 3px 0 0 var(--focus-green-edge);
  }
  .app.sidebar-collapsed .content-area { margin-left: 76px; }
  .app.sidebar-collapsed .sidebar-brand {
    height: 74px;
    padding: .75rem .5rem;
    justify-content: center;
  }
  .app.sidebar-collapsed .sidebar-brand .neuromath-logo { display: none; }
  .app.sidebar-collapsed .sidebar-compact-brand {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--focus-green-dim);
    border: 1px solid var(--focus-green-edge);
    color: var(--focus-green);
    font-size: 1.25rem;
    font-weight: 800;
  }
  .app.sidebar-collapsed .sidebar-nav,
  .app.sidebar-collapsed .sidebar-footer { padding-inline: .55rem; }
  .app.sidebar-collapsed .sidebar-nav .nav-item,
  .app.sidebar-collapsed .sidebar-footer .nav-item {
    justify-content: center;
    padding-inline: .4rem;
  }
  .app.sidebar-collapsed .sidebar .nav-label,
  .app.sidebar-collapsed .sidebar-resize-control .sidebar-pin-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
  }
  .app.sidebar-collapsed .sidebar-resize-control { padding-inline: .55rem; }
  .app.sidebar-collapsed .sidebar-resize-control .sidebar-pin-btn {
    justify-content: center;
    padding-inline: .25rem;
  }
}

.attempt-paper-info { display: grid; gap: .3rem; min-width: 0; }
.attempt-paper-title { color: var(--ink); line-height: 1.35; overflow-wrap: anywhere; }
.attempt-paper-date { color: var(--ink3); font-size: .78rem; font-weight: 400; }
.attempt-paper-score {
  flex-shrink: 0;
  align-self: center;
  padding: .35rem .65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink);
  background: var(--bg2);
  font-size: .84rem;
  font-variant-numeric: tabular-nums;
}
.attempt-card > summary { align-items: center; }
.attempt-card > summary:hover { background: var(--surface-hover); }

.result-score-card {
  --score-accent: var(--focus-green);
  position: relative;
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: center;
  padding: clamp(1.35rem, 3vw, 2rem);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--score-accent) 38%, var(--border));
  background: radial-gradient(ellipse at 0% 10%, color-mix(in srgb, var(--score-accent) 13%, transparent), transparent 63%), var(--surface);
  transition: border-color .25s ease;
}
.result-score-card[data-tier="poor"] { --score-accent: #e88c76; }
.result-score-card[data-tier="not-bad"] { --score-accent: #dca85d; }
.result-score-card[data-tier="good"] { --score-accent: #55b6bf; }
.result-score-card[data-tier="amazing"] { --score-accent: #7c9cf6; }
.result-score-card[data-tier="excellent"] { --score-accent: #38ce98; }
.result-score-card .score-ring-wrap {
  width: 136px;
  height: 136px;
  justify-self: center;
}
.result-score-card .score-ring { width: 136px; height: 136px; }
.result-score-card .ring-fill { stroke: var(--score-accent); }
.result-score-card .score-pct { font-size: 1.65rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.result-score-card .results-meta { min-width: 0; }
.result-score-card .results-meta h2 {
  margin: .45rem 0;
  color: var(--ink);
  font-size: clamp(1.45rem, 2.5vw, 1.9rem);
}
.result-score-card .results-meta p { margin-bottom: 0; line-height: 1.5; }
.result-score-card .result-score-detail { margin-top: .4rem; color: var(--ink2); font-weight: 600; }
.result-tier-label {
  display: inline-flex;
  align-items: center;
  padding: .38rem .8rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--score-accent) 45%, var(--border));
  color: var(--score-accent);
  background: color-mix(in srgb, var(--score-accent) 11%, transparent);
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .02em;
}
.result-score-card .result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: .75rem;
  width: 100%;
  margin-top: 1.45rem;
}
.result-score-card .result-actions > button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .48rem;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  margin: 0;
  padding: .66rem .7rem;
  font-size: .88rem;
  white-space: nowrap;
}
.result-score-card .result-actions .material-symbols-outlined { font-size: 1.15rem; }
.result-mood {
  position: absolute;
  top: .8rem;
  right: 1.25rem;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--score-accent);
  pointer-events: none;
}
.result-mood-icon { font-size: 2.2rem; line-height: 1; transform-origin: 50% 60%; }
.result-mood-spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--score-accent);
  opacity: 0;
}
.result-mood-spark--one { top: 0; left: 0; }
.result-mood-spark--two { top: -7px; right: -5px; }
.result-mood-spark--three { bottom: 0; right: -8px; }
@keyframes result-poor-sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes result-not-bad-breathe { 0%, 100% { transform: scale(1); opacity: .75; } 50% { transform: scale(1.12); opacity: 1; } }
@keyframes result-good-lift { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes result-amazing-twinkle { 0%, 100% { transform: scale(.9) rotate(-10deg); } 50% { transform: scale(1.22) rotate(15deg); } }
@keyframes result-excellent-pop { 0% { transform: scale(.5); opacity: .35; } 55% { transform: scale(1.35); opacity: 1; } 80% { transform: scale(.92); } 100% { transform: scale(1); opacity: 1; } }
@keyframes result-sparkle { 0%, 100% { opacity: 0; transform: translateY(5px) scale(.5); } 35%, 65% { opacity: 1; transform: translateY(-10px) scale(1.4); } }
@media (prefers-reduced-motion: no-preference) {
  .result-score-card.result-animate[data-tier="poor"] .result-mood-icon { animation: result-poor-sway 1.8s ease-in-out 2; }
  .result-score-card.result-animate[data-tier="not-bad"] .result-mood-icon { animation: result-not-bad-breathe 1.3s ease-in-out 3; }
  .result-score-card.result-animate[data-tier="good"] .result-mood-icon { animation: result-good-lift .9s ease-in-out 3; }
  .result-score-card.result-animate[data-tier="amazing"] .result-mood-icon { animation: result-amazing-twinkle .85s ease-in-out 3; }
  .result-score-card.result-animate[data-tier="excellent"] .result-mood-icon { animation: result-excellent-pop .9s cubic-bezier(.2,.9,.35,1.1) both; }
  .result-score-card.result-animate:is([data-tier="amazing"],[data-tier="excellent"]) .result-mood-spark {
    animation: result-sparkle 1.2s ease-in-out 2;
  }
  .result-score-card.result-animate .result-mood-spark--two { animation-delay: .15s; }
  .result-score-card.result-animate .result-mood-spark--three { animation-delay: .3s; }
}
@media (prefers-reduced-motion: reduce) {
  .result-score-card .ring-fill { transition: none; }
}
@media (max-width: 780px) {
  .result-score-card { grid-template-columns: 1fr; text-align: center; }
  .result-score-card .result-mood { top: .6rem; right: .65rem; }
  .result-score-card .result-actions { gap: .55rem; }
}
@media (max-width: 540px) {
  .result-score-card .result-actions { grid-template-columns: 1fr; }
  .attempt-card > summary { align-items: flex-start; }
  .attempt-paper-score { align-self: flex-start; }
}

/* Recommended practice entry points: align the action with the topic label. */
.reco-item .reco-body { min-width: 0; }
.guidance-practice-btn {
  min-height: 40px;
  padding: .5rem .85rem;
  margin: .7rem 0 .2rem;
  gap: .4rem;
  font-size: .88rem;
  border-radius: 9px;
}
.guidance-practice-btn .material-symbols-outlined { font-size: 1.15rem; }
.guidance-practice-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* Expanded attempt scores reuse the five animated results tiers. */
.attempt-paper-body { padding: .95rem; }
/* When accordion items above collapse, keep the newly opened paper visible. */
.attempt-card { scroll-margin-top: 6rem; }
.attempt-result-score {
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  grid-template-columns: 138px minmax(0, 1fr);
}
.attempt-result-score .results-meta { padding-right: 1.7rem; }
.attempt-result-score .result-score-detail { margin-top: .65rem; }
.attempt-paper-body .attempt-questions { padding: 0; }
@media (max-width: 700px) {
  .attempt-result-score { grid-template-columns: 1fr; text-align: center; }
  .attempt-result-score .results-meta { padding-right: 0; }
  .attempt-result-score .result-mood { right: .5rem; }
  .attempt-paper-body { padding: .65rem; }
}

/* Week 3 achievements and challenge actions */
.badge-category { font-size: .7rem; font-weight: 700; letter-spacing: .02em; color: var(--ink2); }
.badge-requirement { font-size: .72rem; color: var(--ink2); }
/* Earned badge actions: compact labelled brand icons, no external icon fonts. */
.badge-share-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; margin-top: auto; padding-top: .25rem; }
.badge-share { display: inline-flex; justify-content: center; align-items: center; min-height: 36px; gap: .25rem; font: inherit; font-size: .67rem; font-weight: 650; line-height: 1.15; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: .35rem .25rem; cursor: pointer; white-space: nowrap; }
.badge-share svg { width: 15px; height: 15px; flex: none; }
.badge-share--linkedin { color: #78b5fa; }
.badge-share--whatsapp { color: #69d7a6; }
.badge-share:hover:not(:disabled) { border-color: var(--focus-green-edge); background: var(--focus-green-dim); }
.badge-share:disabled { opacity: .55; cursor: wait; }
.badge-share:focus-visible, .challenge-actions button:focus-visible, .badge-status-download:focus-visible { outline: 3px solid var(--focus-green); outline-offset: 3px; }
.badge-share-feedback { margin: .5rem 0 .75rem; color: var(--ink2); font-size: .78rem; line-height: 1.5; }
.badge-status-download { display: inline-flex; margin-bottom: .75rem; color: var(--focus-green); font-size: .78rem; text-underline-offset: 3px; }
.badge-status-download[hidden] { display: none; }
.challenge-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.challenge-actions button { padding: .65rem .85rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
.challenge-actions button:disabled { opacity: .5; cursor: not-allowed; }
.question-performance { padding: .5rem .75rem; border-radius: 8px; background: var(--surface); font-size: .82rem; }
