/* styles.css — Atlas shared stylesheet */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,600;12..96,700;12..96,800&family=Figtree:wght@400;500;600;700&display=swap');

/* ── Custom Properties ─────────────────────────────────────────────────────── */
:root {
  --font:         'Figtree', system-ui, sans-serif;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;   /* headings / wordmark */

  --blue:      #4f46e5;   /* brand indigo — AA-verified on white (UX-A11y-004) */
  --green:     #3b82f6;   /* NB: this is the brand indigo-blue, NOT a green hue (UX-A11y-016) */
  --primary:   #3b82f6;   /* correctly-named alias for the brand blue on the line above */
  --amber:     #b45309;   /* a11y: darkened amber for AA text contrast (UX-A11y-003) */
  --red:       #dc2626;   /* a11y: darkened red for AA contrast (UX-A11y-004) */
  --darkgreen: #3b82f6;

  /* Bright-direction additive accents (used by the landing + available app-wide) */
  --brand:        #4f46e5;   /* alias of --blue for design-handoff parity */
  --brand-strong: #3f37c9;   /* hover / strong text on brand */
  --brand-soft:   #eeecfb;   /* soft brand tint for icon tiles, step numbers, focus rings */
  --amber-soft:   #fdf1e3;
  --ok:           #1f9d57;   /* a real success green (AA on white) for correct answers / grades */
  --ok-soft:      #e7f6ed;
  --border2:      #dad8ea;   /* stronger border for secondary buttons / inputs */
  --surface3:     #edecf8;

  --bg:        #fbfbfe;
  --surface:   #ffffff;
  --surface2:  #f4f3fb;
  --border:    #e7e6f1;
  --ring-track:#edecf8;

  --text:      #15161c;   /* neutral ink */
  --text-2:    #4a4d5c;
  --text-muted:#5b5f70;   /* a11y: darkened from design #7c8092 to meet AA (UX-A11y-004) */

  --shadow-sm: 0 2px 8px rgba(30,28,60,.06);
  --shadow:    0 14px 40px -16px rgba(40,32,90,.18);
  --shadow-lg: 0 40px 90px -30px rgba(40,32,90,.32);

  --radius-sm: 12px;
  --radius:    18px;
  --radius-lg: 28px;

  --sidebar-w: 240px;
  --nav-h:     64px;
}

[data-theme="dark"] {
  --bg:        #110e1a;
  --surface:   #1a1528;
  --surface2:  #241e35;
  --surface3:  #2c2540;
  --border:    #352d4a;
  --border2:   #443a5e;
  --ring-track:#352d4a;
  --amber:     #fbbf24;
  --amber-soft:#2e2410;
  --blue:      #6366f1;   /* keep the brighter brand blue/red on dark backgrounds */
  --brand:     #6366f1;
  --brand-strong:#818cf8;
  --brand-soft:#272150;
  --ok:        #34d27b;
  --ok-soft:   #13311f;
  --red:       #ef4444;
  --text:      #f1eef9;
  --text-2:    #a89ec4;
  --text-muted:#8b80aa;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.35);
  --shadow:    0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.55);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  transition: background .25s, color .25s;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Skip Link ─────────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--blue);
  color: white;
  padding: 8px 16px;
  border-radius: 0 0 8px 8px;
  font-size: .875rem;
  font-weight: 600;
  z-index: 9999;
  text-decoration: none;
}
.skip-link:focus { top: 0; outline: none; }

/* Visually-hidden but available to screen readers (UX-A11y-005/007 headings). */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Focus Visible ─────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 3px;
}
:focus:not(:focus-visible) { outline: none; }
/* Inputs use box-shadow for focus — transparent outline ensures High Contrast Mode visibility */
.form-input:focus-visible { outline: 3px solid transparent; box-shadow: 0 0 0 3px var(--blue); }
[data-theme="dark"] :focus-visible { outline-color: #60a5fa; }

/* ── Typography ────────────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -.02em; }
h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.2; text-wrap: pretty; }
h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 700; line-height: 1.4; }
h4 { font-size: .9375rem; font-weight: 600; }
p { font-size: .9375rem; color: var(--text-2); line-height: 1.7; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: background .25s, border-color .25s;
}
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  width: 100%;
  min-width: 0;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar-logo {
  padding: 24px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-img {
  height: 112px;
  width: auto;
  display: block;
}
.sidebar-logo-mark {
  width: 36px; height: 36px;
  background: var(--blue);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.sidebar-logo-text { font-size: 1.0625rem; font-weight: 800; color: var(--text); }
.sidebar-logo-text span { color: var(--amber); }

.sidebar-nav { padding: 16px 12px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: #ede9fe; color: var(--blue); }
[data-theme="dark"] .nav-item.active { background: rgba(99,102,241,.15); }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.user-card {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.user-name { font-weight: 700; font-size: .9375rem; margin-bottom: 2px; }
.user-level { font-size: .75rem; color: var(--text-muted); margin-bottom: 10px; }
.xp-bar-wrap { margin-bottom: 4px; }
.xp-bar-track {
  height: 6px;
  background: var(--border);
  border: 1px solid #9ca3af;
  border-radius: 99px;
  overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--blue);
  transition: width .5s ease;
}
.xp-label { font-size: .6875rem; color: var(--text-muted); margin-top: 4px; display: flex; justify-content: space-between; }

/* Account block (sidebar bottom): avatar + name → profile, with sign out */
.account-card { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.account-card:hover { border-color: var(--blue); background: var(--surface); }
.account-avatar { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: .95rem; display: grid; place-items: center; }
.account-info { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.account-info .user-name { margin-bottom: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-year { font-size: .75rem; color: var(--text-muted); }
.account-gear { flex-shrink: 0; font-size: .85rem; opacity: .55; }
.account-signout { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 8px; padding: 9px 12px;
  border-radius: var(--radius-sm); font-size: .875rem; font-weight: 600; color: var(--text-muted);
  background: none; border: 1px solid transparent; cursor: pointer; transition: background .15s, color .15s; min-height: 44px; }
.account-signout:hover { background: var(--surface2); color: var(--text); }

.sidebar-footer {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}
.streak-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: .8125rem; font-weight: 600; color: var(--amber);
}
.theme-toggle {
  width: 44px; height: 44px;   /* a11y: 44px min touch target (UX-A11y-012) */
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: background .15s;
}
.theme-toggle:hover { background: var(--border); }

/* ── Hamburger Button ──────────────────────────────────────────────────────── */
.hamburger-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 0 9px;
  transition: background .15s;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--border); }
.hamburger-line {
  display: block;
  width: 100%; height: 2px;
  background: var(--text);
  border-radius: 1px;
}

/* ── Sidebar Backdrop (mobile) ─────────────────────────────────────────────── */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* ── Sidebar Close Row (mobile only) ───────────────────────────────────────── */
.sidebar-close-row {
  display: none;
  justify-content: flex-end;
  padding: 10px 12px 0;
  flex-shrink: 0;
}
.sidebar-close-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .875rem;
  color: var(--text);
  cursor: pointer;
  transition: background .15s;
}
.sidebar-close-btn:hover { background: var(--border); }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background .25s, border-color .25s;
}

