:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --paper: #ffffff;
  --paper-subtle: #f8fafc;
  --paper-hover: #f1f5f9;
  --canvas: #f1f5f9;
  --navy: #0f172a;
  --accent: #1976d2;
  --accent-soft: #e8f0fe;
  --good: #15803d;
  --good-soft: #dcfce7;
  --good-border: #86efac;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --bad-border: #fca5a5;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --warning-border: #fcd34d;
  --memory-bg: #f5f3ff;
  --memory-border: #ddd6fe;
  --memory-ink: #4c1d95;
  --summary-bg: #eff6ff;
  --summary-border: #bfdbfe;
  --summary-ink: #1e3a8a;
  --formula-bg: #f8fafc;
  --formula-border: #cbd5e1;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.14), 0 4px 10px -2px rgba(15, 23, 42, 0.06);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar: 268px;
}

html[data-theme="dark"] {
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --line: #1e293b;
  --line-strong: #334155;
  --paper: #111827;
  --paper-subtle: #1e293b;
  --paper-hover: #263349;
  --canvas: #0b1120;
  --navy: #f8fafc;
  --good: #4ade80;
  --good-soft: rgba(22, 163, 74, 0.16);
  --good-border: rgba(74, 222, 128, 0.35);
  --bad: #f87171;
  --bad-soft: rgba(220, 38, 38, 0.16);
  --bad-border: rgba(248, 113, 113, 0.35);
  --warning: #fbbf24;
  --warning-soft: rgba(217, 119, 6, 0.16);
  --warning-border: rgba(251, 191, 36, 0.35);
  --memory-bg: rgba(139, 92, 246, 0.14);
  --memory-border: rgba(167, 139, 250, 0.32);
  --memory-ink: #ddd6fe;
  --summary-bg: rgba(59, 130, 246, 0.14);
  --summary-border: rgba(96, 165, 250, 0.32);
  --summary-ink: #dbeafe;
  --formula-bg: #172033;
  --formula-border: #334155;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 2px 5px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 14.5px/1.62 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Mathematical Typography */
.math {
  font-variant-numeric: tabular-nums;
  display: inline-block;
  font-weight: 500;
  color: var(--ink);
}
.math sub, .math sup, sub, sup {
  font-size: 0.78em;
  line-height: 0;
}
.math-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  padding: 2px 6px;
  margin: 2px 3px;
  font-size: 0.94em;
  line-height: 1.28;
}
.math-num {
  border-bottom: 1.5px solid var(--ink-2);
  padding: 0 5px 3px;
  font-weight: 600;
  color: var(--ink);
}
.math-den {
  padding: 3px 5px 0;
  font-weight: 500;
  color: var(--ink-2);
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -100px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 8px 14px;
  z-index: 100;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.skip-link:focus { top: 12px; }

.shell { min-height: 100vh; }

/* Permanent Sidebar Drawer */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--paper);
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  z-index: 30;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: 0;
  color: var(--ink);
  text-align: left;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
}
.brand:hover .brand-mark {
  transform: scale(1.04);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #000));
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 32%, transparent);
  transition: transform 0.15s ease;
}
.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.2px;
  color: var(--ink);
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}
.subject-picker {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--paper-subtle);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  line-height: 1.35;
  min-height: 52px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.subject-picker:hover {
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: var(--shadow-xs);
}
.subject-picker b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.subject-picker small {
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Quick Subject Switcher Pills in Sidebar */
.subject-quick-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 8px;
}
.subject-quick-btn {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 4px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subject-quick-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--paper-subtle);
}
.subject-quick-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  padding: 16px 10px 6px;
}
.main-nav {
  display: grid;
  gap: 3px;
}
.main-nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  width: 100%;
}
.main-nav button svg {
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.12s;
}
.main-nav button .nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.main-nav button .nav-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--paper-subtle);
  color: var(--muted);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.main-nav button .nav-badge:empty {
  display: none;
}
.main-nav button:hover {
  background: var(--paper-hover);
  color: var(--ink);
}
.main-nav button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.main-nav button.active svg {
  color: var(--accent);
}
.main-nav button.active .nav-badge {
  background: var(--paper);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.mini-progress {
  padding: 8px 10px;
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
}
.mini-progress b { color: var(--ink); }
.mini-progress .bar {
  margin-top: 6px;
}
.sidebar-links {
  display: grid;
  gap: 2px;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.text-button:hover {
  color: var(--ink);
  background: var(--paper-hover);
}

/* Main Column & AppBar */
.main-column {
  margin-left: var(--sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 60px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.breadcrumb {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.crumb-btn {
  border: 0;
  background: transparent;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
}
.crumb-btn:hover {
  background: var(--paper-hover);
  color: var(--ink);
}
.crumb-current {
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  padding: 2px 4px;
}
.crumb-sep {
  color: var(--line-strong);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.cmd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: var(--paper-subtle);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  transition: all 0.15s ease;
}
.cmd-trigger:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--paper);
}
.cmd-trigger kbd {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--muted);
}
.tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.tool-pill:hover, .tool-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.save-status {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.icon-button {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  transition: all 0.15s ease;
}
.icon-button:hover {
  background: var(--paper-hover);
  color: var(--ink);
  border-color: var(--accent);
}
.mobile-only { display: none; }

/* Sticky Reading Progress Bar */
.reading-progress-bar {
  position: sticky;
  top: 60px;
  height: 3px;
  background: transparent;
  z-index: 19;
  width: 100%;
}
.reading-progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

#app {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px 72px;
  outline: none;
}

/* Page Headers & Hero Card */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.page-head h1, .hero h1 {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.35px;
  margin: 0 0 6px;
  color: var(--ink);
}
.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 720px;
}
.hero {
  background: linear-gradient(135deg, var(--paper) 0%, var(--paper-subtle) 100%);
  color: var(--ink);
  padding: 28px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}
.hero h1 {
  font-size: 26px;
  max-width: 780px;
}
.hero p {
  color: var(--muted);
  max-width: 760px;
  margin: 8px 0 0;
  font-size: 14.5px;
}
.hero .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

/* Stats & Cards */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0 26px;
}
.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
  box-shadow: var(--shadow);
}
.stat-card strong {
  font-size: 23px;
  font-weight: 700;
  display: block;
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}
.stat-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.subject-card {
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 22px;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
  min-height: 256px;
}
.subject-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.subject-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.subject-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.subject-pct-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.subject-card h2 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 8px;
  color: var(--ink);
}
.subject-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 16px;
}
.subject-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: auto;
  padding-top: 14px;
}
.subject-meta span {
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
}
.subject-card .go {
  font-weight: 600;
  color: var(--accent);
  margin-top: 14px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Progress Bars */
.bar {
  height: 7px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  height: 100%;
  display: block;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 30px 0 12px;
}
.section-title h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin: 0;
}
.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}
.action-card {
  text-align: left;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
}
.action-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.action-card .action-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 12px;
}
.action-card h3 {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.action-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

/* Next-Step Recommendation Banner on Dashboard */
.next-step-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(90deg, var(--accent-soft), var(--paper));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}
.next-step-banner b {
  display: block;
  font-size: 13.5px;
  color: var(--ink);
}
.next-step-banner span {
  font-size: 12.5px;
  color: var(--muted);
}

/* Chapter Row on Dashboard */
.chapter-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
}
.chapter-row-item:last-child { border-bottom: 0; }
.chapter-progress {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Buttons & Chips */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  transition: all 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 3px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-secondary {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--paper-hover);
  border-color: var(--muted);
}
.btn-soft {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--accent);
  font-weight: 600;
}
.btn-soft:hover:not(:disabled) {
  filter: brightness(0.97);
}
.btn-danger {
  background: var(--bad-soft);
  border-color: var(--bad-border);
  color: var(--bad);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-large { padding: 10px 20px; font-size: 13.5px; min-height: 42px; }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  transition: all 0.14s ease;
}
.pill:hover:not(:disabled) {
  background: var(--paper-hover);
  border-color: var(--accent);
}
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pill:disabled { opacity: 0.45; cursor: not-allowed; }

/* Learn Layout & Article Typography */
.learn-layout {
  display: grid;
  grid-template-columns: 265px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.chapter-list {
  position: sticky;
  top: 76px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  box-shadow: var(--shadow-xs);
  display: grid;
  gap: 2px;
}
.chapter-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.4;
  transition: background 0.12s, color 0.12s;
}
.chapter-list button:hover {
  background: var(--paper-hover);
  color: var(--ink);
}
.chapter-list button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.chapter-list button .read-dot {
  flex-shrink: 0;
  color: var(--good);
  font-weight: 700;
  background: var(--good-soft);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
}

.search-box {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--paper);
  color: var(--ink);
  margin-bottom: 10px;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 30px 36px;
  box-shadow: var(--shadow);
}
.article-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 20px;
}
.article-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.article-header h2 {
  margin: 4px 0 6px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.25px;
}
.source {
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Section Jump Bar (Table of Contents inside chapter) */
.toc-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 18px;
}
.toc-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-right: 4px;
}
.toc-pill {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
  transition: all 0.14s ease;
}
.toc-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.article h3 {
  font-size: 16.5px;
  font-weight: 700;
  margin: 26px 0 10px;
  line-height: 1.35;
  color: var(--ink);
  scroll-margin-top: 80px;
}
.article h4 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 18px 0 6px;
  color: var(--ink);
}
.article p { margin: 9px 0; }
.article ul, .article ol { padding-left: 20px; }
.article li { margin: 5px 0; }

