/* ─── 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%;
}

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: center; 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;
  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;
  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;
}

.synapmath-mark-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.synapmath-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-blue);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
  flex-shrink: 0;
}

.synapmath-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.synapmath-logo--auth {
  width: 3.25rem;
  height: 3.75rem;
  margin-bottom: 0.35rem;
}

.synapmath-logo--sidebar {
  width: 1.75rem;
  height: 2.15rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

[data-theme="light"] .synapmath-logo {
  filter: drop-shadow(0 1px 3px rgba(14, 33, 160, 0.14));
}

.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;
}

.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);
}

.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;
}

/* ─── 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);
}

/* Spinner */
.spinner {
  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);
}

.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;
}

.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(1rem, 3vw, 1.35rem);
  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-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;
}

.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%;
}

.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-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 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);
}

.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) {
  .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;
}