/* ── Stats Row ─────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ── Subject Filter ────────────────────────────────────────────────────────── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.filter-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--text-2); color: var(--text); }
.filter-btn.active {
  color: white;
  border-color: transparent;
}
.filter-count {
  background: rgba(255,255,255,.25);
  border-radius: 99px;
  padding: 0 6px;
  font-size: .6875rem;
  font-weight: 700;
}

/* ── Unit Grid ───────────────────────────────────────────────────────────── */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.unit-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-top-width: 3px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
  position: relative;
  overflow: hidden;
}
.unit-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.unit-card:active { transform: translateY(-1px); }
.unit-card.locked { opacity: .55; cursor: not-allowed; }
.unit-card.locked:hover { transform: none; box-shadow: var(--shadow-sm); }

.unit-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}
.unit-emoji {
  font-size: 1.875rem;
  line-height: 1;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
  border-radius: 14px;
  flex-shrink: 0;
}
.unit-name { font-size: .9375rem; font-weight: 700; margin-bottom: 4px; line-height: 1.3; }
.unit-order-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface2); color: var(--text-muted);
  font-size: .6875rem; font-weight: 800;
  margin-right: 6px; vertical-align: middle;
}
.start-here-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: .6875rem; font-weight: 700;
  color: white; background: var(--green);
  margin-bottom: 8px;
}
.subject-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .6875rem;
  font-weight: 700;
  color: white;
  margin-bottom: 8px;
}
.unit-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.status-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: .6875rem;
  font-weight: 700;
  background: var(--surface2);
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  pointer-events: none;
}

/* ── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 28px;
}
.page-header h1 { margin-bottom: 4px; }
.page-header p { font-size: .9375rem; }
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.header-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: .8125rem;
  color: var(--text);
  white-space: nowrap;
}
.header-badge strong {
  font-weight: 700;
  font-size: .875rem;
}
.header-badge-icon {
  font-size: .9rem;
}
.header-badge-label {
  color: var(--text-muted);
}

/* ── Hero Banner ──────────────────────────────────────────────────────────── */
.hero-banner {
  --hero-accent: #3b82f6;
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--hero-accent) 5%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--hero-accent) 12%, var(--border));
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
}
.hero-content {
  position: relative;
  z-index: 1;
}
.hero-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: color-mix(in srgb, var(--hero-accent) 70%, var(--text));
  background: color-mix(in srgb, var(--hero-accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--hero-accent) 15%, transparent);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
}
.hero-body {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}
.hero-emoji {
  font-size: 2.4rem;
  line-height: 1;
  background: var(--surface);
  border-radius: var(--radius-md);
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.hero-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--text);
}
.hero-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  margin: 0 0 14px;
}
.hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.hero-btn {
  text-decoration: none;
  font-size: .85rem;
  padding: 8px 22px;
}
.hero-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}
.hero-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--hero-accent) 15%, var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--hero-accent) 25%, transparent);
  transition: background .2s;
}
.hero-dot.filled {
  background: var(--hero-accent);
  border-color: var(--hero-accent);
}
.hero-decoration {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 40%;
  pointer-events: none;
}
.hero-blob {
  position: absolute;
  border-radius: 50%;
  background: color-mix(in srgb, var(--hero-accent) 4%, transparent);
}
.hero-blob-1 {
  width: 200px; height: 200px;
  top: -40px; right: -20px;
}
.hero-blob-2 {
  width: 120px; height: 120px;
  bottom: -30px; right: 80px;
}