/* Callout Boxes & Alerts */
.lead {
  font-size: 15px;
  line-height: 1.68;
  color: var(--ink);
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
}
.summary-box {
  background: var(--summary-bg);
  border: 1px solid var(--summary-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  margin: 16px 0 20px;
  font-size: 13.5px;
  color: var(--summary-ink);
}
.summary-box > b:first-child {
  display: block;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 6px;
}
.summary-box b { color: var(--ink); font-weight: 700; }
.summary-box ul { margin: 6px 0 0; padding-left: 18px; }
.summary-box li { margin: 5px 0; }

details.quick-check {
  border: 1px solid var(--line-strong);
  background: var(--paper-subtle);
  border-radius: var(--radius);
  margin: 22px 0 8px;
  overflow: hidden;
}
details.quick-check summary {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s;
}
details.quick-check summary:hover {
  background: var(--paper-hover);
}
details.quick-check summary::-webkit-details-marker { display: none; }
details.quick-check summary:after {
  content: "Pokaż odpowiedzi ▾";
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
details.quick-check[open] summary {
  border-bottom: 1px solid var(--line);
  background: var(--paper-hover);
}
details.quick-check[open] summary:after { content: "Ukryj odpowiedzi ▴"; }
.quick-check-body {
  padding: 14px 18px;
  font-size: 13.5px;
  background: var(--paper);
}
.quick-check-body p { margin: 7px 0; }

.formula {
  background: var(--formula-bg);
  color: var(--ink);
  border: 1px solid var(--formula-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 14.5px;
  line-height: 1.9;
  margin: 16px 0;
  white-space: normal;
  box-shadow: var(--shadow-xs);
}
.memory, .example, .warning, .callout, .notice {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  font-size: 13.5px;
  border: 1px solid var(--line);
  line-height: 1.58;
}
.memory {
  background: var(--memory-bg);
  border-color: var(--memory-border);
  border-left: 4px solid #7c3aed;
  color: var(--memory-ink);
}
.example {
  background: var(--good-soft);
  border-color: var(--good-border);
  border-left: 4px solid var(--good);
  color: var(--ink);
}
.warning {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  border-left: 4px solid var(--warning);
  color: var(--ink);
}
.callout {
  background: var(--paper-subtle);
  margin: 0;
}
.notice {
  background: var(--paper-subtle);
  border-color: var(--line-strong);
  color: var(--ink-2);
}

/* Data Tables */
.table-wrap {
  overflow: auto;
  margin: 16px 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  background: var(--paper);
}
th {
  background: var(--paper-subtle);
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line-strong);
}
th, td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px 13px;
  vertical-align: top;
}
th:last-child, td:last-child { border-right: 0; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--paper-subtle); }

.article-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 26px;
  padding-top: 18px;
  flex-wrap: wrap;
}

/* Quiz & Config */
.config-card { max-width: 740px; margin: auto; }
.config-card h2 { margin-top: 0; font-size: 19px; font-weight: 700; }
.field { margin: 16px 0; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: 13.5px;
}

/* Material UI Checkbox & Topic Selector */
.mui-checkbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  color: var(--md-outline, #757780);
  background-color: transparent;
  cursor: pointer;
  user-select: none;
  vertical-align: middle;
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1), color 150ms cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}
.mui-checkbox:hover {
  background-color: color-mix(in srgb, var(--md-on-surface, #1a1b21) 6%, transparent);
}
.mui-checkbox.checked,
.mui-checkbox.indeterminate,
.mui-checkbox:has(.mui-checkbox-native:checked),
.mui-checkbox:has(.mui-checkbox-native:indeterminate) {
  color: var(--md-primary, #3f5aa6);
}
.mui-checkbox.checked:hover,
.mui-checkbox.indeterminate:hover,
.mui-checkbox:has(.mui-checkbox-native:checked):hover,
.mui-checkbox:has(.mui-checkbox-native:indeterminate):hover {
  background-color: color-mix(in srgb, var(--md-primary, #3f5aa6) 8%, transparent);
}
.mui-checkbox-native {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.mui-checkbox:has(.mui-checkbox-native:focus-visible) {
  outline: 2px solid var(--md-primary, #3f5aa6);
  outline-offset: 2px;
  background-color: color-mix(in srgb, var(--md-primary, #3f5aa6) 12%, transparent);
}
.mui-checkbox-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  pointer-events: none;
}
.mui-check-svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.mui-checked-icon,
.mui-indeterminate-icon {
  display: none;
}
.mui-unchecked-icon {
  display: block;
}
.mui-checkbox.checked .mui-checked-icon,
.mui-checkbox:has(.mui-checkbox-native:checked) .mui-checked-icon {
  display: block;
  animation: mui-check-pop 160ms cubic-bezier(0.2, 0, 0, 1);
}
.mui-checkbox.checked .mui-unchecked-icon,
.mui-checkbox.checked .mui-indeterminate-icon,
.mui-checkbox:has(.mui-checkbox-native:checked) .mui-unchecked-icon,
.mui-checkbox:has(.mui-checkbox-native:checked) .mui-indeterminate-icon {
  display: none;
}
.mui-checkbox.indeterminate .mui-indeterminate-icon,
.mui-checkbox:has(.mui-checkbox-native:indeterminate) .mui-indeterminate-icon {
  display: block;
  animation: mui-check-pop 160ms cubic-bezier(0.2, 0, 0, 1);
}
.mui-checkbox.indeterminate .mui-unchecked-icon,
.mui-checkbox.indeterminate .mui-checked-icon,
.mui-checkbox:has(.mui-checkbox-native:indeterminate) .mui-unchecked-icon,
.mui-checkbox:has(.mui-checkbox-native:indeterminate) .mui-checked-icon {
  display: none;
}
@keyframes mui-check-pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Topic Selector Card & List */
.mui-topic-selector-card {
  margin: 10px 0 16px;
  border: 1px solid var(--md-outline-var, var(--line));
  border-radius: var(--radius, 16px);
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: border-color .2s var(--md-ease);
}
.mui-topics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 10px 8px;
  background: var(--paper-subtle);
  border-bottom: 1px solid var(--md-outline-var, var(--line));
  flex-wrap: wrap;
}
.mui-master-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  flex: 1;
  min-width: 220px;
}
.mui-master-info {
  display: flex;
  flex-direction: column;
}
.mui-master-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--md-on-surface, var(--ink));
  line-height: 1.25;
}
.mui-master-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}
.mui-topics-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.mui-topic-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--md-outline-var, var(--line));
}
.mui-topic-search-wrap svg.mui-search-icon {
  position: absolute;
  left: 22px;
  color: var(--muted);
  pointer-events: none;
}
.mui-topic-search-input {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 32px !important;
  font-size: 13px !important;
  border: 1px solid var(--line) !important;
  border-radius: 18px !important;
  background: var(--paper-subtle) !important;
  color: var(--ink) !important;
  box-sizing: border-box;
}
.mui-topic-search-input:focus {
  border-color: var(--md-primary) !important;
  background: var(--paper) !important;
  box-shadow: 0 0 0 1px var(--md-primary);
}
.mui-search-clear {
  position: absolute;
  right: 22px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.mui-search-clear:hover {
  color: var(--ink);
}
.mui-topic-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 380px;
  overflow-y: auto;
  padding: 6px 8px;
  overscroll-behavior: contain;
}
.mui-topic-list::-webkit-scrollbar {
  width: 6px;
}
.mui-topic-list::-webkit-scrollbar-track {
  background: transparent;
}
.mui-topic-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}
.mui-topic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-sm, 10px);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  user-select: none;
  transition: background-color 140ms var(--md-ease), border-color 140ms var(--md-ease);
}
.mui-topic-item:hover {
  background: var(--paper-hover, rgba(0, 0, 0, 0.04));
}
.mui-topic-item.selected {
  background: color-mix(in srgb, var(--md-primary, #3f5aa6) 8%, var(--paper));
  border-color: color-mix(in srgb, var(--md-primary, #3f5aa6) 24%, transparent);
}
.mui-topic-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.mui-topic-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--md-primary, #3f5aa6);
  letter-spacing: .3px;
  line-height: 1.2;
}
.mui-topic-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--md-on-surface, var(--ink));
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}
.mui-topic-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  flex-shrink: 0;
  transition: color 140ms var(--md-ease), background 140ms var(--md-ease), border-color 140ms var(--md-ease);
}
.mui-topic-item.selected .mui-topic-badge {
  background: color-mix(in srgb, var(--md-primary) 12%, transparent);
  color: var(--md-primary);
  border-color: transparent;
  font-weight: 600;
}
.mui-topic-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.segmented button {
  flex: 1;
  min-width: 110px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.14s ease;
}
.segmented button:hover {
  border-color: var(--accent);
}
.segmented button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.config-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.quiz-shell { max-width: 840px; margin: auto; }
.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}
.quiz-nav-dots {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}
.quiz-dot {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  transition: all 0.12s ease;
}
.quiz-dot:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.quiz-dot.current {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}
.quiz-dot.answered {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.quiz-dot.right {
  background: var(--good-soft);
  color: var(--good);
  border-color: var(--good-border);
}
.quiz-dot.wrong {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: var(--bad-border);
}

.lifeline-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper-subtle);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
}
.quiz-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow);
}
.question-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  font-weight: 700;
}
.quiz-card h2 {
  font-size: 18.5px;
  font-weight: 600;
  line-height: 1.45;
  margin: 10px 0 20px;
}
.answers { display: grid; gap: 10px; }
.answer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  line-height: 1.5;
  transition: all 0.14s ease;
}
.answer:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--paper-subtle);
}
.answer-letter {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  height: 26px;
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink-2);
}
.answer.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.answer.selected .answer-letter {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.answer.correct {
  border-color: var(--good);
  background: var(--good-soft);
}
.answer.correct .answer-letter {
  background: var(--good);
  border-color: var(--good);
  color: white;
}
.answer.incorrect {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.answer.incorrect .answer-letter {
  background: var(--bad);
  border-color: var(--bad);
  color: white;
}
.answer.eliminated {
  opacity: 0.36;
  text-decoration: line-through;
  pointer-events: none;
  background: var(--paper-subtle);
}
.answer:disabled { cursor: default; color: inherit; }

.feedback {
  margin-top: 16px;
  padding: 15px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid transparent;
}
.feedback.good {
  background: var(--good-soft);
  border-color: var(--good-border);
  color: var(--ink);
}
.feedback.bad {
  background: var(--bad-soft);
  border-color: var(--bad-border);
  color: var(--ink);
}
.feedback b { display: block; margin-bottom: 4px; }
.explanation { margin-top: 6px; color: inherit; line-height: 1.58; }

.quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.bookmark {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
}
.bookmark.active {
  color: var(--warning);
  border-color: var(--warning-border);
  background: var(--warning-soft);
}

.score-hero { text-align: center; padding: 30px; }
.score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) var(--score), var(--line) 0);
  position: relative;
}
.score-ring:before {
  content: "";
  position: absolute;
  inset: 10px;
  background: var(--paper);
  border-radius: 50%;
}
.score-ring strong { position: relative; font-size: 26px; font-weight: 700; }
.score-hero h2 { margin: 0; font-size: 21px; font-weight: 700; }
.score-hero p { color: var(--muted); font-size: 13.5px; }

