:root {
  /* Crisp Warm Paper + Clean White Card Palette (Brilliant.org / @PrepSATMath style) */
  --bg-page: #FAF5EC;
  --bg-card: #FFFFFF;
  --bg-subtle: #F3ECE0;
  --bg-hover: #EFE5D4;
  --border-subtle: #E5DAC9;
  --border-strong: #CFC0AA;
  --border-focus: #1F5E9C;
  --text-main: #231915;
  --text-muted: #68564A;
  --accent-blue: #1F5E9C;
  --accent-cyan: #1F5E9C;
  --accent-amber: #B45309;
  --accent-emerald: #1E7E48;
  --accent-coral: #C2410C;
  --accent-purple: #6D28D9;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  --shadow-sm: 0 1px 2px rgba(35, 25, 21, 0.05);
  --shadow-card: 0 2px 8px rgba(35, 25, 21, 0.05), 0 1px 2px rgba(35, 25, 21, 0.04);
  --shadow-modal: 0 20px 25px -5px rgba(35, 25, 21, 0.14), 0 8px 10px -6px rgba(35, 25, 21, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 4rem;
  -webkit-font-smoothing: antialiased;
}

.katex {
  font-size: 1.05em;
}

/* Minimal Material App Bar */
.topbar {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(250, 245, 236, 0.96);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.top-topic-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.top-topic-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.38rem 0.78rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s ease;
}

.top-topic-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.top-topic-btn.active {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--accent-blue);
  box-shadow: var(--shadow-sm);
}