/* ── Section Heading ───────────────────────────────────────────────────────── */
.section-heading {
  font-size: .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;   /* Bright direction: pill buttons app-wide */
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, filter .15s;
  border: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: white; box-shadow: 0 10px 24px -10px var(--blue); }
.btn-primary:hover { background: var(--brand-strong); box-shadow: 0 16px 30px -12px var(--blue); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border2); }
.btn-secondary:hover { background: var(--surface2); border-color: var(--text-muted); }
.btn-success { background: var(--ok); color: white; }
.btn-success:hover { filter: brightness(1.08); }
.btn-warning { background: #f59e0b; color: #111827; }
.btn-warning:hover { filter: brightness(1.08); }
.btn-danger { background: #ef4444; color: white; }
.btn-lg { padding: 15px 30px; font-size: 1.05rem; border-radius: 999px; }
.btn-sm { padding: 9px 18px; font-size: .8125rem; border-radius: 999px; min-height: 44px; }   /* a11y: 44px min touch target (UX-A11y-012) */
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  padding: 9px 16px;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  background: none;
  border: none;
  text-align: center;
}
.tab-btn:hover { color: var(--text); background: var(--border); }
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Flashcard Header ──────────────────────────────────────────────────────── */
.fc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ── Topic Progress Header ─────────────────────────────────────────────────── */
.topic-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

/* ── Flashcard ─────────────────────────────────────────────────────────────── */
.flashcard-viewport {
  perspective: 1200px;
  width: 100%; max-width: 560px;
  margin: 0 auto 24px;
}
.flashcard-scene {
  width: 100%; aspect-ratio: 16/10;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.4,0,.2,1);
  cursor: pointer;
}
.flashcard-scene.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  display: flex; flex-direction: column;
  padding: 32px;
}
.flashcard-back-face {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #f0f7ff 0%, var(--surface) 60%);
}
[data-theme="dark"] .flashcard-back-face {
  background: linear-gradient(135deg, #1a2535 0%, var(--surface) 60%);
}
.flashcard-label {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.flashcard-text {
  flex: 1;
  display: flex; align-items: center;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.55;
  white-space: pre-wrap;
}
.flashcard-answer { font-size: .9375rem; font-weight: 500; line-height: 1.7; white-space: pre-wrap; }
.fc-diagram-badge { display: none; position: absolute; bottom: 12px; right: 12px; font-size: .7rem; color: #6366f1; background: rgba(24,95,165,.08); border: 1px solid rgba(24,95,165,.2); border-radius: 6px; padding: 3px 8px; pointer-events: none; }
.fc-text-col { display: flex; flex-direction: column; flex: 1 1 0; overflow-y: auto; min-width: 0; }
.fc-diagram { display: none; flex: 0 0 46%; align-items: center; justify-content: center; }
.fc-diagram svg { width: 100%; height: auto; max-height: 188px; }
.flashcard-back-face.has-diagram { flex-direction: row; gap: 16px; padding: 18px 22px; }
.flashcard-back-face.has-diagram .flashcard-answer { font-size: .8125rem; }
.flashcard-back-face.has-diagram .fc-diagram { display: flex; }
@media (max-width: 600px) {
  .flashcard-back-face.has-diagram { flex-direction: column; gap: 8px; padding: 14px; }
  .flashcard-back-face.has-diagram .fc-diagram { flex: none; }
  .fc-diagram svg { max-height: 120px; }
}

/* Lesson diagrams */
.lesson-diagram { margin: 20px 0; text-align: center; }
.lesson-diagram-inner { display: inline-block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; cursor: pointer; transition: box-shadow .2s, transform .15s; max-width: 100%; }
.lesson-diagram-inner:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: scale(1.02); }
.lesson-diagram-inner svg { width: 100%; height: auto; max-height: 240px; display: block; }
.lesson-diagram .diagram-caption { font-size: .75rem; color: var(--text-muted); margin-top: 8px; font-style: italic; }
.lesson-diagram .diagram-expand-hint { font-size: .65rem; color: var(--text-muted); margin-top: 4px; opacity: .7; }

/* Diagram zoom modal */
.diagram-modal-overlay { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.75); align-items: center; justify-content: center; padding: 20px; }
.diagram-modal-overlay.show { display: flex; }
.diagram-modal { position: relative; background: var(--surface); border-radius: 16px; padding: 48px 40px 40px; width: 85vw; max-width: 800px; max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.diagram-modal-close { position: absolute; top: 12px; right: 16px; font-size: 1.75rem; background: none; border: none; color: var(--text-muted); cursor: pointer; line-height: 1; padding: 4px 10px; border-radius: 6px; }
.diagram-modal-close:hover { background: var(--hover); color: var(--text); }
.diagram-modal-content { display: flex; align-items: center; justify-content: center; min-height: 300px; }
.diagram-modal-content svg { width: 100%; height: auto; max-height: 75vh; display: block; }
@media (max-width: 600px) {
  .diagram-modal { padding: 40px 16px 24px; width: 96vw; }
}

.flashcard-hint {
  font-size: .75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: auto;
}
.card-nav {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 20px;
}
.card-progress-dots {
  display: flex; gap: 6px; align-items: center;
}
.card-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: all .2s;
}
.card-dot.learned { background: #22c55e; }
.card-dot.current { background: var(--blue); transform: scale(1.35); }
.card-dot.review { background: var(--amber); }

.flashcard-actions {
  display: flex; gap: 12px; justify-content: center;
  margin-top: 4px;
}

/* ── Quiz ──────────────────────────────────────────────────────────────────── */
.quiz-progress-bar {
  height: 5px;
  background: var(--border);
  border: 1px solid #9ca3af;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 28px;
}
.quiz-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--blue);
  transition: width .4s ease;
}
.quiz-question-num {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.quiz-question-text {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.quiz-options {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 24px;
}
.quiz-option {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: .9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  display: flex; align-items: center; gap: 12px;
}
.quiz-option:hover:not(.answered) { border-color: var(--blue); background: #e8f0fa; }
[data-theme="dark"] .quiz-option:hover:not(.answered) { background: rgba(24,95,165,.15); }
.quiz-option.selected:not(.answered) { border-color: var(--blue); background: #e8f0fa; }
[data-theme="dark"] .quiz-option.selected:not(.answered) { background: rgba(24,95,165,.15); }
.quiz-option.correct  { border-color: #22c55e; background: #f0fdf4; color: #166534; }
.quiz-option.wrong    { border-color: #ef4444; background: #fef2f2; color: #991b1b; }
[data-theme="dark"] .quiz-option.correct { background: rgba(34,197,94,.12); color: #4ade80; }
[data-theme="dark"] .quiz-option.wrong   { background: rgba(239,68,68,.12); color: #f87171; }
.quiz-option.answered:not(.correct):not(.wrong) { opacity: .45; pointer-events: none; }
.option-letter {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 800;
  flex-shrink: 0;
  transition: all .15s;
}
.quiz-option.correct .option-letter { background: #22c55e; color: white; }
.quiz-option.wrong   .option-letter { background: #ef4444; color: white; }
.quiz-explanation {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--blue);
  padding: 14px 16px;
  font-size: .875rem;
  color: var(--text-2);
  margin-bottom: 16px;
  display: none;
}
.quiz-explanation.show { display: block; }
.quiz-next-wrap {
  position: sticky;
  bottom: 16px;
  display: flex;
  justify-content: flex-end;
  padding: 20px 0 8px;
  /* fade the page background up so scrolled content doesn't hard-clip behind the button */
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
  pointer-events: none; /* let clicks pass through the gradient area */
}
.quiz-next-wrap .btn { pointer-events: all; }
.quiz-report-wrap { text-align: center; margin-top: 4px; }
.quiz-report-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .8125rem;
  cursor: pointer;
  padding: 6px 10px;
  text-decoration: none;
}
.quiz-report-link:hover, .quiz-report-link:focus-visible { color: var(--text-2); text-decoration: underline; }
textarea.form-input { resize: vertical; min-height: 90px; font-family: inherit; }
@media (max-width: 900px) {
  /* on mobile the fixed nav bar is ~60 px tall — keep the button above it */
  .quiz-next-wrap { bottom: 76px; }
}
.quiz-score-screen {
  text-align: center;
  padding: 40px 20px;
  display: none;
}
.quiz-score-screen.show { display: block; }
.score-emoji { font-size: 4rem; margin-bottom: 16px; }
.score-fraction { font-size: 3rem; font-weight: 800; margin-bottom: 8px; }
.score-label { font-size: 1rem; color: var(--text-2); margin-bottom: 32px; }

/* ── Lesson Tab ────────────────────────────────────────────────────────────── */
.lesson-generate-area { text-align: center; padding: 48px 24px; }
.lesson-generate-icon { font-size: 3rem; margin-bottom: 16px; }
.lesson-content-area {
  max-width: 640px;
}
.lesson-content-area h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text);
}
.lesson-content-area h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 24px 0 8px;
  color: var(--text);
}
.lesson-content-area h3:first-of-type { margin-top: 12px; }
.lesson-content-area h4 {
  font-size: 1rem;
  margin: 24px 0 10px;
  color: var(--text);
}
.lesson-content-area h4:first-child { margin-top: 0; }
.lesson-content-area ul, .lesson-content-area ol {
  padding-left: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.lesson-content-area li { font-size: .9375rem; color: var(--text-2); line-height: 1.6; }
.lesson-content-area dl { display: flex; flex-direction: column; gap: 8px; }
.lesson-content-area dt { font-weight: 700; font-size: .9375rem; }
.lesson-content-area dd { font-size: .9rem; color: var(--text-2); margin-left: 16px; }
.example-box {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--blue);
  padding: 14px 16px;
  margin: 10px 0;
}
.example-box p { font-size: .9375rem; margin-bottom: 6px; }
.lesson-next-hint {
  font-size: .8125rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 20px;
}
.lesson-loading {
  display: flex; align-items: center; gap: 12px;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: .9375rem;
}
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page Main (unit.html & topic.html) ──────────────────────────────────── */
.page-main { margin: 0 auto; padding: 28px 24px 64px; }
.unit-main { max-width: 760px; }
.topic-main  { max-width: 1100px; }

/* ── Unit Detail Header ──────────────────────────────────────────────────── */
.unit-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.unit-header-back {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  background: var(--surface);
  flex-shrink: 0;
  transition: background .15s;
}
.unit-header-back:hover { background: var(--surface2); }
.unit-header-emoji {
  font-size: 2.25rem;
  width: 52px; height: 52px;
  background: var(--surface2);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.unit-header-info { flex: 1; }
.unit-header-info h2 { font-size: 1.25rem; }
.unit-header-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }

/* ── Login Page ────────────────────────────────────────────────────────────── */
.auth-page {
  display: flex;
  min-height: 100vh;
  overflow: hidden; /* contain decorative brand blobs; avoids transient edge clipping on first paint */
}
.auth-brand {
  flex: 1;
  background: var(--blue);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  position: relative;
  overflow: hidden;
}
.auth-brand::after {
  content: '';
  position: absolute;
  bottom: -80px; right: -80px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.auth-brand::before {
  content: '';
  position: absolute;
  top: -40px; left: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.auth-logo-img {
  height: 176px;
  width: auto;
  display: block;
  position: relative;
  z-index: 1;
}
.auth-brand-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 48px;
  position: relative;
  z-index: 1;
}
.auth-brand-mark {
  width: 48px; height: 48px;
  background: rgba(255,255,255,.2);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
}
.auth-brand-name { font-size: 1.25rem; font-weight: 800; color: white; }
.auth-brand-name span { color: var(--amber); }
.brand-atl { color: #14213d; font-weight: 800; }
.brand-as  { color: #c9a020; font-weight: 800; }
.welcome-atlas-text {
  height: 4.8em;
  width: auto;
  vertical-align: middle;
  display: inline-block;
}
.auth-brand h1 { color: white; font-size: 2rem; margin-bottom: 16px; position: relative; z-index: 1; }
.auth-brand p { color: rgba(255,255,255,.8); font-size: 1rem; max-width: 340px; position: relative; z-index: 1; }
.auth-brand-features { margin-top: 40px; display: flex; flex-direction: column; gap: 16px; position: relative; z-index: 1; }
.auth-feature {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,.9);
  font-size: .9375rem;
  font-weight: 500;
}
.auth-feature-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.auth-form-panel {
  width: 460px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 48px;
  background: var(--surface);
}
.auth-form-panel h2 { margin-bottom: 6px; }
.auth-form-panel > p { margin-bottom: 32px; }

.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .9375rem;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24,95,165,.12);
}
.form-input::placeholder { color: var(--text-muted); }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-select option:disabled {
  color: #9ca3af;
  font-style: italic;
}
.form-error {
  font-size: .8125rem;
  color: #ef4444;
  margin-top: 6px;
  display: none;
}
.form-error.show { display: block; }
.auth-switch {
  text-align: center;
  font-size: .875rem;
  color: var(--text-muted);
  margin-top: 20px;
}
.auth-switch a {
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
}
.auth-tab-bar {
  display: flex;
  background: var(--surface2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab-btn {
  flex: 1;
  padding: 9px;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
  color: var(--text-muted);
  background: none;
  border: none;
}
.auth-tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── Toasts ────────────────────────────────────────────────────────────────── */
.xp-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--text);
  color: var(--surface);
  border-radius: 12px;
  padding: 12px 18px;
  display: flex; align-items: center; gap: 10px;
  font-size: .875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .3s;
  z-index: 1000;
}
.xp-toast--show { transform: translateY(0); opacity: 1; }
.xp-toast-amount { color: #fbbf24; font-size: 1rem; }
.xp-toast-reason { color: var(--text-muted); font-size: .8125rem; }

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: var(--text);
  color: var(--surface);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: .875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s;
}
.toast--show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast--success { border-left: 4px solid #22c55e; }
.toast--error   { border-left: 4px solid #ef4444; }

/* ── Profile Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 440px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  transform: scale(.95);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: .875rem;
  transition: background .15s;
}
.modal-close:hover { background: var(--border); }

/* ── Profile Page ──────────────────────────────────────────────────────────── */
.profile-page {
  width: 100%;
}
.profile-page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.profile-page-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}
.profile-back-btn {
  flex-shrink: 0;
}
.profile-page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.profile-page-card .form-input {
  max-width: 480px;
}
.profile-page-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.profile-page-signout {
  padding: 16px 24px;
}
.profile-page-signout .btn {
  max-width: 200px;
}
.profile-progress-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text);
}
.profile-progress-section .wp-roadahead {
  overflow-x: auto;
}

/* ── Mobile Header ─────────────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  align-items: center;
  justify-content: space-between;
  transition: background .25s, border-color .25s;
}
.mobile-header-logo {
  height: 120px;
  width: auto;
}
.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Mobile Bottom Nav ─────────────────────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  transition: background .25s, border-color .25s;
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .6875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color .15s;
  background: none;
  border: none;
  font-family: var(--font);
}
.mobile-nav-item.active { color: var(--blue); }
.mobile-nav-icon { font-size: 1.375rem; line-height: 1; }

/* ── Responsive ────────────────────────────────────────────────────────────── */

/* Tablet & Mobile (≤900px) */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 110;
    transition: background .25s, border-color .25s, transform .3s cubic-bezier(.4,0,.2,1), box-shadow .3s;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-close-row { display: flex; }
  .mobile-header { display: flex; }
  .mobile-nav { display: flex; }
  .page-main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .main-content {
    margin-left: 0;
    padding: 20px 16px calc(72px + env(safe-area-inset-bottom));
    max-width: 100%;
  }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .unit-header { padding: 12px 16px; gap: 12px; }
  .unit-header-emoji { width: 44px; height: 44px; font-size: 1.75rem; border-radius: 10px; }
  .unit-header-info h2 { font-size: 1.05rem; }
  .xp-toast { bottom: calc(72px + env(safe-area-inset-bottom) + 16px); }

  /* Auth: show compact logo banner instead of hiding branding entirely */
  .auth-brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 14px 20px;
    min-height: auto;
    flex: none;
    gap: 12px;
    overflow: hidden;
  }
  .auth-brand h1,
  .auth-brand > p,
  .auth-brand-features { display: none; }
  .auth-brand-logo { margin-bottom: 0; }
  .auth-logo-img { height: 38px; }
  .auth-form-panel { width: 100%; padding: 28px 20px 40px; }
  .auth-page { flex-direction: column; }
}

/* Mobile (≤600px) */
@media (max-width: 600px) {
  .page-main { padding: 20px 16px calc(72px + env(safe-area-inset-bottom)); }
  .unit-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 1.5rem; }
  .page-header { margin-bottom: 20px; }
  .page-header h1 { font-size: 1.375rem; }
  .header-badges { gap: 6px; }
  .header-badge { padding: 4px 10px; font-size: .75rem; }
  .header-badge strong { font-size: .8rem; }

  .hero-banner { padding: 20px 18px; }
  .hero-emoji { width: 50px; height: 50px; font-size: 1.8rem; }
  .hero-title { font-size: 1.15rem; }
  .hero-body { gap: 14px; }
  .hero-blob-1 { width: 140px; height: 140px; }
  .hero-blob-2 { width: 80px; height: 80px; }

  .goals-header { flex-wrap: wrap; gap: 8px; }
  .goals-segments { order: 10; width: 100%; flex: none; }
  .week-plan { padding: 16px; }

  /* Filter row: horizontal scroll so filters stay on one line */
  .filter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 6px;
  }
  .filter-row::-webkit-scrollbar { display: none; }

  /* Tab bar: scroll horizontally on very small screens */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    gap: 2px;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { flex: none; white-space: nowrap; font-size: .75rem; padding: 8px 10px; }

  .flashcard-face { padding: 20px; overflow-y: auto; }
  .flashcard-scene { aspect-ratio: auto; min-height: 200px; }
  .flashcard-text { font-size: .9375rem; }
  .flashcard-viewport { max-width: 100%; }

  .unit-header-meta { flex-wrap: wrap; gap: 4px; }
}