.chapter-breakdown { display: grid; gap: 8px; margin: 12px 0 20px; }
.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 13px;
}
.review-item {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px;
  margin: 10px 0;
}
.review-item h3 { font-size: 14.5px; font-weight: 600; margin: 0 0 8px; }
.review-item p { font-size: 13px; margin: 5px 0; }
.review-item .right { color: var(--good); }
.review-item .wrong { color: var(--bad); }

/* Flashcards */
.flash-layout { max-width: 740px; margin: auto; }
.flashcard {
  height: 310px;
  perspective: 1200px;
  cursor: pointer;
  margin: 16px 0;
}
.flash-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  transform-style: preserve-3d;
}
.flashcard.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
}
.flash-face.back {
  transform: rotateY(180deg);
  background: var(--paper-subtle);
  border-top-color: var(--good);
  color: var(--ink);
}
.flash-face small {
  position: absolute;
  top: 18px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 11px;
  font-weight: 700;
}
.flash-face h2 { font-size: 20px; font-weight: 600; line-height: 1.4; margin: 0; }
.flash-face p { font-size: 16px; line-height: 1.58; margin: 0; }
.flash-hint {
  position: absolute;
  bottom: 16px;
  font-size: 11.5px;
  color: var(--muted);
}
.flash-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.flash-selfcheck {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.flash-selfcheck input {
  flex: 1;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
}

/* Formulas */
.formula-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.formula-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.formula-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.formula-item b {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}
.formula-item code, .formula-eq {
  display: block;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.85;
  white-space: normal;
  background: var(--formula-bg);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--formula-border);
  border-left: 4px solid var(--accent);
  transition: filter 0.18s ease;
}
.formula-note {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.5;
}
.formula-item.masked { cursor: pointer; }
.formula-item.masked code, .formula-item.masked .formula-eq, .formula-item.masked .formula-note {
  filter: blur(7px);
  user-select: none;
}

/* Study Plan */
.plan-list { display: grid; gap: 10px; }
.plan-day {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.plan-day:hover {
  border-color: var(--accent);
}
.plan-day.done {
  opacity: 0.75;
  background: var(--paper-subtle);
}
.day-number {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13.5px;
}
.plan-day h3 { margin: 0 0 3px; font-size: 14.5px; font-weight: 600; }
.plan-day p { margin: 0; color: var(--muted); font-size: 13px; }
.plan-check {
  margin-left: auto;
  width: 20px;
  height: 20px;
  accent-color: var(--good);
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 16px 0;
}
.method {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}
.method b { display: block; margin-bottom: 5px; font-size: 14px; color: var(--ink); }
.method p { color: var(--muted); font-size: 12.5px; margin: 0; }

/* Tabs & Exercise Generators */
.mode-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.mode-tab {
  border: 0;
  border-bottom: 2.5px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: -1px;
  transition: all 0.14s ease;
}
.mode-tab:hover {
  color: var(--ink);
  background: var(--paper-hover);
}
.mode-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
}

.exercise-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.exercise-list {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  display: grid;
  gap: 3px;
  box-shadow: var(--shadow-xs);
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow: auto;
}
.exercise-list button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.38;
  transition: background 0.12s, color 0.12s;
}
.exercise-list button:hover {
  background: var(--paper-hover);
  color: var(--ink);
}
.exercise-list button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.exercise-list button small {
  display: block;
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

.exercise-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 30px;
  box-shadow: var(--shadow);
}
.exercise-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}
.exercise-head h2 {
  margin: 2px 0 4px;
  font-size: 20px;
  font-weight: 700;
}
.exercise-head p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}
.data-cell {
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.data-cell span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}
.data-cell strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.calc-fields { display: grid; gap: 12px; margin: 16px 0; }
.calc-row {
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  transition: border-color 0.15s;
}
.calc-row:focus-within {
  border-color: var(--accent);
}
.calc-row.correct {
  background: var(--good-soft);
  border-color: var(--good-border);
}
.calc-row.wrong {
  background: var(--bad-soft);
  border-color: var(--bad-border);
}
.calc-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 8px;
}
.calc-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.calc-input {
  width: 190px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.calc-input.is-correct {
  border-color: var(--good);
  color: var(--good);
}
.calc-input.is-wrong {
  border-color: var(--bad);
  color: var(--bad);
}
.calc-unit {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}
.calc-explain {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.55;
}

.score-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  font-weight: 600;
  font-size: 13.5px;
}
.score-banner.good {
  background: var(--good-soft);
  color: var(--ink);
  border: 1px solid var(--good-border);
}
.score-banner.mid {
  background: var(--warning-soft);
  color: var(--ink);
  border: 1px solid var(--warning-border);
}
.score-banner.bad {
  background: var(--bad-soft);
  color: var(--ink);
  border: 1px solid var(--bad-border);
}

.classifier-list { display: grid; gap: 10px; margin: 14px 0; }
.classifier-item {
  border: 1px solid var(--line);
  background: var(--paper-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.classifier-item.correct {
  background: var(--good-soft);
  border-color: var(--good-border);
}
.classifier-item.wrong {
  background: var(--bad-soft);
  border-color: var(--bad-border);
}
.classifier-item p {
  margin: 0 0 9px;
  font-weight: 500;
  font-size: 13.5px;
}
.cat-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-pill {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  transition: all 0.12s ease;
}
.cat-pill:hover {
  border-color: var(--accent);
  background: var(--paper-hover);
}
.cat-pill.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.cat-pill.right-choice {
  background: var(--good);
  border-color: var(--good);
  color: white;
}
.cat-pill.wrong-choice {
  background: var(--bad);
  border-color: var(--bad);
  color: white;
}

.cloze-list { display: grid; gap: 10px; margin: 14px 0; }
.cloze-item {
  border: 1px solid var(--line);
  background: var(--paper-subtle);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 13.5px;
  line-height: 1.65;
}
.cloze-item.correct {
  background: var(--good-soft);
  border-color: var(--good-border);
}
.cloze-item.wrong {
  background: var(--bad-soft);
  border-color: var(--bad-border);
}
.cloze-select {
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  font-weight: 600;
  font-size: 13px;
  margin: 0 4px;
  color: var(--accent);
}

/* Floating Calculator & Scratchpad Drawer */
.calc-drawer {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 340px;
  max-width: calc(100vw - 28px);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 45;
  overflow: hidden;
}
.calc-drawer[hidden] { display: none !important; }
.calc-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: var(--paper-subtle);
  border-bottom: 1px solid var(--line);
}
.calc-drawer-head strong {
  display: block;
  font-size: 13.5px;
}
.calc-drawer-head small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.calc-drawer-body {
  padding: 12px 14px;
  display: grid;
  gap: 9px;
}
.calc-expr-row {
  display: flex;
  gap: 6px;
}
.calc-expr-input {
  flex: 1;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--paper);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.calc-result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.calc-keypad {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.calc-key {
  border: 1px solid var(--line-strong);
  background: var(--paper-subtle);
  border-radius: 5px;
  padding: 5px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.calc-key:hover {
  border-color: var(--accent);
  background: var(--paper-hover);
}
.calc-history {
  max-height: 76px;
  overflow: auto;
  font-size: 11.5px;
  color: var(--muted);
  display: grid;
  gap: 3px;
}
.calc-hist-item {
  display: flex;
  justify-content: space-between;
  padding: 3px 6px;
  background: var(--paper-subtle);
  border-radius: 4px;
  cursor: pointer;
}
.calc-hist-item:hover {
  color: var(--ink);
}
.scratch-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.scratch-area {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 9px;
  background: var(--paper-subtle);
  font-size: 12px;
  resize: vertical;
  line-height: 1.45;
}

/* Global Search / Command Palette Modal */
.cmd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(3px);
  z-index: 60;
  display: grid;
  place-items: start center;
  padding: 10vh 16px 24px;
}
.cmd-backdrop[hidden] { display: none !important; }
.cmd-dialog {
  width: 100%;
  max-width: 640px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.cmd-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.cmd-search-bar svg { color: var(--muted); flex-shrink: 0; }
.cmd-search-bar input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
}
.cmd-results {
  max-height: 60vh;
  overflow: auto;
  padding: 8px;
  display: grid;
  gap: 4px;
}
.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: background 0.12s;
}
.cmd-item:hover {
  background: var(--paper-hover);
  border-color: var(--line);
}
.cmd-item b {
  display: block;
  font-size: 13px;
  color: var(--ink);
}
.cmd-item small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}
.cmd-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.settings {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--navy);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.overlay { display: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }
.no-margin { margin: 0; }
.desktop-inline { display: inline; }