.minimal-split-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 860px) {
  .minimal-split-grid {
    grid-template-columns: 1fr;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent-blue);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #ffffff;
  font-size: 1.1rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Segmented Track Pill Switcher */
.track-switcher {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-subtle);
  padding: 0.25rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.track-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.42rem 0.95rem;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.track-btn:hover {
  color: var(--text-main);
}

.track-btn.active {
  background: var(--bg-card);
  color: var(--accent-blue);
  box-shadow: var(--shadow-sm);
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-chip {
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.user-chip.subscriber {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

/* Main Layout */
.app-shell {
  max-width: 1040px;
  margin: 1.25rem auto 0;
  padding: 0 1.25rem;
  display: block;
}
  align-items: start;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  /* Phones and tablets: the question first, the course list after it */
  .main-workspace { order: 1; }
  .course-sidebar { order: 2; position: static; max-height: none; overflow: visible; }
}

/* Clean Left Navigation Drawer */
.course-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem;
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.sidebar-header {
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.sidebar-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.45rem;
}

.sidebar-progress-fill {
  height: 100%;
  background: var(--accent-blue);
  transition: width 0.25s ease;
}

.sidebar-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0.85rem 0 0.4rem;
  padding: 0 0.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-skill-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.2rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: background 0.14s ease, border-color 0.14s ease;
  font-family: var(--font-sans);
}

.sidebar-skill-btn:hover {
  background: var(--bg-subtle);
}

.sidebar-skill-btn.active {
  background: var(--bg-hover);
  border-color: #bfdbfe;
  color: var(--accent-blue);
}

.sidebar-skill-btn.locked {
  color: var(--text-muted);
}

.skill-row-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.skill-num-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-skill-btn.active .skill-num-circle {
  background: var(--accent-blue);
  color: #ffffff;
}

.skill-num-circle.done {
  background: #dcfce7;
  color: #15803d;
}

.skill-btn-name {
  font-size: 0.81rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-skill-btn.active .skill-btn-name {
  font-weight: 600;
}

.tier-tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.tier-tag.free {
  background: #eff6ff;
  color: var(--accent-blue);
}

.tier-tag.done {
  background: #dcfce7;
  color: #15803d;
}

.tier-tag.locked {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

/* Minimal 4-Step Segmented Bar */
.main-workspace {
  min-width: 0;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  padding: 0.4rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.step-pill {
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.step-pill:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.step-pill.active {
  background: var(--bg-hover);
  color: var(--accent-blue);
}

.step-pill.done {
  color: var(--accent-emerald);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: grid;
  place-items: center;
  font-size: 0.73rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-pill.active .step-num {
  background: var(--accent-blue);
  color: #ffffff;
}

.step-pill.done .step-num {
  background: #dcfce7;
  color: #15803d;
}

.step-label {
  font-size: 0.82rem;
  font-weight: 600;
}

/* Main Content Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--accent-blue);
}

.badge.amber {
  background: #fef3c7;
  color: #b45309;
}

.badge.emerald {
  background: #dcfce7;
  color: #15803d;
}

.badge.coral {
  background: #fee2e2;
  color: #b91c1c;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.015em;
  margin-bottom: 0.35rem;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}

/* Clean Key Concept Strip */
.formula-showcase {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.9rem 1.15rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.formula-main {
  font-size: 1.05rem;
}

.formula-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.math-pill {
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.math-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Clean Question Cards */
.question-block {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.1rem;
}

.question-split {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 880px) {
  .question-split {
    grid-template-columns: 1fr;
  }
}

.mini-figure-wrap {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.55rem;
}

.mini-figure-caption {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.35rem;
}

.question-stem {
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.9rem;
  line-height: 1.6;
}

.options-grid {
  display: grid;
  gap: 0.5rem;
}

.option-btn {
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 0.75rem 0.95rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.14s ease;
  line-height: 1.45;
  font-family: var(--font-sans);
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent-blue);
  background: var(--bg-hover);
}

.option-btn.selected {
  border-color: var(--accent-blue);
  background: var(--bg-hover);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.option-btn.correct-reveal {
  border-color: var(--accent-emerald);
  background: #f0fdf4;
}

.option-btn.wrong-reveal {
  border-color: var(--accent-coral);
  background: #fef2f2;
}

.opt-letter {
  font-weight: 600;
  font-size: 0.78rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-main);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.option-btn.selected .opt-letter {
  background: var(--accent-blue);
  color: #ffffff;
}

.option-btn.correct-reveal .opt-letter {
  background: var(--accent-emerald);
  color: #ffffff;
}

.option-btn.wrong-reveal .opt-letter {
  background: var(--accent-coral);
  color: #ffffff;
}

/* Material Buttons */
.primary-btn {
  background: var(--accent-blue);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  padding: 0.7rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  font-family: var(--font-sans);
}

.primary-btn:hover:not(:disabled) {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  font-weight: 600;
  font-size: 0.84rem;
  padding: 0.65rem 1.05rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: var(--font-sans);
}

.secondary-btn:hover {
  background: var(--bg-subtle);
}

/* Interactive Visual Lab Grid */
.lab-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 920px) {
  .lab-grid {
    grid-template-columns: 1fr;
  }
  .stepper {
    grid-template-columns: repeat(2, 1fr);
  }
}

.canvas-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.canvas-hint-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  padding: 0 0.2rem;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  cursor: ew-resize;
  border: 1px solid var(--border-subtle);
}

.controls-panel {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1.15rem;
}

.control-group {
  margin-bottom: 1rem;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.control-val {
  font-family: var(--font-mono);
  color: var(--accent-blue);
  background: #eff6ff;
  padding: 0.12rem 0.48rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-blue);
  cursor: pointer;
  height: 6px;
}

.live-math-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
}

.callout-box {
  background: #fffbeb;
  border-left: 3.5px solid var(--accent-amber);
  color: var(--text-main);
  padding: 0.8rem 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.callout-box.emerald {
  background: #f0fdf4;
  border-left-color: var(--accent-emerald);
}

.callout-box.coral {
  background: #fef2f2;
  border-left-color: var(--accent-coral);
}

.receipt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem;
  margin: 1.1rem 0;
}

.metric-box {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.95rem;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.metric-value {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 0.2rem;
  font-family: var(--font-mono);
}

.pilot-cta-card {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 1.25rem;
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  max-width: 500px;
  width: 100%;
  padding: 1.65rem;
  box-shadow: var(--shadow-modal);
}

.text-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 0.72rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
  font-family: var(--font-sans);
}

.text-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.timer-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.75rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.json-log {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-main);
  overflow-x: auto;
  max-height: 220px;
  margin-top: 0.75rem;
}

/* ==========================================================================
   RESPONSIVE MOCK A+ FOCUS ARCHITECTURE (Mobile, Tablet, Desktop)
   ========================================================================== */
.mpl-topbar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0.8rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mpl-top-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.mpl-nav-btn {
  padding: 0.48rem 0.95rem;
  font-size: 0.92rem;
  border-radius: 10px;
  min-height: 38px;
}

.mpl-course-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  min-width: 248px;
  max-width: calc(100vw - 24px);
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  padding: 0.38rem;
  z-index: 300;
}

.mpl-course-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.62rem 0.78rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.mpl-course-option:hover {
  background: var(--bg-page);
}

.mpl-course-option.active {
  background: #eff6ff;
  color: var(--accent-blue);
}

.mpl-shell {
  max-width: 780px;
  margin: 1.35rem auto 0;
  padding: 0 1.25rem;
  display: block;
}

/* Keep KaTeX MathML accessible to screen readers while visually hidden */
.katex-mathml {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.mpl-value-strip {
  max-width: 780px;
  margin: 0 auto 0.7rem;
  padding: 0.55rem 0.9rem;
  border-radius: 12px;
  background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
  border: 1px solid #dbeafe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: #1e3a8a;
}

.mpl-value-strip-text {
  font-weight: 500;
  line-height: 1.4;
}

.mpl-value-pills {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  flex-wrap: wrap;
}

.mpl-value-pill {
  border: 1.5px solid #bfdbfe;
  background: #ffffff;
  color: #1e40af;
  border-radius: 999px;
  padding: 0.28rem 0.68rem;
  min-height: 32px;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.14s ease;
}

.mpl-value-pill:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.mpl-value-pill.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}

.mpl-focus-card {
  max-width: 780px;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px -2px rgba(24, 39, 75, 0.06), 0 2px 6px -1px rgba(24, 39, 75, 0.03);
}

.mpl-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}

.mpl-back-btn {
  background: transparent;
  border: none;
  padding: 0.25rem 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  transition: color 0.15s ease;
}

.mpl-back-btn:hover {
  color: var(--accent-blue);
}

.mpl-seg-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  max-width: 265px;
  min-width: 148px;
}

.mpl-seg-bars {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
}

.mpl-seg-bar {
  height: 26px;
  min-width: 30px;
  flex: 1;
  border-radius: 999px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1;
  padding: 0 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.14s ease;
  position: relative;
}

.mpl-seg-bar:hover {
  border-color: #2563eb;
  color: #1d4ed8;
  background: #eff6ff;
  transform: translateY(-1px);
}

.mpl-seg-bar.done.correct {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.mpl-seg-bar.done.wrong {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.mpl-seg-bar.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 0 0 2.5px rgba(37, 99, 235, 0.2);
}

.mpl-seg-counter {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
}

.mpl-visual-box {
  background: #f3f6fc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 0.9rem 1.05rem;
  margin-bottom: 1.25rem;
}

.mpl-visual-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.mpl-visual-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.mpl-slider {
  width: 150px !important;
  height: 7px !important;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.mpl-canvas-wrap {
  position: relative;
  width: 100%;
}

.mpl-canvas-badge-overlay {
  position: static;
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.72rem;
  border-radius: 8px;
  border: 1.25px solid #1f5e9c;
  background: #eff6ff;
  color: #1f5e9c;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mpl-canvas-badge-overlay .katex {
  font-size: 1.03em;
}

.mpl-canvas {
  width: 100%;
  height: 220px;
  display: block;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  touch-action: pan-y;
  transition: height 0.18s ease;
}

.mpl-canvas.expanded {
  height: 320px;
}

.mpl-question-stem {
  font-size: 1.14rem;
  line-height: 1.75;
  max-width: 65ch;
  color: var(--text-main);
  margin-bottom: 1.25rem;
}

.mpl-question-stem .katex {
  font-size: 1.12em;
}

.mpl-stem-question {
  font-weight: 600;
  color: #0f172a;
}

@keyframes mplRerollPulse {
  0% { opacity: 0.55; transform: translateY(2px); }
  100% { opacity: 1; transform: translateY(0); }
}

.mpl-reroll-pulse {
  animation: mplRerollPulse 0.18s ease-out;
}

.mpl-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}

.mpl-option-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 18px;
  min-height: 56px;
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--text-main);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s ease;
}

.mpl-option-btn .katex {
  font-size: 1.06em;
}

.mpl-option-btn:hover:not(:disabled) {
  border-color: #93c5fd;
  background: #f8fafc;
}

.mpl-option-btn.selected {
  border: 2px solid #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.mpl-option-btn.correct-reveal {
  border: 2px solid var(--accent-emerald);
  background: #f0fdf4;
}

.mpl-option-btn.wrong-reveal {
  border: 2px solid var(--accent-coral);
  background: #fef2f2;
}

.mpl-opt-letter {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1.5px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
  background: #f1f5f9;
  color: #334155;
}

.mpl-option-btn.selected .mpl-opt-letter {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.mpl-option-btn.correct-reveal .mpl-opt-letter {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #ffffff;
}

.mpl-option-btn.wrong-reveal .mpl-opt-letter {
  background: var(--accent-coral);
  border-color: var(--accent-coral);
  color: #ffffff;
}

.mpl-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.mpl-helper-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mpl-pill-btn {
  padding: 0.5rem 0.95rem;
  font-size: 0.88rem;
  border-radius: 999px;
  min-height: 40px;
  font-weight: 600;
}

.mpl-tonal-indigo {
  background: #eef2ff !important;
  color: #1e40af !important;
  border-color: #c7d2fe !important;
}

.mpl-tonal-indigo:hover {
  background: #e0e7ff !important;
}

.mpl-tonal-amber {
  background: #fef3c7 !important;
  color: #92400e !important;
  border-color: #fde68a !important;
}

.mpl-tonal-amber:hover {
  background: #fde68a !important;
}

.mpl-submit-wrap {
  display: flex;
  align-items: center;
  gap: 0.48rem;
}

.mpl-submit-btn {
  padding: 0.58rem 1.45rem;
  font-size: 0.96rem;
  border-radius: 999px;
  min-height: 42px;
  font-weight: 700;
  background: #2563eb;
  color: #ffffff;
}

.mpl-submit-btn:disabled {
  background: #e2e8f0 !important;
  color: #64748b !important;
  border-color: #cbd5e1 !important;
  opacity: 1 !important;
  cursor: not-allowed;
}

.mpl-topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.mpl-topic-card {
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: var(--bg-page);
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.2rem 1.25rem;
  transition: all 0.15s ease;
  display: block;
}

.mpl-topic-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.mpl-subtopic-row {
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1.15rem;
  min-height: 56px;
  border-radius: 14px;
  background: var(--bg-page);
  border: 1.5px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.mpl-topic-card:focus-visible,
.mpl-subtopic-row:focus-visible,
.mpl-option-btn:focus-visible,
.mpl-seg-bar:focus-visible,
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.mpl-back-btn:focus-visible,
.mpl-value-pill:focus-visible,
.mpl-footer-link-btn:focus-visible {
  outline: 2.5px solid #2563eb;
  outline-offset: 2px;
}

.mpl-site-footer {
  max-width: 780px;
  margin: 2rem auto 2.5rem;
  padding: 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.mpl-site-footer-inner {
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mpl-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mpl-footer-links a {
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 600;
}

.mpl-footer-links a:hover {
  text-decoration: underline;
}

.mpl-footer-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #1d4ed8;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.mpl-footer-link-btn:hover {
  text-decoration: underline;
}

.mpl-footer-disclaimer {
  color: #64748b;
  font-size: 0.74rem;
}

.mpl-subtopic-row:hover {
  border-color: var(--accent-blue);
  background: #ffffff;
}

.mpl-subtopic-row.active {
  border: 2px solid var(--accent-blue);
  background: #ffffff;
}

/* Tablet Adjustments (640px to 960px) */
@media (min-width: 640px) and (max-width: 960px) {
  .mpl-topbar-inner,
  .mpl-shell,
  .mpl-focus-card {
    max-width: 740px;
  }
  .mpl-focus-card {
    padding: 1.65rem 1.85rem;
  }
  .mpl-canvas {
    height: 215px;
  }
}

/* Mobile Adjustments (< 640px) */
@media (max-width: 639px) {
  .modal-backdrop {
    padding: 0.75rem;
  }
  .modal-card {
    padding: 1.15rem 1.05rem;
    max-height: calc(100vh - 1.5rem);
    overflow-y: auto;
  }
  .mpl-topbar-inner {
    padding: 0.65rem 0.9rem;
  }
  .mpl-nav-btn {
    padding: 0.42rem 0.78rem;
    font-size: 0.85rem;
    min-height: 36px;
  }
  .mpl-shell {
    margin-top: 0.75rem;
    padding: 0 0.75rem;
  }
  .mpl-focus-card {
    padding: 1.15rem 1.05rem;
    border-radius: 14px;
  }
  .mpl-card-header {
    gap: 0.55rem;
    margin-bottom: 0.95rem;
  }
  .mpl-back-btn {
    font-size: 0.88rem;
  }
  .mpl-seg-bars {
    max-width: 155px;
    gap: 0.25rem;
  }
  .mpl-seg-bar {
    height: 24px;
    min-width: 26px;
    font-size: 0.72rem;
    padding: 0 0.25rem;
  }
  .mpl-visual-box {
    padding: 0.75rem 0.8rem;
    margin-bottom: 1rem;
  }
  .mpl-slider {
    width: 115px !important;
  }
  .mpl-canvas {
    height: 195px;
  }
  .mpl-canvas.expanded {
    height: 285px;
  }
  .mpl-value-strip {
    padding: 0.5rem 0.75rem;
    font-size: 0.76rem;
  }
  .mpl-question-stem {
    font-size: 1.04rem;
    line-height: 1.6;
    margin-bottom: 1rem;
  }
  .mpl-options-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    margin-bottom: 1rem;
  }
  .mpl-option-btn {
    padding: 0.85rem 0.95rem;
    min-height: 52px;
    font-size: 0.98rem;
  }
  .mpl-action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .mpl-helper-btns {
    width: 100%;
    justify-content: space-between;
    gap: 0.38rem;
  }
  .mpl-pill-btn {
    flex: 1;
    text-align: center;
    padding: 0.44rem 0.42rem;
    font-size: 0.76rem;
    white-space: nowrap;
  }
  .mpl-kb-hint {
    display: none;
  }
  .mpl-submit-wrap {
    width: 100%;
    display: flex;
    gap: 0.45rem;
  }
  .mpl-submit-wrap .mpl-prev-btn,
  .mpl-submit-wrap .mpl-next-skip-btn {
    flex: 0 0 auto;
    padding: 0.48rem 0.85rem;
    font-size: 0.84rem;
    min-height: 44px;
  }
  .mpl-submit-btn {
    flex: 1;
    width: auto;
    min-height: 44px;
    font-size: 0.98rem;
  }
  .mpl-topic-grid {
    grid-template-columns: 1fr;
  }
  .mpl-subtopic-row {
    padding: 0.85rem 0.95rem;
  }
}