/* Small Mobile (≤400px) */
@media (max-width: 400px) {
  .unit-card { padding: 14px; }
  .mobile-nav-item { padding: 6px 16px; }
  .unit-header-emoji { display: none; }
  .unit-header-info h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
}

/* Narrowest (≤360px) — single-column grid */
@media (max-width: 360px) {
  .unit-grid { grid-template-columns: 1fr; }
}

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .6875rem;
  font-weight: 700;
  background: var(--surface2);
  color: var(--text-muted);
}
.text-blue   { color: var(--blue); }
.text-green  { color: var(--green); }
.text-amber  { color: var(--amber); }
.text-muted  { color: var(--text-muted); }
.font-bold   { font-weight: 700; }
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mt-16       { margin-top: 16px; }
.mb-8        { margin-bottom: 8px; }
.mb-16       { margin-bottom: 16px; }

/* ═════════════════════════════════════════════════════════════════════════════
   STUDY PLANNER — Setup Banner + Today's Plan Card
   ═════════════════════════════════════════════════════════════════════════════ */

/* ── Setup Banner ────────────────────────────────────────────────────────────── */
.plan-setup-modal-inner {
  position: relative;
  background: linear-gradient(135deg, var(--blue), #2a7de1);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  width: 480px;
  max-width: calc(100vw - 32px);
  border: none;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.plan-setup-modal-inner .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,.2);
  color: #fff;
}
.plan-setup-modal-inner .modal-close:hover {
  background: rgba(255,255,255,.35);
}
.plan-setup-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.plan-setup-icon { font-size: 1.75rem; }
.plan-setup-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}
.plan-setup-desc {
  font-size: .925rem;
  line-height: 1.6;
  color: #fff;
  margin: 0 0 20px;
}
.plan-setup-dates {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}
.plan-setup-date {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan-setup-date-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .9;
}
.plan-setup-date-value {
  font-size: 1rem;
  font-weight: 700;
}
.plan-setup-go {
  background: #fff !important;
  color: var(--blue) !important;
  font-weight: 700 !important;
  padding: 10px 28px !important;
  font-size: .95rem !important;
  border-radius: 12px !important;
  border: none;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.plan-setup-go:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}