@media (max-width: 1050px) {
  .subject-grid { grid-template-columns: 1fr; }
  .subject-card { min-height: 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .learn-layout, .exercise-layout { grid-template-columns: 220px minmax(0, 1fr); }
  #app { padding: 24px 20px 56px; }
  .article, .exercise-card { padding: 22px; }
  .method-grid { grid-template-columns: 1fr; }
  .cmd-trigger-text { display: none; }
}

@media (max-width: 760px) {
  :root { --sidebar: 268px; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .main-column { margin-left: 0; }
  .mobile-only { display: inline-grid; place-items: center; }
  .desktop-inline { display: none; }
  .topbar { padding: 0 14px; height: 56px; }
  .save-status, .cmd-trigger kbd { display: none; }
  .breadcrumb { font-size: 12.5px; }
  #app { padding: 18px 14px 48px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head h1, .hero h1 { font-size: 21px; }
  .hero { padding: 20px; }
  .subject-grid, .grid-2, .formula-grid { grid-template-columns: 1fr; }
  .stats-row { gap: 10px; }
  .stat-card { padding: 13px; }
  .stat-card strong { font-size: 19px; }
  .learn-layout, .exercise-layout { display: block; }
  .chapter-list, .exercise-list { position: static; max-height: 220px; margin-bottom: 12px; }
  .article, .exercise-card { padding: 18px 15px; }
  .article-header h2 { font-size: 18px; }
  .quiz-card { padding: 20px 16px; }
  .quiz-card h2 { font-size: 16.5px; }
  .quiz-footer { flex-wrap: wrap; }
  .flashcard { height: 320px; }
  .flash-face { padding: 24px 18px; }
  .flash-face h2 { font-size: 18px; }
  .flash-face p { font-size: 15px; }
  .overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
  }
  body.menu-open .overlay { opacity: 1; pointer-events: auto; }
  .settings { flex-direction: column; }
  .settings .btn { width: 100%; }
}

@media print {
  body { background: white; color: black; font-size: 11pt; }
  .sidebar, .topbar, .no-print, .toast, .overlay, .calc-drawer, .cmd-backdrop { display: none !important; }
  .main-column { margin: 0; }
  #app { max-width: none; padding: 0; }
  .article, .card, .quiz-card, .formula-item, .exercise-card { border: 0; box-shadow: none; }
  .article, .exercise-card { padding: 0; }
  .learn-layout, .exercise-layout { display: block; }
  .chapter-list, .exercise-list { display: none; }
  .hero { border: 0; padding: 0; box-shadow: none; }
  .article h3 { break-after: avoid; }
  .article table, .review-item, .formula-item { break-inside: avoid; }
  .flashcard { display: none; }
}

/* ==========================================================
   Material polish layer: motion tokens, elevation, state layers
   ========================================================== */
:root {
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-1: 120ms; --dur-2: 220ms; --dur-3: 380ms; --dur-4: 560ms;
  --radius: 16px; --radius-lg: 24px; --radius-sm: 12px;
  --elev-1: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px 1px rgba(15,23,42,.05);
  --elev-2: 0 1px 2px rgba(15,23,42,.08), 0 2px 6px 2px rgba(15,23,42,.07);
  --elev-3: 0 4px 8px 3px rgba(15,23,42,.08), 0 1px 3px rgba(15,23,42,.1);
}
html[data-theme="dark"] {
  --elev-1: 0 1px 2px rgba(0,0,0,.4), 0 1px 3px 1px rgba(0,0,0,.3);
  --elev-2: 0 1px 2px rgba(0,0,0,.45), 0 2px 6px 2px rgba(0,0,0,.35);
  --elev-3: 0 4px 8px 3px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.5);
}
body { background-image: radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%); background-attachment: fixed; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
html { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; border: 3px solid transparent; }

/* Page enter: staggered rise */
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
#app.view-enter > * { animation: riseIn var(--dur-4) var(--ease-emphasized) both; }
#app.view-enter > *:nth-child(2) { animation-delay: 50ms; }
#app.view-enter > *:nth-child(3) { animation-delay: 100ms; }
#app.view-enter > *:nth-child(4) { animation-delay: 150ms; }
#app.view-enter > *:nth-child(n+5) { animation-delay: 200ms; }
#app.view-enter .subject-card, #app.view-enter .stat-card, #app.view-enter .plan-day, #app.view-enter .chapter-row-item {
  animation: riseIn var(--dur-4) var(--ease-emphasized) both;
}
#app.view-enter .subject-card:nth-child(2), #app.view-enter .stat-card:nth-child(2), #app.view-enter .plan-day:nth-child(2) { animation-delay: 80ms; }
#app.view-enter .subject-card:nth-child(3), #app.view-enter .stat-card:nth-child(3), #app.view-enter .plan-day:nth-child(3) { animation-delay: 140ms; }
#app.view-enter .stat-card:nth-child(4), #app.view-enter .plan-day:nth-child(4) { animation-delay: 200ms; }
#app.view-enter .plan-day:nth-child(n+5) { animation-delay: 260ms; }