/* ── Week Complete Congratulations Modal ────────────────────────────────────── */
.week-complete-modal-inner {
  position: relative;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 420px;
  max-width: calc(100vw - 32px);
  border: none;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.week-complete-modal-inner .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,.2);
  color: #fff;
}
.week-complete-modal-inner .modal-close:hover {
  background: rgba(255,255,255,.35);
}
.week-complete-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
}
.week-complete-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 8px;
}
.week-complete-desc {
  font-size: .925rem;
  line-height: 1.6;
  color: #fff;
  opacity: .95;
  margin: 0 0 22px;
}
.week-complete-go {
  background: #fff !important;
  color: #16a34a !important;
  font-weight: 700 !important;
  padding: 10px 28px !important;
  font-size: .95rem !important;
  border-radius: 12px !important;
  border: none;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.week-complete-go:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}

/* ── Study Plan Card ─────────────────────────────────────────────────────────── */
.week-plan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  animation: planSlideIn .35s ease;
}

/* Goals header bar */
.goals-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.goals-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text);
  background: color-mix(in srgb, var(--blue) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--blue) 20%, var(--border));
  border-radius: 20px;
  padding: 5px 14px;
  white-space: nowrap;
  flex-shrink: 0;
}
.goals-week {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.goals-segments {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.goals-seg {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid color-mix(in srgb, var(--seg-color, #9ca3af) 20%, var(--border));
  transition: background .3s;
}
.goals-seg.done {
  background: #22c55e;
  border-color: #22c55e;
}
.goals-count {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.goals-toggle {
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 600;
  color: var(--blue);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0;
  transition: color .15s;
}
.goals-toggle:hover {
  color: color-mix(in srgb, var(--blue) 80%, #000);
}
.goals-toggle.active {
  color: var(--text-muted);
}
.goals-toggle.active:hover {
  color: var(--text);
}
.goals-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 16px;
}
.goals-body {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height .35s ease, opacity .25s ease;
  opacity: 1;
  margin-top: 16px;
}
.goals-body.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

/* Tabs */
.wp-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.wp-tab {
  padding: 8px 18px;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.wp-tab:hover { color: var(--text); }
.wp-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.wp-panel { /* tab content panels */ }

.week-plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.week-plan-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  color: var(--text);
}
.week-plan-icon { font-size: 1.2rem; }
.week-plan-count {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-2);
}
.week-plan-bar-wrap { margin-bottom: 16px; }
.week-plan-bar-track {
  height: 6px;
  background: var(--surface2);
  border: 1px solid #9ca3af;
  border-radius: 3px;
  overflow: hidden;
}
.week-plan-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 3px;
  transition: width .4s ease;
  width: 0%;
}

/* Topic-level progress overview */
.week-plan-progress {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.wp-prog-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.wp-prog-label {
  font-size: .78rem;
  font-weight: 600;
  width: 120px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wp-prog-bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.wp-prog-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .5s ease;
}
.wp-prog-stat {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}
.wp-prog-overall {
  margin-top: 8px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-2);
  text-align: right;
}

/* Section titles */
.wp-section-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
}

/* Subject progress cards */
.subj-cards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.subj-cards-header .wp-section-title {
  margin: 0;
}
.subj-cards-hint {
  font-size: .75rem;
  color: var(--text-muted);
}
.subj-cards-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 12px;
}
.subj-cards-scroll::-webkit-scrollbar { display: none; }
.subj-cards {
  display: flex;
  gap: 14px;
  min-width: min-content;
}
.subj-card {
  position: relative;
  overflow: hidden;
  min-width: 180px;
  max-width: 220px;
  flex: 1 0 180px;
  background: var(--surface);
  border: 1.5px solid color-mix(in srgb, var(--subj-color) 30%, var(--border));
  border-radius: var(--radius-lg);
  padding: 20px 18px 16px;
}
.subj-card-blob {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--subj-color) 10%, transparent);
  pointer-events: none;
}
.subj-card-emoji {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: color-mix(in srgb, var(--subj-color) 10%, var(--surface));
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  position: relative;
}
.subj-card-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.subj-card-stat {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.subj-card-bar-track {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.subj-card-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--subj-color);
  transition: width .5s ease;
}