/* Cards: elevation that responds */
.card, .stat-card, .subject-card, .article, .formula-item, .exercise-card, .quiz-card, .review-item, .plan-day {
  border-radius: var(--radius);
  box-shadow: var(--elev-1);
  transition: box-shadow var(--dur-2) var(--ease-standard), transform var(--dur-2) var(--ease-standard), border-color var(--dur-2) var(--ease-standard), background-color var(--dur-2);
}
.subject-card:hover, .stat-card:hover, .plan-day:hover, .formula-item:hover, .chapter-row-item:hover {
  box-shadow: var(--elev-3);
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.subject-card:active, .plan-day:active { transform: translateY(-1px) scale(.992); }

/* Buttons: state layers, pressed depth, tonal fills */
.btn, .pill, .icon-button, .tool-pill {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: 999px;
  transition: box-shadow var(--dur-2) var(--ease-standard), transform var(--dur-1) var(--ease-standard), background-color var(--dur-2), color var(--dur-2), border-color var(--dur-2);
}
.btn::after, .pill::after, .icon-button::after, .tool-pill::after, .main-nav button::after, .answer::after {
  content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; pointer-events: none; transition: opacity var(--dur-2); z-index: -1;
}
.btn:hover::after, .pill:hover::after, .icon-button:hover::after, .tool-pill:hover::after, .main-nav button:hover::after { opacity: .07; }
.btn:active::after, .pill:active::after { opacity: .12; }
.btn-primary { box-shadow: var(--elev-1); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--elev-2); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: scale(.97); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-large { padding-inline: 28px; }
.btn.btn-primary::after { background: #fff; }
.has-ripple { overflow: hidden; }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .16; transform: scale(0); animation: ripple 650ms var(--ease-standard) forwards; pointer-events: none; z-index: 0; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* Navigation: active pill with indicator */
.main-nav button { border-radius: 999px; position: relative; overflow: hidden; transition: background-color var(--dur-2), color var(--dur-2), transform var(--dur-1); padding: 10px 16px; }
.main-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.main-nav button.active svg { color: var(--accent); transform: scale(1.1); }
.main-nav button svg { transition: transform var(--dur-2) var(--ease-spring), color var(--dur-2); }
.main-nav button:hover svg { transform: translateX(2px); }
.main-nav button:active { transform: scale(.98); }
.topbar { backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); background-color: color-mix(in srgb, var(--paper) 78%, transparent); }

/* Progress: clean solid fill */
.bar { height: 8px; }
.bar > span { position: relative; overflow: hidden; transition: width var(--dur-4) var(--ease-emphasized); background: var(--accent); }
.bar > span::after { display: none; animation: none; }

/* Quiz */
.answer { border-radius: var(--radius); position: relative; overflow: hidden; transition: transform var(--dur-2) var(--ease-standard), border-color var(--dur-2), background-color var(--dur-2), box-shadow var(--dur-2); }
.answer:hover:not(:disabled) { transform: translateX(4px); box-shadow: var(--elev-1); }
.answer:active:not(:disabled) { transform: scale(.99); }
.answer-letter { transition: background-color var(--dur-2), color var(--dur-2), transform var(--dur-2) var(--ease-spring); }
.answer.selected .answer-letter, .answer.correct .answer-letter { transform: scale(1.12); }
.answer.correct { animation: popOk var(--dur-3) var(--ease-spring); }
.answer.incorrect { animation: shake var(--dur-3) var(--ease-standard); }
@keyframes popOk { 0% { transform: scale(.98); } 50% { transform: scale(1.025); } 100% { transform: none; } }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.answer-mark { animation: markIn var(--dur-3) var(--ease-spring) both; }
@keyframes markIn { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
.feedback { border-radius: var(--radius); animation: slideDown var(--dur-3) var(--ease-emphasized); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px) scaleY(.96); transform-origin: top; } to { opacity: 1; transform: none; } }
.quiz-dot { transition: transform var(--dur-2) var(--ease-spring), background-color var(--dur-2), border-color var(--dur-2); }
.quiz-dot:hover { transform: scale(1.15); }
.quiz-dot.current { transform: scale(1.18); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.streak-badge { transition: transform var(--dur-2) var(--ease-spring); }
.quiz-card { box-shadow: var(--elev-2); border-radius: var(--radius-lg); }

/* Score ring animates from 0 */
@property --score { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.score-ring { animation: ringFill 1.1s var(--ease-emphasized) both; }
@keyframes ringFill { from { --score: 0%; transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.score-ring strong { animation: riseIn var(--dur-4) var(--ease-emphasized) .3s both; }


/* Flashcards: springy flip */
.flash-inner { transition: transform var(--dur-4) var(--ease-emphasized); }
.flashcard { transition: transform var(--dur-2) var(--ease-standard); }
.flashcard:hover { transform: translateY(-3px); }
.flashcard:active { transform: scale(.99); }
.flash-face { border-radius: var(--radius-lg); box-shadow: var(--elev-2); }
html[data-theme="dark"] .flash-face.back { background: var(--paper-subtle); }
.flash-face.back { background: color-mix(in srgb, var(--good-soft) 60%, var(--paper)); }
.flash-hint { animation: pulseHint 2.4s ease-in-out infinite; }
@keyframes pulseHint { 50% { opacity: .45; } }

/* Inputs & forms */
input[type=text], input[type=number], select, textarea { border-radius: var(--radius-sm); transition: border-color var(--dur-2), box-shadow var(--dur-2), background-color var(--dur-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.segmented button { transition: background-color var(--dur-2), color var(--dur-2), box-shadow var(--dur-2), transform var(--dur-1); }
.segmented button:active { transform: scale(.97); }
.segmented button.active { box-shadow: var(--elev-1); }

/* Content blocks & disclosure */
.summary-box, .callout, .memory, .notice { border-radius: var(--radius); transition: box-shadow var(--dur-2), transform var(--dur-2); }
.callout:hover, .memory:hover { box-shadow: var(--elev-1); transform: translateY(-1px); }
details.quick-check { border-radius: var(--radius); transition: box-shadow var(--dur-2); }
details.quick-check[open] { box-shadow: var(--elev-1); }
details.quick-check[open] .quick-check-body { animation: slideDown var(--dur-3) var(--ease-emphasized); }
details > summary { transition: background-color var(--dur-2); }
details > summary:hover { background: var(--paper-hover); }
.table-wrap { border-radius: var(--radius); }
table tbody tr { transition: background-color var(--dur-1); }
table tbody tr:hover { background: var(--accent-soft); }

/* Toast: bouncy snackbar */
.toast { border-radius: 14px; box-shadow: var(--elev-3); transition: opacity var(--dur-2), transform var(--dur-3) var(--ease-spring); }

/* Focus ring everywhere */
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 3px; border-radius: 12px; }

/* Theme switch smoothness */
body, .sidebar, .topbar, .card, .article, .quiz-card, .answer, .flash-face { transition-property: background-color, border-color, color, box-shadow, transform; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print { #app.view-enter > *, .quiz-card, .score-hero { animation: none !important; } }

/* Search highlights & snippets */
mark { background: color-mix(in srgb, #facc15 55%, transparent); color: inherit; padding: 0 2px; border-radius: 4px; box-shadow: 0 0 0 1px color-mix(in srgb, #eab308 45%, transparent); animation: markPulse 1.4s var(--ease-standard) .2s 1; }
@keyframes markPulse { 30% { background: color-mix(in srgb, #facc15 90%, transparent); } }
.cmd-snippet { display: block; margin: 3px 0 2px; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); font-weight: 400; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chapter-snippet { display: block; margin-top: 3px; font-size: 11.5px; font-weight: 400; line-height: 1.4; color: var(--muted); white-space: normal; }
.chapter-list button { height: auto; }
.chapter-list button > span:first-child { white-space: normal; }

/* Calculator */
.calc-drawer { width: 320px; border-radius: var(--radius-lg); box-shadow: var(--elev-3), var(--shadow-lg); animation: calcIn var(--dur-3) var(--ease-emphasized); }
@keyframes calcIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
.calc-expr-input { font-size: 17px; padding: 10px 14px; border-radius: 12px; width: 100%; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.calc-expr-row { display: block; }
.calc-result-bar { min-height: 48px; border-radius: 12px; background: var(--paper-subtle); color: var(--muted); transition: background-color var(--dur-2), color var(--dur-2); }
.calc-result-bar.ok { background: var(--accent-soft); color: var(--accent); }
.calc-result-bar.committed { animation: popOk var(--dur-3) var(--ease-spring); }
.calc-result-bar.err { background: var(--bad-soft); color: var(--bad); }
.calc-value { font-size: 20px; font-weight: 700; letter-spacing: -.2px; word-break: break-all; }
.calc-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.calc-actions small { font-size: 11px; opacity: .8; }
.calc-actions .pill { padding: 3px 12px; font-size: 12px; }
.calc-hint { font-size: 12px; }
.calc-keypad { grid-template-columns: repeat(5, 1fr); gap: 6px; }
.calc-key { padding: 11px 0; font-size: 15px; border-radius: 12px; border: 0; background: var(--paper-subtle); position: relative; overflow: hidden; transition: transform var(--dur-1), background-color var(--dur-2); }
.calc-key:hover { background: var(--paper-hover); }
.calc-key:active { transform: scale(.92); }
.calc-key.key-op { background: var(--accent-soft); color: var(--accent); }
.calc-key.key-fn { color: var(--ink-2); font-size: 13px; }
.calc-key.key-clear { color: var(--bad); }
.calc-key.key-eq { background: var(--accent); color: #fff; box-shadow: var(--elev-1); }
.calc-key.key-eq:hover { filter: brightness(1.08); }
.calc-hist-item { border-radius: 8px; padding: 5px 9px; transition: background-color var(--dur-1); }
.calc-hist-item:hover { background: var(--accent-soft); color: var(--accent); }
.calc-history { max-height: 96px; }

/* ==========================================================================
   Material Design 3 refinement layer
   Tonal surfaces, state layers, pill controls, standard motion.
   Material Design 3 (M3) Complete Token System
   ========================================================================== */
:root {
  /* M3 System Colors (Light) */
  --md-sys-color-primary: #005ac1;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d8e2ff;
  --md-sys-color-on-primary-container: #001a41;
  --md-sys-color-secondary: #575e71;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #dbe2f9;
  --md-sys-color-on-secondary-container: #141b2c;
  --md-sys-color-tertiary: #715573;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #fcd7fd;
  --md-sys-color-on-tertiary-container: #29132d;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-surface: #fdfbff;
  --md-sys-color-on-surface: #1a1b1f;
  --md-sys-color-surface-variant: #e1e2ec;
  --md-sys-color-on-surface-variant: #44474f;
  --md-sys-color-outline: #74777f;
  --md-sys-color-outline-variant: #c4c6d0;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f7f3f8;
  --md-sys-color-surface-container: #f1edf3;
  --md-sys-color-surface-container-high: #ebe7ed;
  --md-sys-color-surface-container-highest: #e5e1e7;

  /* Aliases for earlier variables */
  --md-primary: var(--md-sys-color-primary);
  --md-on-primary: var(--md-sys-color-on-primary);
  --md-primary-container: var(--md-sys-color-primary-container);
  --md-on-primary-container: var(--md-sys-color-on-primary-container);
  --md-secondary-container: var(--md-sys-color-secondary-container);
  --md-on-secondary-container: var(--md-sys-color-on-secondary-container);
  --md-surface: var(--md-sys-color-surface);
  --md-surface-1: var(--md-sys-color-surface-container-low);
  --md-surface-2: var(--md-sys-color-surface-container);
  --md-surface-3: var(--md-sys-color-surface-container-high);
  --md-on-surface: var(--md-sys-color-on-surface);
  --md-on-surface-var: var(--md-sys-color-on-surface-variant);
  --md-outline: var(--md-sys-color-outline);
  --md-outline-var: var(--md-sys-color-outline-variant);

  --md-ease: cubic-bezier(0.2, 0, 0, 1);
  --md-ease-emph: cubic-bezier(0.3, 0, 0, 1);

  /* Elevation */
  --md-sys-elevation-0: none;
  --md-sys-elevation-1: 0 1px 3px 1px rgba(0, 0, 0, 0.12), 0 1px 2px 0 rgba(0, 0, 0, 0.24);
  --md-sys-elevation-2: 0 2px 6px 2px rgba(0, 0, 0, 0.12), 0 1px 2px 0 rgba(0, 0, 0, 0.24);
  --md-sys-elevation-3: 0 4px 8px 3px rgba(0, 0, 0, 0.12), 0 1px 3px 0 rgba(0, 0, 0, 0.24);

  --ink: var(--md-sys-color-on-surface);
  --ink-2: var(--md-sys-color-on-surface-variant);
  --muted: #5f616b;
  --line: var(--md-sys-color-outline-variant);
  --line-strong: var(--md-sys-color-outline);
  --paper: var(--md-sys-color-surface-container-lowest);
  --paper-subtle: var(--md-sys-color-surface-container-low);
  --paper-hover: var(--md-sys-color-surface-container-high);
  --canvas: var(--md-sys-color-surface);
  --accent: var(--md-sys-color-primary);
  --accent-soft: var(--md-sys-color-primary-container);
  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 28px;
  --shadow-xs: none;
  --shadow: var(--md-sys-elevation-1);
  --shadow-md: var(--md-sys-elevation-2);
  --shadow-lg: var(--md-sys-elevation-3);
}
html[data-theme="dark"] {
  --md-sys-color-primary: #adc6ff;
  --md-sys-color-on-primary: #002e69;
  --md-sys-color-primary-container: #004494;
  --md-sys-color-on-primary-container: #d8e2ff;
  --md-sys-color-secondary: #bec6dc;
  --md-sys-color-on-secondary: #293041;
  --md-sys-color-secondary-container: #3f4759;
  --md-sys-color-on-secondary-container: #dbe2f9;
  --md-sys-color-tertiary: #debce0;
  --md-sys-color-on-tertiary: #402843;
  --md-sys-color-tertiary-container: #583e5a;
  --md-sys-color-on-tertiary-container: #fcd7fd;
  --md-sys-color-error: #ffb4ab;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;
  --md-sys-color-surface: #111318;
  --md-sys-color-on-surface: #e2e2e6;
  --md-sys-color-surface-variant: #44474f;
  --md-sys-color-on-surface-variant: #c4c6d0;
  --md-sys-color-outline: #8e9099;
  --md-sys-color-outline-variant: #44474f;
  --md-sys-color-surface-container-lowest: #0c0e13;
  --md-sys-color-surface-container-low: #191c20;
  --md-sys-color-surface-container: #1e2025;
  --md-sys-color-surface-container-high: #282a2f;
  --md-sys-color-surface-container-highest: #33353a;

  --md-primary: var(--md-sys-color-primary);
  --md-on-primary: var(--md-sys-color-on-primary);
  --md-primary-container: var(--md-sys-color-primary-container);
  --md-on-primary-container: var(--md-sys-color-on-primary-container);
  --md-secondary-container: var(--md-sys-color-secondary-container);
  --md-on-secondary-container: var(--md-sys-color-on-secondary-container);
  --md-surface: var(--md-sys-color-surface);
  --md-surface-1: var(--md-sys-color-surface-container-low);
  --md-surface-2: var(--md-sys-color-surface-container);
  --md-surface-3: var(--md-sys-color-surface-container-high);
  --md-on-surface: var(--md-sys-color-on-surface);
  --md-on-surface-var: var(--md-sys-color-on-surface-variant);
  --md-outline: var(--md-sys-color-outline);
  --md-outline-var: var(--md-sys-color-outline-variant);

  --ink: var(--md-sys-color-on-surface);
  --ink-2: var(--md-sys-color-on-surface-variant);
  --muted: #a9aab5;
  --line: var(--md-sys-color-outline-variant);
  --line-strong: var(--md-sys-color-outline);
  --paper: var(--md-sys-color-surface-container);
  --paper-subtle: var(--md-sys-color-surface-container-low);
  --paper-hover: var(--md-sys-color-surface-container-high);
  --canvas: var(--md-sys-color-surface);
  --accent: var(--md-sys-color-primary);
  --accent-soft: var(--md-sys-color-primary-container);
  --shadow: 0 1px 3px 1px rgba(0,0,0,.4);
  --shadow-md: 0 2px 6px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 4px 8px 3px rgba(0,0,0,.4);
}

body {
  font-family: "Roboto", "Google Sans Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: .01em;
  background: var(--md-surface);
  color: var(--md-on-surface);
}
h1, h2, h3, h4 { font-weight: 500; letter-spacing: 0; }
::selection { background: var(--md-primary-container); color: var(--md-on-primary-container); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--md-primary) 55%, transparent) !important; outline-offset: 2px; }

/* Navigation drawer */
.sidebar { background: var(--md-surface-1); border-right: 0; padding: 12px; }
.brand { border-bottom: 0; padding: 8px 12px 16px; }
.brand-mark { background: var(--md-primary); border-radius: 12px; box-shadow: none; }
.brand strong { font-weight: 500; font-size: 16px; letter-spacing: 0; }
.subject-picker { background: var(--md-surface-3); border: 0; border-radius: var(--radius); }
.subject-picker:hover { background: color-mix(in srgb, var(--md-surface-3) 90%, var(--md-primary)); box-shadow: none; }
.subject-quick-btn { border: 1px solid var(--md-outline-var); background: transparent; border-radius: 8px; padding: 6px 4px; font-weight: 500; }
.subject-quick-btn:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); border-color: var(--md-outline-var); }
.subject-quick-btn.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: transparent; }
.nav-section-label { font-size: 12px; font-weight: 500; letter-spacing: .5px; text-transform: none; padding: 20px 16px 8px; color: var(--md-on-surface-var); }
.main-nav { gap: 2px; }
.main-nav button { border-radius: 28px; padding: 0 16px; height: 48px; font-weight: 500; font-size: 14px; letter-spacing: .1px; position: relative; transition: background .2s var(--md-ease); }
.main-nav button:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.main-nav button.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.main-nav button.active svg { color: var(--md-on-secondary-container); }
.sidebar-links .text-button { border-radius: 20px; }

/* Top app bar */
.topbar { background: color-mix(in srgb, var(--md-surface) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 0; box-shadow: none; }
.breadcrumb { font-size: 16px; font-weight: 500; }
.cmd-trigger { background: var(--md-surface-3); border: 0; border-radius: 28px; height: 40px; padding: 0 16px; box-shadow: none; }
.cmd-trigger:hover { background: color-mix(in srgb, var(--md-surface-3) 88%, var(--md-on-surface)); }
.cmd-trigger kbd { background: transparent; border: 0; color: var(--muted); font-size: 11px; }
.tool-pill { border: 1px solid var(--md-outline); background: transparent; border-radius: 20px; height: 40px; padding: 0 16px; font-weight: 500; color: var(--md-primary); }
.tool-pill:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; display: inline-grid; place-items: center; padding: 0; transition: background .2s var(--md-ease); }
.icon-button:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.save-status { font-size: 12px; color: var(--muted); }

/* Surfaces: tonal, border-light cards */
.card, .stat-card, .subject-card, .action-card, .exercise-card, .quiz-card, .config-card, .formula-item,
.flashcard, .article, .plan-day, .review-item, .score-banner, .next-step-banner, .chapter-breakdown {
  background: var(--md-surface-1);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: none;
  transition: background .2s var(--md-ease), box-shadow .2s var(--md-ease), transform .2s var(--md-ease);
}
.subject-card:hover, .action-card:hover, .exercise-card:hover, .formula-item:hover {
  background: var(--md-surface-2);
  box-shadow: var(--shadow);
  transform: none;
}
.hero { border-radius: var(--radius-lg); background: var(--md-primary-container); color: var(--md-on-primary-container); border: 0; box-shadow: none; }
.hero h1, .hero h2, .hero p, .hero .lead { color: inherit; }
.page-head h1 { font-size: 32px; line-height: 40px; font-weight: 400; }
.eyebrow { font-size: 12px; font-weight: 500; letter-spacing: .5px; text-transform: none; color: var(--md-primary); }
.section-title { font-weight: 500; font-size: 20px; }

/* Buttons */
.btn { border-radius: 20px; height: 40px; padding: 0 24px; font-weight: 500; font-size: 14px; letter-spacing: .1px; border: 0; box-shadow: none; position: relative; overflow: hidden; transition: box-shadow .2s var(--md-ease), background .2s var(--md-ease); }
.btn-large { height: 48px; border-radius: 24px; padding: 0 32px; }
.btn-sm { height: 32px; border-radius: 16px; padding: 0 14px; font-size: 12.5px; }
.btn-primary { background: var(--md-primary); color: var(--md-on-primary); }
.btn-primary:hover { box-shadow: var(--shadow); background: color-mix(in srgb, var(--md-primary) 92%, var(--md-on-primary)); }
.btn-secondary, .btn-soft { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn-secondary:hover, .btn-soft:hover { box-shadow: var(--shadow); }
.btn-danger { background: #ba1a1a; color: #fff; }
.btn:disabled { opacity: .38; box-shadow: none; }
.pill, .cat-pill, .toc-pill, .mode-tab, .streak-badge, .subject-pct-pill { border-radius: 8px; font-weight: 500; letter-spacing: .1px; }
.pill, .cat-pill, .toc-pill { background: transparent; border: 1px solid var(--md-outline); color: var(--md-on-surface-var); }
.pill:hover, .cat-pill:hover, .toc-pill:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.cat-pill.active, .toc-pill.active, .pill.active { background: var(--md-secondary-container); border-color: transparent; color: var(--md-on-secondary-container); }
.mode-tabs, .segmented { background: transparent; border: 0; }
.mode-tab.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }

/* Text fields */
input[type="text"], input[type="search"], input[type="number"], select, textarea, .calc-input, .search-box input {
  background: var(--md-surface-3);
  border: 0;
  border-bottom: 1px solid var(--md-outline);
  border-radius: 4px 4px 0 0;
  transition: border-color .2s var(--md-ease), background .2s var(--md-ease);
}
input[type="text"]:focus, input[type="search"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  outline: 0 !important;
  border-bottom: 2px solid var(--md-primary);
  background: color-mix(in srgb, var(--md-surface-3) 92%, var(--md-primary));
}

/* Quiz answers as outlined list items with state layers */
.answer { border: 1px solid var(--md-outline-var); border-radius: var(--radius-sm); background: transparent; transition: background .15s var(--md-ease), border-color .15s var(--md-ease); }
.answer:hover { background: color-mix(in srgb, var(--md-on-surface) 6%, transparent); }
.answer-letter { border-radius: 50%; background: var(--md-surface-3); font-weight: 500; }
.quiz-dot { border-radius: 50%; }
.score-ring { filter: none; }
.bar, .lifeline-bar, .reading-progress-bar, .chapter-progress { border-radius: 4px; }

/* Callouts: tonal containers, no left-stripe look */
.callout, .notice, .warning, .memory, .summary-box, .method, .example, .explanation, .formula, .formula-note, .feedback {
  border-radius: var(--radius);
  box-shadow: none;
}
.table-wrap { border: 1px solid var(--md-outline-var); border-radius: var(--radius); overflow: auto; }
.table-wrap th { background: var(--md-surface-3); font-weight: 500; }

/* Dialogs, drawers, snackbar */
.cmd-backdrop { background: rgba(0,0,0,.32); backdrop-filter: none; }
.cmd-dialog { background: var(--md-surface-3); border: 0; border-radius: 28px; box-shadow: var(--shadow-lg); }
.cmd-item { border-radius: 12px; }
.cmd-item:hover, .cmd-item.active { background: var(--md-secondary-container); }
.calc-drawer { background: var(--md-surface-1); border: 0; border-radius: 28px 0 0 28px; box-shadow: var(--shadow-lg); }
.calc-key { border: 0; border-radius: 16px; background: var(--md-surface-3); font-weight: 500; transition: background .15s var(--md-ease), border-radius .15s var(--md-ease); }
.calc-key:hover { background: color-mix(in srgb, var(--md-surface-3) 85%, var(--md-on-surface)); }
.calc-key:active { border-radius: 24px; }
.calc-key.key-op { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.calc-key.key-eq { background: var(--md-primary); color: var(--md-on-primary); }
.toast { background: #2f3036; color: #f1f0f7; border-radius: 4px; box-shadow: var(--shadow-md); font-size: 14px; }

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

/* ---------- Study features ---------- */
.flash-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; font-size: 12.5px; }
.flash-stat { padding: 3px 12px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); color: var(--muted); }
.flash-stat.good { color: var(--good); border-color: var(--good-border); background: var(--good-soft); }
.flash-stat.box { margin-left: auto; color: var(--accent); background: var(--accent-soft); border-color: transparent; font-weight: 600; }
kbd { font: 600 10.5px/1 ui-monospace, monospace; padding: 2px 6px; margin-left: 4px; border-radius: 5px; border: 1px solid currentColor; opacity: .6; }
.flash-modes { width: 100%; }
.flash-modes button { flex: 1; }
.flash-actions { grid-template-columns: repeat(3, 1fr); }
.flash-actions .btn { flex-direction: column; gap: 2px; padding: 10px 8px; min-height: 56px; border-radius: 16px; }
.flash-actions .btn small { font-size: 11px; opacity: .75; font-weight: 500; }
.rate-again { color: var(--bad); }
.rate-hard { color: var(--warning); }
.answer-text { flex: 1; text-align: left; }
.answer-mark { margin-left: auto; font-weight: 800; font-size: 17px; }
.answer.correct .answer-mark { color: var(--good); }
.answer.incorrect .answer-mark { color: var(--bad); }
.retry-badge { display: inline-block; margin-left: 8px; padding: 1px 9px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-weight: 600; font-size: 11.5px; }
@media (max-width: 640px) { kbd { display: none; } .flash-actions .btn { font-size: 12.5px; } }

/* Dzisiaj: seria i cel */
.today-card { display: grid; gap: 14px; margin: 0 0 18px; padding: 18px 20px; border-radius: var(--radius-lg); background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--paper)), var(--paper)); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)); box-shadow: var(--elev-1); }
.today-main { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.today-streak { display: flex; gap: 10px; align-items: center; }
.today-streak .flame { font-size: 30px; animation: flicker 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes flicker { 50% { transform: scale(1.1) rotate(-4deg); } }
.today-streak b { display: block; font-size: 24px; line-height: 1; }
.today-streak small { color: var(--muted); font-size: 12px; }
.today-goal { flex: 1; min-width: 220px; }
.goal-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; flex-wrap: wrap; }
.today-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Tryb przypominania: rozmyte terminy do odsłonięcia */
.recall-mode .summary-box li b, .recall-mode .memory b, .recall-mode .callout b:not(:first-child), .recall-mode .article-content td b, .recall-mode .quick-check-body b + * b {
  filter: blur(6px); cursor: pointer; transition: filter var(--dur-3) var(--ease-standard), background-color var(--dur-2); border-radius: 4px; user-select: none; background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.recall-mode .summary-box li b:first-child, .recall-mode .summary-box li > b:first-child { filter: none; cursor: default; background: none; user-select: auto; }
.recall-mode b.shown { filter: none !important; user-select: auto; background: color-mix(in srgb, #facc15 30%, transparent) !important; }
.recall-mode .summary-box li b:hover { filter: blur(3px); }
.recall-mode b.shown:hover { filter: none !important; }

/* Sidebar toggle (hamburger) works on desktop and mobile */
.icon-button.mobile-only { display: inline-grid; }
.main-column { transition: margin-left var(--dur-3) var(--ease-emphasized); }
.sidebar { transition: transform var(--dur-3) var(--ease-emphasized), background-color .2s ease; }
@media (min-width: 761px) {
  body.sidebar-collapsed .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-collapsed .main-column { margin-left: 0; }
}

/* ---------- Moduły nauki chapter dropdown & calm Notatki reader ---------- */
.main-nav {
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}
.main-nav button .nav-expand-chevron {
  margin-left: 2px;
  transition: transform var(--dur-2) var(--ease-standard);
  opacity: 0.7;
}
.main-nav button.expanded .nav-expand-chevron {
  transform: rotate(180deg);
}
.nav-chapter-list {
  display: grid;
  gap: 2px;
  padding: 4px 0 8px 18px;
  margin-left: 16px;
  border-left: 2px solid var(--md-outline-var, var(--line));
}
.nav-chapter-list[hidden] {
  display: none !important;
}
.nav-chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--md-on-surface-var, var(--ink-2));
  border-radius: 18px;
  padding: 6px 12px;
  min-height: 34px;
  height: auto !important;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  position: relative;
  overflow: hidden;
  transition: background-color var(--dur-2) var(--ease-standard), color var(--dur-2) var(--ease-standard);
}
.nav-chapter-item:hover {
  background: color-mix(in srgb, var(--md-on-surface, var(--ink)) 8%, transparent);
  color: var(--md-on-surface, var(--ink));
}
.nav-chapter-item.active {
  background: var(--md-secondary-container, var(--accent-soft));
  color: var(--md-on-secondary-container, var(--accent));
  font-weight: 600;
}
.nav-ch-text {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nav-ch-read {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--good-soft);
  color: var(--good);
  font-size: 10.5px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.learn-reader {
  max-width: 840px;
  margin: 0 auto;
}
.learn-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.learn-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 240px;
  flex-wrap: wrap;
}
.inline-chapter-select {
  flex: 1 1 260px;
  max-width: 400px;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.learn-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 210px;
}
.learn-search-input {
  width: 100%;
  font-size: 13px;
  padding: 8px 28px 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
}
.learn-search-clear {
  position: absolute;
  right: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px;
  border-radius: 50%;
}
.learn-search-clear:hover {
  color: var(--ink);
  background: var(--paper-hover);
}

.learn-reader .article {
  padding: 36px 44px;
  line-height: 1.72;
  font-size: 15px;
}
.learn-reader .article-header h2 {
  font-size: 24px;
  line-height: 1.32;
}
.learn-reader .callout:hover,
.learn-reader .memory:hover,
.learn-reader .summary-box:hover,
.learn-reader table tbody tr:hover {
  transform: none;
  box-shadow: none;
}
@media (max-width: 760px) {
  .learn-reader .article {
    padding: 22px 18px;
  }
  .inline-chapter-select, .learn-search-wrap {
    flex: 1 1 100%;
    max-width: none;
  }
}

/* ---------- Interactive Sandboxes in Learn Modules ---------- */
.interactive-sandbox {
  margin: 24px 0;
  padding: 20px 22px;
  background: color-mix(in srgb, var(--accent) 6%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.sandbox-header {
  margin-bottom: 8px;
}
.sandbox-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.sandbox-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.sandbox-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 16px;
  line-height: 1.5;
}
.sandbox-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  background: var(--paper);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.sandbox-control label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.sandbox-control label b {
  color: var(--accent);
  font-size: 13.5px;
}
.sandbox-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 6px;
  margin: 4px 0;
}
.sandbox-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}
.sandbox-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.sandbox-stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sandbox-stat.highlight {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.sandbox-stat small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.sandbox-stat strong {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}
.sandbox-stat span {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ==========================================================================
   Interactive Sandboxes: Live Formulas and Substituted Calculations
   ========================================================================== */
.sandbox-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.sandbox-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.sandbox-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.sandbox-card.highlight {
  background: color-mix(in srgb, var(--accent) 8%, var(--paper));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.sandbox-card .card-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.sandbox-card .card-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.sandbox-card .card-hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}

.sandbox-formula-box {
  margin-top: 16px;
  background: var(--paper);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.sandbox-formula-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.sandbox-formula-title .formula-badge {
  font-size: 10.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0;
  text-transform: none;
}
.formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.formula-item {
  padding: 10px 12px;
  background: color-mix(in srgb, var(--accent) 3%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--accent) 15%, var(--line));
  border-left: 3.5px solid var(--accent);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.formula-item-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.formula-item-raw {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--ink);
  background: color-mix(in srgb, var(--line) 35%, transparent);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 2px 0;
  letter-spacing: 0.2px;
}
.formula-item-raw .katex-display {
  margin: 2px 0;
}
.formula-item-raw .katex,
.formula-item-name .katex,
.formula-item-calc .katex {
  letter-spacing: normal;
}
.formula-item-calc {
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.4;
  word-break: break-word;
}
.formula-item-calc b {
  color: var(--accent);
  font-weight: 700;
}


/* ==================== SZYBKI SPRINT (RAPID FIRE) ==================== */
.rapid-container {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.rapid-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.rapid-streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #ff9800, #f44336);
  color: #fff;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(244,67,54,0.3);
  animation: pulseStreak 1.8s infinite;
}
@keyframes pulseStreak {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.rapid-progress-bar {
  flex: 1;
  max-width: 320px;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin: 0 16px;
}
.rapid-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.rapid-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.rapid-card-topic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 14px;
  border-radius: 20px;
  width: fit-content;
}
.rapid-scenario-card {
  background: color-mix(in srgb, var(--accent) 6%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-left: 4.5px solid var(--accent);
  padding: 18px 22px;
  border-radius: 12px;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink);
}
.rapid-scenario-summary {
  background: var(--paper-hover, rgba(0,0,0,0.02));
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}
.rapid-question-prompt {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
}
.rapid-hint-details {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--paper);
}
.rapid-hint-details summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  outline: none;
  user-select: none;
}
.rapid-hint-details summary:hover {
  text-decoration: underline;
}
.rapid-hint-content {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.rapid-box-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rapid-step-box {
  background: color-mix(in srgb, #0288d1 8%, var(--paper));
  border: 1px solid color-mix(in srgb, #0288d1 25%, transparent);
  border-left: 4px solid #0288d1;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
}
.rapid-trap-box {
  background: color-mix(in srgb, #ed6c02 8%, var(--paper));
  border: 1px solid color-mix(in srgb, #ed6c02 25%, transparent);
  border-left: 4px solid #ed6c02;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
}
.rapid-category-pill {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--line);
  color: var(--ink-2);
}
.rapid-category-pill.math {
  background: color-mix(in srgb, #2e7d32 15%, var(--paper));
  color: #2e7d32;
  border: 1px solid color-mix(in srgb, #2e7d32 30%, transparent);
}
.rapid-category-pill.balance {
  background: color-mix(in srgb, #0288d1 15%, var(--paper));
  color: #0288d1;
  border: 1px solid color-mix(in srgb, #0288d1 30%, transparent);
}
.rapid-category-pill.case {
  background: color-mix(in srgb, #9c27b0 15%, var(--paper));
  color: #9c27b0;
  border: 1px solid color-mix(in srgb, #9c27b0 30%, transparent);
}
.rapid-category-pill.law {
  background: color-mix(in srgb, #e65100 15%, var(--paper));
  color: #e65100;
  border: 1px solid color-mix(in srgb, #e65100 30%, transparent);
}

.rapid-mnemonic-box {
  background: color-mix(in srgb, #9c27b0 8%, var(--paper));
  border: 1px solid color-mix(in srgb, #9c27b0 25%, transparent);
  border-left: 4px solid #9c27b0;
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
}
.rapid-options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rapid-option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.rapid-option-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateX(4px);
}
.rapid-opt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--line);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.rapid-feedback-card {
  border-radius: 12px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rapid-feedback-card.good {
  background: color-mix(in srgb, var(--good) 12%, var(--paper));
  border: 1.5px solid var(--good);
}
.rapid-feedback-card.bad {
  background: color-mix(in srgb, var(--bad) 12%, var(--paper));
  border: 1.5px solid var(--bad);
}
.rapid-summary-card {
  text-align: center;
  padding: 36px 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.rapid-config-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
}
@media (max-width: 768px) {
  .rapid-config-grid { grid-template-columns: 1fr; }
}
.rapid-scope-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.rapid-scope-opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background: var(--paper);
  transition: all 0.15s ease;
}
.rapid-scope-opt:hover {
  border-color: var(--accent);
}
.rapid-scope-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rapid-scope-opt input {
  margin-top: 3px;
}
.rapid-len-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.rapid-topic-toolbar {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rapid-topics-box {
  max-height: 280px;
  overflow-y: auto;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.rapid-topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s ease;
  user-select: none;
}
.rapid-topic-row:hover {
  background: var(--paper-hover, rgba(0,0,0,0.03));
  border-color: var(--line);
}
.rapid-topic-row.selected {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.rapid-topic-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}
.rapid-topic-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--line);
  color: var(--ink-2);
}
.rapid-topic-row.selected .rapid-topic-badge {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--accent);
}
.rapid-topic-group-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  padding: 6px 10px 2px;
  margin-top: 4px;
}

/* ==========================================================================
   Material Design 3 (M3) Specialized Components:
   - Interactive Micro-Calculators (Hands-on Practice & Calculation)
   - 36-Chapter Mastery Matrix (Cognitive Radar & Adaptive Spaced Retrieval)
   - Financial T-Account Bilans Cards
   ========================================================================== */

/* Smart Presets Pills in Rapid Fire Config */
.rapid-presets-bar {
  margin: 12px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rapid-presets-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.rapid-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid var(--md-sys-color-outline-variant, var(--line));
  background: var(--md-sys-color-surface-container-low, var(--paper));
  color: var(--md-sys-color-on-surface, var(--ink));
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--md-ease);
  user-select: none;
}
.preset-chip:hover {
  background: var(--md-sys-color-surface-container-high, var(--paper-hover));
  border-color: var(--md-sys-color-outline, var(--line-strong));
  transform: translateY(-1px);
}
.preset-chip.active {
  background: var(--md-sys-color-secondary-container, var(--accent-soft));
  color: var(--md-sys-color-on-secondary-container, var(--accent));
  border-color: transparent;
  font-weight: 600;
  box-shadow: var(--md-sys-elevation-1);
}

/* 36-Chapter Mastery Matrix */
.mastery-matrix-section {
  margin-top: 20px;
  background: var(--md-sys-color-surface-container-low, var(--paper));
  border: 1px solid var(--md-sys-color-outline-variant, var(--line));
  border-radius: 16px;
  padding: 16px 18px;
}
.mastery-matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.mastery-matrix-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.mastery-matrix-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.mastery-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.mastery-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}
.mastery-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--paper);
  border: 1px solid var(--md-sys-color-outline-variant, var(--line));
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  transition: all 0.12s var(--md-ease);
}
.mastery-chip:hover {
  background: var(--paper-hover);
  border-color: var(--md-sys-color-primary, var(--accent));
}
.mastery-chip.selected {
  background: var(--md-sys-color-secondary-container, var(--accent-soft));
  border-color: var(--md-sys-color-primary, var(--accent));
  font-weight: 600;
}
.mastery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mastery-dot.mastered { background: #16a34a; box-shadow: 0 0 5px rgba(22, 163, 74, 0.6); }
.mastery-dot.learning { background: #ea580c; box-shadow: 0 0 5px rgba(234, 88, 12, 0.6); }
.mastery-dot.unseen { background: #94a3b8; opacity: 0.5; }

/* Interactive Micro-Calculator Widget */
.rapid-calc-widget {
  background: color-mix(in srgb, var(--md-sys-color-primary, #005ac1) 4%, var(--paper));
  border: 1.5px solid color-mix(in srgb, var(--md-sys-color-primary, #005ac1) 25%, transparent);
  border-radius: 16px;
  padding: 18px 20px;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--md-sys-elevation-1);
}
.rapid-calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.rapid-calc-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--md-sys-color-primary, #005ac1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.rapid-calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}
.rapid-calc-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--paper);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.rapid-calc-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rapid-calc-field label b {
  color: var(--md-sys-color-primary, var(--accent));
  font-size: 13px;
}
.rapid-calc-field input[type="range"] {
  width: 100%;
  accent-color: var(--md-sys-color-primary, var(--accent));
  cursor: pointer;
  height: 6px;
  margin: 4px 0;
}
.rapid-calc-field input[type="number"], .rapid-calc-field input[type="text"] {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}
.rapid-calc-output-box {
  background: var(--paper);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-primary, #005ac1) 30%, var(--line));
  border-left: 4px solid var(--md-sys-color-primary, #005ac1);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rapid-calc-out-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.rapid-calc-out-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--md-sys-color-primary, #005ac1);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.rapid-calc-formula {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  margin-top: 4px;
}

/* Material Design 3 Financial T-Account */
.t-account-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin: 16px 0;
  box-shadow: var(--md-sys-elevation-1);
}
.t-account-head {
  background: var(--paper-subtle);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  border-bottom: 2px solid var(--ink);
  letter-spacing: 0.3px;
}
.t-account-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 600px) {
  .t-account-body { grid-template-columns: 1fr; }
}
.t-account-col {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.t-account-col.left {
  border-right: 2px solid var(--ink);
}
@media (max-width: 600px) {
  .t-account-col.left { border-right: none; border-bottom: 2px solid var(--ink); }
}
.t-account-col-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.t-account-col.left .t-account-col-title { color: #005ac1; }
.t-account-col.right .t-account-col-title { color: #715573; }
.t-account-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  padding: 2px 0;
}
.t-account-item .val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.t-account-total {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1.5px solid var(--ink);
  border-bottom: 3.5px double var(--ink);
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 14px;
}