/* Road Ahead — weekly grid table */
.wp-grid-wrap {
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.wp-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
  min-width: 600px; /* ensures horizontal scroll on mobile */
}
.wp-grid th,
.wp-grid td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.wp-grid thead th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  z-index: 1;
}
.wp-grid-wk {
  font-weight: 700;
  white-space: nowrap;
  width: 48px;
  text-align: center !important;
  color: var(--text-muted);
}
.wp-grid tbody td {
  color: var(--text-2);
  line-height: 2.1;
}
.wp-grid-topic {
  font-weight: 600;
  color: var(--text);
}
.wp-grid-empty {
  color: var(--text-muted);
  opacity: .4;
}
/* Current week row highlight */
.wp-grid-current {
  background: rgba(24,95,165,.08);
}
.wp-grid-current .wp-grid-wk {
  color: var(--blue);
  font-weight: 800;
}
[data-theme="dark"] .wp-grid-current {
  background: rgba(24,95,165,.18);
}
/* Past weeks slightly muted */
.wp-grid-past {
  opacity: .55;
}
/* Mastered tick — green */
.wp-grid-mastered {
  color: #16a34a;
  font-weight: 700;
}
/* Locked icon — muted */
.wp-grid-locked {
  opacity: .6;
  font-size: .7rem;
}
/* Test milestone */
.wp-grid-test {
  display: inline-block;
}
/* Checkpoint milestone */
.wp-grid-checkpoint {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  color: #0d9488;
  text-decoration: none;
  padding: 1px 0;
}
.wp-grid-checkpoint:hover {
  text-decoration: underline;
  color: #06708a;
}
[data-theme="dark"] .wp-grid-checkpoint { color: #22d3ee; }
[data-theme="dark"] .wp-grid-checkpoint:hover { color: #67e8f9; }
/* Comprehension entry */
.wp-grid-comp {
  display: inline-block;
}

/* Subject groups */
.week-plan-subject { margin-bottom: 20px; }
.week-plan-subject:last-child { margin-bottom: 0; }
.week-plan-subject-header {
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .06em;
  margin-bottom: 8px;
  padding-bottom: 0;
}
.week-plan-topic {
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 600;
  margin: 6px 0 2px 0;
  padding-left: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Square status indicator */
.wp-square {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  display: inline-block;
}
.wp-square.filled {
  background: var(--sq-color);
}
.wp-square.empty {
  background: var(--surface2);
  border: 2px solid var(--border);
}

/* Unit rows */
.week-plan-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: none;
  transition: background .1s;
}
.week-plan-item:hover { background: var(--surface2); border-radius: var(--radius-sm); }
/* Completed rows: mute the label/square/dots but keep the green check at full
   strength so every "✓ Done" / "✓ Passed" reads as the same dark green. */
.week-plan-item.complete .week-plan-name { color: var(--text-muted); }
.week-plan-item.complete .wp-dot-label,
.week-plan-item.complete .week-plan-dots { opacity: .5; }
.week-plan-item.complete .wp-square { opacity: .6; }

/* Progress dots (right side) */
.week-plan-dots {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.wp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.wp-dot.filled { /* background set inline via subject color */ }
.wp-dot.empty {
  background: var(--border);
}

.week-plan-name {
  flex: 1;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.week-plan-go {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  transition: color .15s;
}
.week-plan-go:hover { color: var(--text); }
.week-plan-done {
  font-size: .8rem;
  font-weight: 600;
  color: #15803d;
  white-space: nowrap;
}

/* Footer */
.week-plan-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.week-plan-footer .btn-sm {
  padding: 4px 10px;
  font-size: .75rem;
}

/* ── GCSE standing (indicative 9–1 scale placement; Parent Zone) ────────────── */
.gcse-standing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-top: 4px; }
.gs-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.gs-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.gs-emoji { font-size: 1.15rem; }
.gs-name { font-weight: 700; font-size: .95rem; }
.gs-grade { margin-left: auto; font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--blue); }
.gs-grade.gs-below { font-family: var(--font); font-weight: 700; font-size: .8rem; color: var(--text-muted); }
.gs-grade.gs-ks3grade { font-family: var(--font); font-weight: 700; font-size: .82rem; color: var(--brand-strong); }
.gs-scale-ks3 .gs-seg { font-size: .58rem; line-height: 1.1; padding: 3px 2px; height: 32px; text-align: center; }
.gs-scalewrap { position: relative; padding-top: 16px; }
.gs-scale { display: flex; gap: 3px; }
.gs-seg { flex: 1; height: 28px; display: grid; place-items: center; font-size: .8rem; font-weight: 700;
  background: var(--surface2); color: var(--text-muted); border-radius: 6px; }
.gs-seg.on { background: var(--brand-soft); color: var(--brand-strong); }
.gs-seg.cur { background: var(--blue); color: #fff; box-shadow: 0 4px 12px -4px var(--blue); }
.gs-marker { position: absolute; top: 0; transform: translateX(-50%); font-size: .62rem; font-weight: 800;
  color: var(--blue); white-space: nowrap; letter-spacing: .02em; }
.gs-note { font-size: .7rem; color: var(--text-muted); margin-top: 11px; line-height: 1.45; }
.gs-empty { font-size: .8125rem; color: var(--text-muted); padding: 6px 0 2px; line-height: 1.5; }

.week-plan-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-2);
  font-size: .9rem;
}

/* Comprehension & gate type label (replaces dots) */
.wp-dot-label {
  font-size: .75rem;
  flex-shrink: 0;
  min-width: 22px;
  text-align: center;
}

/* Topic gate section */
.week-plan-gate {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.week-plan-item.revision .week-plan-name { color: var(--amber, #d97706); }
.revision-score {
  font-size: .75rem;
  font-weight: 400;
  color: var(--text-muted);
}
.week-plan-item.gate-test .week-plan-name {
  font-weight: 600;
  font-size: .8125rem;
}
.week-plan-item.locked { opacity: .5; }
.week-plan-locked {
  font-size: .7rem;
  font-weight: 500;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
}
.week-plan-locked-notice {
  font-size: .75rem;
  color: var(--text-muted);
  padding: 6px 4px;
  text-align: center;
}

/* Next week preview */
.week-plan-next {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
}
.week-plan-next-header {
  font-size: .875rem;
  font-weight: 700;
  color: var(--primary, #6366f1);
  margin-bottom: 12px;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .plan-setup-modal-inner { padding: 24px 20px; }
  .plan-setup-dates { flex-direction: column; gap: 12px; }
  .week-plan { padding: 16px; }
  .wp-tab { padding: 6px 14px; font-size: .8rem; }
  .week-plan-item { gap: 8px; padding: 6px 2px; }
  .week-plan-name { font-size: .8rem; }
  .wp-prog-label { width: 100px; font-size: .72rem; }
  .wp-grid-wrap { max-height: 350px; }
  .wp-grid { font-size: .72rem; }
  .wp-grid th, .wp-grid td { padding: 5px 8px; }
  .week-plan-footer { flex-direction: column; align-items: flex-end; }
}

/* a11y: honour the OS "reduce motion" preference — near-instant animations and
   transitions for users who request it (UX-A11y-011). Covers spin, bubbleIn,
   micPulse, typingBounce, planSlideIn and any future animation/transition. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Accessible confirm dialog (UX-A11y-014) — replaces window.confirm(). */
.atlas-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.atlas-modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 24px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.atlas-modal-msg { font-size: 1rem; line-height: 1.5; color: var(--text); margin: 0 0 20px; }
.atlas-modal-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
