/* ==========================================================================
   DuoMath — Duolingo Android Mobile-First Design System
   ========================================================================== */

:root {
  --bg-outer: #EEF3F7;
  --bg-app: #FFFFFF;
  --bg-surface: #F7F7F7;
  --bg-card: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --border-subtle: #E5E5E5;
  --border-strong: #CECECE;
  --text-primary: #3C3C3C;
  --text-secondary: #777777;
  --text-muted: #AFAFAF;

  --duo-green: #58CC02;
  --duo-green-dark: #46A302;
  --duo-green-light: #D7FFB8;
  --duo-green-text: #58A700;

  --duo-blue: #1CB0F6;
  --duo-blue-dark: #1899D6;
  --duo-blue-soft: #DDF4FF;

  --duo-orange: #FF9600;
  --duo-orange-dark: #CC7800;
  --duo-orange-soft: #FFF1D6;

  --duo-gold: #FFC800;
  --duo-gold-dark: #E5A400;

  --duo-red: #FF4B4B;
  --duo-red-dark: #EA2B2B;
  --duo-red-soft: #FFDFE0;

  --duo-purple: #CE82FF;
  --duo-purple-dark: #A55EEA;

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --font-sans: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

html[data-theme="dark"] {
  --bg-outer: #0B1216;
  --bg-app: #131F24;
  --bg-surface: #1A2B32;
  --bg-card: #1A2B32;
  --bg-elevated: #20323B;
  --border-subtle: #37464F;
  --border-strong: #4A5D68;
  --text-primary: #F1F7FB;
  --text-secondary: #A5B7C2;
  --text-muted: #6C808D;

  --duo-green-light: #1A3A1E;
  --duo-green-text: #7BE028;
  --duo-blue-soft: #153447;
  --duo-orange-soft: #3D2B10;
  --duo-red-soft: #3E1C20;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-outer);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
  touch-action: manipulation;
}

/* ==========================================================================
   Viewport & Responsive App Shell (Phone + iPad + Desktop)
   ========================================================================== */

.viewport-stage {
  min-height: 100dvh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  background: var(--bg-app);
}

.fx-canvas-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.app-shell {
  width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  background: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-app-frame {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
}

.main-content-column {
  order: 1;
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.tab-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 24px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Signature Duolingo 3D Tactile Buttons
   ========================================================================== */

.duo-btn {
  width: 100%;
  min-height: 50px;
  padding: 13px 18px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
  user-select: none;
}

.duo-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--btn-shadow, #46A302) !important;
}

.duo-btn-green {
  background: var(--duo-green);
  color: #FFFFFF;
  --btn-shadow: var(--duo-green-dark);
  box-shadow: 0 4px 0 var(--duo-green-dark);
}

.duo-btn-blue {
  background: var(--duo-blue);
  color: #FFFFFF;
  --btn-shadow: var(--duo-blue-dark);
  box-shadow: 0 4px 0 var(--duo-blue-dark);
}

.duo-btn-red {
  background: var(--duo-red);
  color: #FFFFFF;
  --btn-shadow: var(--duo-red-dark);
  box-shadow: 0 4px 0 var(--duo-red-dark);
}

.duo-btn-gold {
  background: var(--duo-gold);
  color: #5A3B00;
  --btn-shadow: var(--duo-gold-dark);
  box-shadow: 0 4px 0 var(--duo-gold-dark);
}

.duo-btn-orange {
  background: var(--duo-orange);
  color: #FFFFFF;
  --btn-shadow: var(--duo-orange-dark);
  box-shadow: 0 4px 0 var(--duo-orange-dark);
}

.duo-btn-purple {
  background: var(--duo-purple);
  color: #FFFFFF;
  --btn-shadow: var(--duo-purple-dark);
  box-shadow: 0 4px 0 var(--duo-purple-dark);
}

.duo-btn-white-orange {
  background: #FFFFFF;
  color: var(--duo-orange-dark);
  --btn-shadow: #FFD494;
  box-shadow: 0 4px 0 #FFD494;
}

.duo-btn-outline {
  background: var(--bg-card);
  color: var(--duo-blue);
  border: 2px solid var(--border-subtle);
  --btn-shadow: var(--border-subtle);
  box-shadow: 0 3px 0 var(--border-subtle);
}

.duo-btn-disabled {
  background: var(--border-subtle);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

/* ==========================================================================
   Toast Banner
   ========================================================================== */

.duo-toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 398px;
  background: #2B3942;
  color: #FFFFFF;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  z-index: 500;
  animation: popIn 0.22s ease-out;
  cursor: pointer;
}

.toast-dismiss {
  opacity: 0.7;
  font-size: 14px;
}

/* ==========================================================================
   Top App Bar & Course Switcher Drawer (Duolingo Android Style)
   ========================================================================== */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: calc(58px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) calc(14px + env(safe-area-inset-right, 0px)) 0 calc(14px + env(safe-area-inset-left, 0px));
  background: var(--bg-app);
  border-bottom: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.top-bar-stats {
  display: contents;
}

.course-pill-name {
  display: none;
  font-size: 13.5px;
  font-weight: 900;
  color: var(--text-primary);
  white-space: nowrap;
}

.icon-svg,
.course-flag-svg {
  display: block;
  flex-shrink: 0;
}

.top-bar-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  gap: 5px;
  padding: 0 8px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  transition: background 0.14s ease, transform 0.08s ease;
}

.top-bar-pill:active {
  transform: scale(0.94);
  background: var(--bg-surface);
}

.course-pill {
  padding: 0 8px 0 4px;
  border: 2px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-card);
}

.course-pill-code {
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.course-pill .caret {
  font-size: 11px;
  color: var(--text-secondary);
}

.streak-pill { color: var(--duo-orange); }
.streak-pill.muted { color: var(--text-muted); }
.heart-pill { color: var(--duo-red); }

.sheet-backdrop {
  position: absolute;
  inset: calc(58px + env(safe-area-inset-top, 0px)) 0 0 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 45;
  animation: fadeIn 0.18s ease;
}

.course-switcher-sheet {
  position: absolute;
  top: calc(58px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  background: var(--bg-app);
  border-bottom: 2px solid var(--border-subtle);
  padding: 14px 16px 18px;
  z-index: 50;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16);
  animation: slideDown 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.course-switcher-inner {
  width: 100%;
  margin: 0 auto;
}

.switcher-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.switcher-title {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.switcher-hint {
  font-size: 12px;
  font-weight: 700;
  color: var(--duo-blue);
}

.course-cards-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.course-choice-card {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid var(--border-subtle);
  box-shadow: 0 3px 0 var(--border-subtle);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.course-choice-card.selected {
  border-color: var(--duo-blue);
  background: var(--duo-blue-soft);
  box-shadow: 0 3px 0 var(--duo-blue);
}

.course-choice-card:active {
  transform: translateY(2px);
}

.course-choice-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.course-choice-meta {
  flex: 1;
  min-width: 0;
}

.course-choice-name {
  font-size: 15.5px;
  font-weight: 900;
  color: var(--text-primary);
}

.course-choice-ref {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-active-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--duo-blue);
  color: #FFFFFF;
  font-weight: 900;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.course-choice-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-progress-track {
  flex: 1;
  height: 9px;
  border-radius: 99px;
  background: var(--border-subtle);
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.35s ease;
}

.course-xp-tag {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ==========================================================================
   Navigation Bar (Mobile Bottom Nav -> iPad Left Rail / Sidebar)
   ========================================================================== */

.bottom-nav {
  order: 2;
  position: relative;
  flex-shrink: 0;
  min-height: calc(68px + env(safe-area-inset-bottom, 0px));
  padding: 6px calc(10px + env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
  background: var(--bg-app);
  border-top: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  z-index: 35;
}

.sidebar-brand {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px;
  border-radius: 16px;
  margin-bottom: 14px;
  transition: background 0.14s ease, transform 0.08s ease;
}

.sidebar-brand:active {
  transform: scale(0.96);
}

.sidebar-brand-title {
  display: none;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--duo-green);
}

.nav-items-group {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  align-items: center;
}

.nav-item {
  height: 54px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 2px solid transparent;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}

.nav-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  line-height: 0;
}

.nav-dot {
  position: absolute;
  top: 0;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--duo-red);
  border: 2px solid var(--bg-app);
}

.nav-item:active {
  transform: scale(0.93);
}

.nav-item.active {
  background: var(--duo-blue-soft);
  border-color: var(--duo-blue);
}

.nav-label {
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.nav-item.active .nav-label {
  color: var(--duo-blue);
}

/* ==========================================================================
   Learn Path View — Unit Banners & Winding S-Curve Nodes
   ========================================================================== */

.learn-path-page {
  padding: 12px 14px 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.course-intro-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
}

.course-intro-badge {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--duo-green);
  color: #FFFFFF;
  flex-shrink: 0;
}

.course-intro-source {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.unit-banner {
  background: var(--unit-color, var(--duo-green));
  color: #FFFFFF;
  border-radius: 18px;
  padding: 16px 16px;
  box-shadow: 0 5px 0 var(--unit-dark, var(--duo-green-dark));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.unit-section-label {
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0.85;
  margin-bottom: 2px;
}

.unit-title {
  margin: 0;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.2;
}

.unit-desc {
  margin: 4px 0 0;
  font-size: 12.5px;
  font-weight: 700;
  opacity: 0.92;
  line-height: 1.35;
}

.guidebook-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.12);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

.guidebook-btn:active {
  transform: translateY(2px);
}

.path-nodes-canvas {
  position: relative;
  padding: 44px 0 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.path-node-row.has-start-below {
  margin-top: 26px;
}

.path-mascot {
  position: absolute;
  top: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}

.path-mascot.right-side { right: 8px; }
.path-mascot.left-side { left: 8px; }

.mascot-speech {
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 12px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
  box-shadow: 0 2px 0 var(--border-subtle);
}

.bobbing {
  animation: bob 3s ease-in-out infinite;
}

.path-node-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 3;
}

.path-node-anchor {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(calc(var(--node-offset, 0px) * var(--path-curve-scale, 1)));
}

.node-ring-stage {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-tooltip-bubble {
  position: absolute;
  top: -36px;
  background: var(--bg-card);
  color: var(--unit-color, var(--duo-green));
  border: 2px solid var(--border-subtle);
  border-radius: 12px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 3px 0 var(--border-subtle);
  animation: startBounce 1.5s ease-in-out infinite;
  z-index: 6;
}

.tooltip-caret {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 11px;
  height: 11px;
  background: var(--bg-card);
  border-right: 2px solid var(--border-subtle);
  border-bottom: 2px solid var(--border-subtle);
}

.node-progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.path-node {
  width: 72px;
  height: 70px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-3px);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.path-node.current {
  background: var(--unit-color, var(--duo-green));
  color: #FFFFFF;
  box-shadow: 0 7px 0 var(--unit-dark, var(--duo-green-dark));
}

.path-node.completed {
  background: linear-gradient(180deg, #FFD84D 0%, #FFC800 100%);
  color: #7C4D00;
  box-shadow: 0 7px 0 #E0A200;
}

.path-node.unlocked {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 2.5px solid var(--border-subtle);
  box-shadow: 0 6px 0 var(--border-strong);
}

.path-node:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--unit-dark, var(--border-strong)) !important;
}

.node-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  position: relative;
  z-index: 2;
}

.node-shine {
  position: absolute;
  top: 8px;
  left: 16px;
  width: 18px;
  height: 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.32);
  transform: rotate(-18deg);
}

.node-caption {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  max-width: 140px;
}

/* Lesson Launch Popover */
.lesson-popover {
  margin-top: 12px;
  width: calc(100% - 12px);
  max-width: 340px;
  background: var(--unit-color, var(--duo-green));
  color: #FFFFFF;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18), 0 5px 0 var(--unit-dark, var(--duo-green-dark));
  animation: popIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 15;
}

.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.popover-title {
  font-size: 18px;
  font-weight: 900;
}

.popover-subtitle {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.92;
  margin-top: 2px;
}

.popover-acc-pill {
  background: rgba(255, 255, 255, 0.22);
  padding: 4px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.popover-meta {
  display: flex;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 800;
  opacity: 0.9;
  margin: 8px 0 14px;
}

.popover-start-btn {
  background: #FFFFFF;
  color: var(--unit-dark, var(--duo-green-dark));
  --btn-shadow: rgba(0, 0, 0, 0.16);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16);
}

/* Guidebook Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.18s ease;
}

.guidebook-modal {
  width: 100%;
  max-width: 430px;
  max-height: 86dvh;
  background: var(--bg-app);
  border-radius: 24px 24px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.guidebook-modal-header {
  padding: 18px 18px 16px;
  color: #FFFFFF;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.guidebook-kicker {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0.88;
}

.guidebook-modal-header h3 {
  margin: 3px 0 0;
  font-size: 20px;
  font-weight: 900;
}

.modal-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 900;
}

.guidebook-cards {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guidebook-card {
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 16px;
  padding: 14px;
}

.guidebook-card-title {
  font-size: 15px;
  font-weight: 900;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.guidebook-formula-box {
  background: var(--bg-surface);
  border-radius: 12px;
  padding: 10px 12px;
  overflow-x: auto;
  margin-bottom: 10px;
  border: 1.5px solid var(--border-subtle);
}

.guidebook-card-summary {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  font-weight: 600;
}

.guidebook-footer {
  padding: 12px 16px 18px;
  border-top: 2px solid var(--border-subtle);
}

/* ==========================================================================
   Full-Screen Lesson Experience (Duolingo Android)
   ========================================================================== */

.lesson-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  position: relative;
}

.lesson-shell.lightning-active {
  box-shadow: inset 0 0 42px rgba(255, 200, 0, 0.22);
}

.lesson-shell.shake-a { animation: shakeA 0.36s ease; }
.lesson-shell.shake-b { animation: shakeB 0.36s ease; }

.lesson-top-bar {
  padding: calc(14px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) 8px calc(16px + env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-shrink: 0;
}

.lesson-close-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lesson-close-btn:active {
  background: var(--bg-surface);
}

.lesson-progress-track {
  flex: 1;
  height: 16px;
  border-radius: 99px;
  background: var(--border-subtle);
  overflow: visible;
  position: relative;
}

.lesson-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--duo-green);
  position: relative;
  transition: width 0.42s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease;
}

.lesson-progress-fill.combo-hot {
  background: linear-gradient(90deg, #FF9600 0%, #FFC800 55%, #FFF078 100%);
  box-shadow: 0 0 16px rgba(255, 200, 0, 0.72);
  animation: comboPulse 0.8s ease-in-out infinite alternate;
}

.progress-highlight {
  position: absolute;
  top: 3px;
  left: 8px;
  right: 8px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.34);
}

.progress-spark-tip {
  position: absolute;
  right: -10px;
  top: -7px;
  font-size: 19px;
  filter: drop-shadow(0 0 6px #FFC800);
  animation: startBounce 0.6s ease-in-out infinite;
}

.lesson-hearts-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 900;
  color: var(--duo-red);
}

.lesson-sub-strip {
  min-height: 26px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.combo-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: var(--duo-orange-soft);
  color: var(--duo-orange-dark);
  animation: popIn 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.combo-pill.hot {
  background: linear-gradient(90deg, #FF9600, #FFC800);
  color: #4A2700;
  box-shadow: 0 0 12px rgba(255, 196, 0, 0.55);
}

.review-pill {
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: var(--duo-red-soft);
  color: var(--duo-red-dark);
}

.lesson-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 16px 20px;
  display: flex;
  flex-direction: column;
}

.question-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: popIn 0.24s ease;
}

.question-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.question-badge {
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hint-pill-btn {
  padding: 5px 10px;
  border-radius: 99px;
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
}

.hint-drawer {
  padding: 10px 13px;
  border-radius: 14px;
  background: var(--duo-blue-soft);
  border: 1.5px solid var(--duo-blue);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  animation: popIn 0.18s ease;
}

.hint-label {
  font-weight: 900;
  color: var(--duo-blue-dark);
}

.question-prompt-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.prompt-bubble {
  flex: 1;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.42;
  color: var(--text-primary);
  position: relative;
}

/* Fill-in-the-Equation */
.fill-eq-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.equation-display-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: 18px;
  padding: 18px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  min-height: 78px;
}

.equation-display-card.compact {
  padding: 12px 14px;
  min-height: 58px;
}

.equation-cloze-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16.5px;
}

.cloze-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 40px;
  padding: 4px 12px;
  border-radius: 12px;
  transition: all 0.15s ease;
}

.cloze-slot.empty {
  border: 2.5px dashed var(--duo-blue);
  background: var(--duo-blue-soft);
  color: var(--duo-blue);
}

.cloze-slot.filled {
  border: 2px solid var(--duo-blue);
  background: var(--bg-card);
  box-shadow: 0 3px 0 var(--duo-blue);
  animation: popIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cloze-qmark {
  font-weight: 900;
  font-size: 18px;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.math-choice-card {
  position: relative;
  min-height: 76px;
  padding: 14px 10px;
  border-radius: 16px;
  border: 2px solid var(--border-subtle);
  box-shadow: 0 4px 0 var(--border-subtle);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease;
}

.math-choice-card:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--border-subtle);
}

.math-choice-card.selected {
  border-color: var(--duo-blue);
  background: var(--duo-blue-soft);
  box-shadow: 0 4px 0 var(--duo-blue);
}

.choice-index-badge {
  position: absolute;
  top: 7px;
  left: 8px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.math-choice-card.selected .choice-index-badge {
  border-color: var(--duo-blue);
  color: var(--duo-blue);
}

.choice-math-inner {
  font-size: 16px;
  padding-top: 4px;
}

.choice-math-inner .katex {
  font-size: 1.24em !important;
}

.lesson-title-crumb {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.inline-code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--duo-blue-dark);
}

html[data-theme="dark"] .inline-code {
  color: #6DD2FF;
}

/* Equation Builder (Duolingo Word-Bank for Math) */
.builder-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.builder-live-preview {
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: 16px;
  padding: 10px 14px 12px;
  overflow-x: auto;
}

.preview-kicker {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.preview-math {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.builder-answer-tray {
  min-height: 62px;
  padding: 10px;
  border-radius: 16px;
  border: 2px dashed var(--border-strong);
  background: var(--bg-card);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tray-placeholder {
  width: 100%;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.builder-bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  padding-top: 4px;
}

.math-token-chip {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 2px solid var(--border-subtle);
  box-shadow: 0 3px 0 var(--border-subtle);
  background: var(--bg-card);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, opacity 0.14s ease;
}

.math-token-chip:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--border-subtle);
}

.math-token-chip.placed {
  border-color: var(--duo-blue);
  background: var(--duo-blue-soft);
  box-shadow: 0 3px 0 var(--duo-blue);
  animation: popIn 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.math-token-chip.used {
  background: var(--border-subtle);
  border-color: var(--border-subtle);
  box-shadow: none;
  opacity: 0.35;
  cursor: default;
}

/* Match Pairs */
.match-pairs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.match-col {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.pair-tile {
  min-height: 64px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 2px solid var(--border-subtle);
  box-shadow: 0 3px 0 var(--border-subtle);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, all 0.15s ease;
}

.pair-tile:active:not(:disabled) {
  transform: translateY(2px);
}

.pair-tile.selected {
  border-color: var(--duo-blue);
  background: var(--duo-blue-soft);
  box-shadow: 0 3px 0 var(--duo-blue);
}

.pair-tile.matched {
  border-color: var(--duo-green);
  background: var(--duo-green-light);
  color: var(--duo-green-text);
  box-shadow: none;
  opacity: 0.62;
}

.pair-tile.wrong-flash {
  border-color: var(--duo-red);
  background: var(--duo-red-soft);
  box-shadow: 0 3px 0 var(--duo-red);
}

/* Math Keypad */
.keypad-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.keypad-input-box {
  min-height: 58px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 2.5px solid var(--duo-blue);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
}

.keypad-typed-value {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}

.keypad-placeholder {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.keypad-caret {
  display: inline-block;
  width: 2.5px;
  height: 22px;
  background: var(--duo-blue);
  border-radius: 2px;
  animation: blink 1s step-end infinite;
}

.math-keypad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.math-key-btn {
  height: 52px;
  border-radius: 14px;
  border: 2px solid var(--border-subtle);
  box-shadow: 0 4px 0 var(--border-subtle);
  background: var(--bg-card);
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s ease;
}

.math-key-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--border-subtle);
}

.math-key-btn.key-action {
  background: var(--bg-surface);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 900;
  color: var(--text-secondary);
}

/* Lesson Footer & Feedback Drawer */
.lesson-footer {
  padding: 14px calc(16px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  border-top: 2px solid var(--border-subtle);
  background: var(--bg-app);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.lesson-footer-inner {
  width: 100%;
  margin: 0 auto;
}

.footer-check-row {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.lesson-footer.correct {
  background: var(--duo-green-light);
  border-top-color: transparent;
  animation: slideUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.lesson-footer.wrong {
  background: var(--duo-red-soft);
  border-top-color: transparent;
  animation: slideUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.feedback-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feedback-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.feedback-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feedback-badge-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  color: #FFFFFF;
  flex-shrink: 0;
}

.feedback-badge-circle.ok { background: var(--duo-green); }
.feedback-badge-circle.err { background: var(--duo-red); }

.feedback-heading {
  font-size: 18px;
  font-weight: 900;
}

.feedback-heading.ok { color: var(--duo-green-text); }
.feedback-heading.err { color: var(--duo-red-dark); }

.feedback-misconception-box {
  background: rgba(255, 75, 75, 0.14);
  border-left: 3.5px solid var(--duo-red);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
}

html[data-theme="dark"] .feedback-misconception-box {
  background: rgba(255, 75, 75, 0.2);
}

.misconception-label {
  color: var(--duo-red-dark);
  font-weight: 900;
}

.feedback-solution-box {
  background: rgba(255, 255, 255, 0.72);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  color: #3C3C3C;
  overflow-x: auto;
}

html[data-theme="dark"] .feedback-solution-box {
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-primary);
}

.solution-label {
  color: var(--duo-red-dark);
  font-weight: 900;
}

.feedback-explanation {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.42;
  color: var(--text-primary);
}

/* ==========================================================================
   Lesson Complete & Streak Ignition Celebration Screen
   ========================================================================== */

.lesson-complete-screen {
  height: 100%;
  width: 100%;
  padding: calc(24px + env(safe-area-inset-top, 0px)) calc(18px + env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) calc(18px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.celebrate-inner {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.celebrate-hero {
  position: relative;
  width: 170px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
}

.sunburst-glow {
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 0, 0.42) 0%, rgba(88, 204, 2, 0.14) 55%, transparent 75%);
  animation: pulseGlow 1.8s ease-in-out infinite alternate;
}

.celebrate-bounce {
  position: relative;
  z-index: 2;
  animation: celebrateBounce 1.1s ease-in-out infinite;
}

.celebrate-title {
  margin: 8px 0 4px;
  font-size: 27px;
  font-weight: 900;
  color: var(--duo-gold-dark);
}

.celebrate-subtitle {
  margin: 0 0 18px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
}

.celebrate-streak-card {
  width: 100%;
  background: linear-gradient(135deg, #FF9600 0%, #FFB800 100%);
  color: #FFFFFF;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 5px 0 var(--duo-orange-dark);
  margin-bottom: 16px;
}

.celebrate-streak-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.streak-flame-big {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #FFFFFF;
  box-shadow: 0 4px 12px rgba(160, 60, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.celebrate-streak-num {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.celebrate-streak-sub {
  font-size: 12.5px;
  font-weight: 700;
  opacity: 0.94;
}

.mini-week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  padding: 10px 8px;
}

.mini-day-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.mini-day-lbl {
  font-size: 11px;
  font-weight: 900;
  opacity: 0.88;
}

.mini-day-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
}

.mini-day-dot.done { background: #FFFFFF; color: var(--duo-orange-dark); }
.mini-day-dot.today { border: 2px dashed #FFFFFF; }
.mini-day-dot.future { background: rgba(255, 255, 255, 0.22); }

.celebrate-stats-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.stat-pill-card {
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid;
  text-align: center;
}

.stat-pill-card.xp-card { border-color: var(--duo-gold); }
.stat-pill-card.acc-card { border-color: var(--duo-green); }

.stat-pill-head {
  padding: 5px 4px;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #FFFFFF;
}

.xp-card .stat-pill-head { background: var(--duo-gold); color: #5C3D00; }
.acc-card .stat-pill-head { background: var(--duo-green); }

.stat-pill-body {
  background: var(--bg-card);
  padding: 12px 6px;
  font-size: 19px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.celebrate-footer {
  margin-top: auto;
  width: 100%;
}

/* ==========================================================================
   Streak, Practice & Profile Tabs
   ========================================================================== */

.tab-page {
  padding: 16px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-heading {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.section-subhead {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-top: 4px;
}

.duo-card {
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card-section-header h3 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 900;
}

.card-subcopy {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Streak Hero */
.streak-hero-card {
  background: linear-gradient(145deg, #FF9600 0%, #FFB800 100%);
  color: #FFFFFF;
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 6px 0 var(--duo-orange-dark);
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
}

.streak-hero-card.lit {
  background: linear-gradient(145deg, #FF7A00 0%, #FFB800 100%);
}

.streak-hero-card.cold {
  background: linear-gradient(145deg, #6E7E8A 0%, #8A9CA8 100%);
  box-shadow: 0 6px 0 #53626E;
}

.streak-society-pill {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.22);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.streak-hero-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.streak-big-number {
  font-size: 56px;
  font-weight: 900;
  line-height: 0.95;
}

.streak-big-label {
  font-size: 20px;
  font-weight: 900;
}

.streak-hero-flame-wrap {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(160, 60, 0, 0.26);
  animation: bob 2.6s ease-in-out infinite;
  flex-shrink: 0;
}

.streak-hero-note {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  opacity: 0.95;
}

.week-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.cal-day-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
}

.cal-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-circle.done { background: var(--duo-orange-soft); border: 2px solid var(--duo-orange); }
.cal-circle.today-pending { border: 2.5px dashed var(--duo-orange); background: var(--bg-surface); }
.cal-circle.missed { background: var(--bg-surface); border: 2px solid var(--border-subtle); opacity: 0.6; }
.cal-circle.future { background: var(--bg-surface); border: 2px solid var(--border-subtle); }

.cal-today-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--duo-orange);
}

.cal-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.xp-fraction {
  font-size: 14px;
  font-weight: 900;
  color: var(--duo-green-text);
}

.goal-bar-track {
  height: 15px;
  border-radius: 99px;
  background: var(--border-subtle);
  overflow: hidden;
}

.goal-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--duo-green) 0%, #89E219 100%);
  transition: width 0.4s ease;
}

.goal-caption {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Practice Tab */
.hearts-row-display {
  display: flex;
  gap: 3px;
}

.hearts-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.drill-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drill-card {
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 16px;
  border: 2px solid var(--border-subtle);
  box-shadow: 0 4px 0 var(--border-subtle);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.08s ease;
}

.drill-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--border-subtle);
}

.drill-card-info {
  flex: 1;
}

.drill-card-title {
  font-size: 15px;
  font-weight: 900;
  color: var(--text-primary);
}

.drill-card-sub {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.drill-play-pill {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--duo-orange-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.juice-badge {
  font-size: 10.5px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--duo-green-light);
  color: var(--duo-green-text);
}

.juice-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Profile Tab */
.profile-hero-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--duo-blue-soft) 0%, var(--bg-card) 100%);
  border: 2px solid var(--border-subtle);
}

.profile-avatar-circle {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid var(--duo-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-name {
  margin: 0;
  font-size: 21px;
  font-weight: 900;
}

.profile-handle {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 2px;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.profile-stat-box {
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pstat-emoji { font-size: 22px; }
.pstat-val { font-size: 18px; font-weight: 900; line-height: 1.1; }
.pstat-lbl { font-size: 12px; font-weight: 700; color: var(--text-secondary); }

.profile-courses-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-course-row {
  width: 100%;
  text-align: left;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  box-shadow: 0 3px 0 var(--border-subtle);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.pcourse-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pcourse-info .mini-progress-track {
  flex: none;
  width: 100%;
  height: 8px;
  min-height: 8px;
}

.pcourse-name { font-size: 14.5px; font-weight: 900; }
.pcourse-ref {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pcourse-right {
  text-align: right;
  flex-shrink: 0;
}

.pcourse-xp { font-size: 13.5px; font-weight: 900; color: var(--duo-orange-dark); }
.pcourse-count { font-size: 11.5px; font-weight: 800; color: var(--text-secondary); }

.settings-card {
  gap: 0;
  padding: 6px 16px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1.5px solid var(--border-subtle);
}

.setting-row.border-none { border-bottom: none; }
.setting-title { font-size: 15px; font-weight: 800; }
.setting-desc { font-size: 12px; font-weight: 700; color: var(--text-secondary); }

.toggle-switch {
  width: 52px;
  height: 30px;
  border-radius: 99px;
  background: var(--border-strong);
  padding: 3px;
  display: flex;
  align-items: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle-switch.on {
  background: var(--duo-green);
}

.toggle-knob {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toggle-switch.on .toggle-knob {
  transform: translateX(22px);
}

.reset-btn {
  padding: 8px 14px;
  border-radius: 12px;
  border: 2px solid var(--duo-red);
  color: var(--duo-red);
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}

.reset-btn.armed {
  background: var(--duo-red);
  color: #FFFFFF;
}

.secondary-pill-btn {
  padding: 8px 14px;
  border-radius: 12px;
  border: 2px solid var(--duo-blue);
  color: var(--duo-blue);
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}

/* Real Profile Editor & Backup */
.profile-identity {
  flex: 1;
  min-width: 0;
}

.profile-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.edit-profile-chip {
  padding: 5px 11px;
  border-radius: 99px;
  background: var(--duo-blue);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}

.profile-bio-text {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.avatar-symbol-fill {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 900;
  color: #FFFFFF;
}

.profile-editor-card {
  gap: 14px;
}

.editor-cancel-link {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-secondary);
}

.form-row-2col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.duo-input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border-radius: 12px;
  border: 2px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 700;
  outline: none;
  transition: border-color 0.14s ease;
}

.duo-input:focus {
  border-color: var(--duo-blue);
  background: var(--bg-card);
}

.avatar-picker-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.avatar-opt-btn {
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-opt-btn.selected {
  border-color: var(--duo-blue);
  background: var(--duo-blue-soft);
  box-shadow: 0 2px 0 var(--duo-blue);
}

.color-picker-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: transform 0.1s ease;
}

.color-swatch.selected {
  border-color: var(--text-primary);
  transform: scale(1.12);
}

.goal-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.goal-choice-pill {
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 800;
}

.goal-choice-pill.selected {
  border-color: var(--duo-green);
  background: var(--duo-green-light);
  color: var(--duo-green-text);
}

.goal-pill-xp { font-weight: 900; }
.goal-pill-lbl { opacity: 0.82; font-size: 12px; }

.backup-drawer {
  padding: 10px 0 14px;
  border-bottom: 1.5px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.backup-textarea {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  resize: vertical;
}

.backup-actions {
  display: flex;
  gap: 8px;
}

.backup-drawer.border-none {
  border-bottom: none;
}

/* Cloudflare D1 Sync & Question History */
.sync-status-col {
  min-width: 0;
  flex: 1;
}

.sync-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sync-pill {
  font-size: 11px;
  font-weight: 900;
  padding: 2px 9px;
  border-radius: 99px;
  letter-spacing: 0.02em;
}

.sync-pill.ok {
  background: var(--duo-green-light);
  color: var(--duo-green-text);
}

.sync-pill.syncing {
  background: var(--duo-blue-soft);
  color: var(--duo-blue);
}

.sync-pill.warn {
  background: var(--duo-red-soft);
  color: var(--duo-red-dark);
}

.sync-pill.offline {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-subtle);
}

.history-drawer {
  padding: 12px 0 14px;
  border-bottom: 1.5px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hsum-pill {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hsum-val {
  font-size: 15px;
  font-weight: 900;
  color: var(--text-primary);
}

.hsum-lbl {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-secondary);
}

.history-empty {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  padding: 12px 8px;
  background: var(--bg-surface);
  border-radius: 12px;
}

.history-empty.err {
  color: var(--duo-red-dark);
  background: var(--duo-red-soft);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 2px;
}

.history-item {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item.ok {
  border-left-color: var(--duo-green);
}

.history-item.err {
  border-left-color: var(--duo-red);
}

.history-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.history-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: #FFFFFF;
  flex-shrink: 0;
}

.history-badge.ok { background: var(--duo-green); }
.history-badge.err { background: var(--duo-red); }

.history-course-chip {
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--duo-blue-soft);
  color: var(--duo-blue);
}

.history-lesson-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-hash-chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.history-prompt {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.38;
}

.history-answer-line {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-card);
  border-radius: 8px;
  padding: 5px 8px;
  overflow-x: auto;
}

.history-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.history-changed-tag {
  background: var(--duo-orange-soft);
  color: var(--duo-orange-dark);
  padding: 1px 7px;
  border-radius: 99px;
  font-weight: 900;
}

.history-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   KaTeX Refinements
   ========================================================================== */

.guidebook-formula-box .katex {
  font-size: 0.96em !important;
}

.katex-display {
  margin: 0.25em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
}

.katex {
  font-size: 1.04em !important;
}

.math-inline {
  display: inline-block;
  vertical-align: middle;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes bob {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-7px); }
}

@keyframes startBounce {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}

@keyframes celebrateBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.04); }
}

@keyframes pulseGlow {
  0% { transform: scale(0.92); opacity: 0.7; }
  100% { transform: scale(1.1); opacity: 1; }
}

@keyframes comboPulse {
  0% { filter: brightness(1); }
  100% { filter: brightness(1.14); }
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.94); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  0% { transform: translateY(30px); opacity: 0.4; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
  0% { transform: translateY(-14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

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

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

@keyframes shakeA {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@keyframes shakeB {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ==========================================================================
   Pointer Hover Feedback (iPad Trackpad / Mouse / Stylus Hover)
   ========================================================================== */

@media (hover: hover) and (pointer: fine) {
  .top-bar-pill:hover {
    background: var(--bg-surface);
  }

  .course-pill:hover {
    border-color: var(--border-strong);
  }

  .nav-item:hover:not(.active),
  .sidebar-brand:hover {
    background: var(--bg-surface);
  }

  .duo-btn:hover:not(:disabled) {
    filter: brightness(1.04);
  }

  .math-choice-card:hover:not(:disabled):not(.selected),
  .math-token-chip:hover:not(:disabled):not(.placed),
  .pair-tile:hover:not(:disabled):not(.selected):not(.matched),
  .math-key-btn:hover:not(:disabled),
  .drill-card:hover,
  .course-choice-card:hover:not(.selected),
  .profile-course-row:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface);
  }

  .lesson-close-btn:hover,
  .hint-pill-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
  }

  .path-node:hover {
    filter: brightness(1.05);
  }
}

/* ==========================================================================
   iPad Portrait, Split View (2/3), & Medium Tablets (>= 700px)
   ========================================================================== */

@media (min-width: 700px) {
  .duo-toast {
    top: calc(74px + env(safe-area-inset-top, 0px));
    max-width: 460px;
    font-size: 14.5px;
    padding: 13px 18px;
  }

  /* Switch to Left Navigation Rail + Right Content Pane */
  .main-app-frame {
    flex-direction: row;
  }

  .bottom-nav {
    order: 1;
    width: calc(92px + env(safe-area-inset-left, 0px));
    height: 100%;
    min-height: 100%;
    border-top: none;
    border-right: 2px solid var(--border-subtle);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 10px calc(16px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
  }

  .sidebar-brand {
    display: flex;
  }

  .nav-items-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .nav-item {
    width: 100%;
    height: 62px;
    border-radius: 16px;
    gap: 4px;
  }

  .nav-label {
    font-size: 11.5px;
  }

  .main-content-column {
    order: 2;
  }

  /* Top Bar & 3-Column Course Switcher */
  .top-bar {
    min-height: calc(64px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) calc(24px + env(safe-area-inset-right, 0px)) 0 24px;
    gap: 16px;
  }

  .top-bar-stats {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .top-bar-pill {
    height: 44px;
    padding: 0 12px;
    font-size: 16px;
    gap: 7px;
  }

  .course-pill {
    padding: 0 12px 0 6px;
  }

  .course-pill-code {
    display: none;
  }

  .course-pill-name {
    display: inline;
  }

  .sheet-backdrop {
    inset: calc(64px + env(safe-area-inset-top, 0px)) 0 0 0;
  }

  .course-switcher-sheet {
    top: calc(64px + env(safe-area-inset-top, 0px));
    padding: 20px 24px 24px;
  }

  .course-switcher-inner {
    max-width: 580px;
  }

  .course-choice-card {
    padding: 15px 16px;
    justify-content: space-between;
  }

  .course-choice-ref {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  /* Tab Pages & Learn Path */
  .tab-scroll-area {
    padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px));
  }

  .learn-path-page {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 28px 48px;
    gap: 32px;
  }

  .course-intro-strip {
    padding: 10px 16px;
    border-radius: 14px;
    gap: 10px;
  }

  .course-intro-badge {
    font-size: 12px;
    padding: 4px 10px;
  }

  .course-intro-source {
    font-size: 13.5px;
  }

  .unit-banner {
    padding: 20px 24px;
    border-radius: 20px;
  }

  .unit-section-label {
    font-size: 12px;
  }

  .unit-title {
    font-size: 22px;
  }

  .unit-desc {
    font-size: 14px;
  }

  .guidebook-btn {
    min-width: 74px;
    min-height: 58px;
    padding: 10px 14px;
    font-size: 11px;
  }

  .path-nodes-canvas {
    --path-curve-scale: 1.35;
    padding: 50px 0 22px;
    gap: 34px;
  }

  .path-mascot {
    top: 108px;
  }

  .path-mascot.right-side { right: 34px; }
  .path-mascot.left-side { left: 34px; }

  .path-mascot .gauss-mascot {
    width: 104px;
    height: 104px;
  }

  .mascot-speech {
    font-size: 13px;
    padding: 7px 13px;
  }

  .node-ring-stage {
    width: 104px;
    height: 104px;
  }

  .path-node {
    width: 80px;
    height: 78px;
  }

  .node-glyph {
    font-size: 27px;
  }

  .node-caption {
    font-size: 14px;
    max-width: 184px;
  }

  .lesson-popover {
    max-width: 400px;
    padding: 20px;
    border-radius: 20px;
  }

  .popover-title {
    font-size: 20px;
  }

  .popover-subtitle {
    font-size: 14px;
  }

  /* Centered iPadOS Sheet for Unit Guidebook */
  .modal-backdrop {
    align-items: center;
    padding: 24px;
  }

  .guidebook-modal {
    max-width: 660px;
    max-height: 82dvh;
    border-radius: 24px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.32);
    animation: popIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .guidebook-modal-header {
    padding: 22px 24px 18px;
  }

  .guidebook-modal-header h3 {
    font-size: 23px;
  }

  .modal-close-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .guidebook-cards {
    padding: 20px 24px;
    gap: 16px;
  }

  .guidebook-card {
    padding: 18px;
  }

  .guidebook-card-title {
    font-size: 16.5px;
  }

  .guidebook-formula-box {
    padding: 14px 16px;
  }

  .guidebook-formula-box .katex {
    font-size: 1.08em !important;
  }

  .guidebook-card-summary {
    font-size: 14.5px;
  }

  .guidebook-footer {
    padding: 14px 24px 18px;
    display: flex;
    justify-content: flex-end;
  }

  .guidebook-footer .duo-btn {
    width: auto;
    min-width: 180px;
  }

  /* Shared Tab Container (Practice, Streak, Profile) */
  .tab-page {
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 28px 48px;
    gap: 20px;
  }

  .page-heading {
    font-size: 28px;
  }

  .duo-card {
    padding: 20px 22px;
    border-radius: 20px;
    gap: 14px;
  }

  .card-section-header h3 {
    font-size: 18px;
  }

  .card-subcopy {
    font-size: 14.5px;
  }

  /* Practice Hub on iPad */
  .juice-btn-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }

  /* Streak Tab on iPad */
  .streak-hero-card {
    padding: 24px 26px;
    border-radius: 24px;
  }

  .streak-big-number {
    font-size: 68px;
  }

  .streak-big-label {
    font-size: 22px;
  }

  .streak-hero-flame-wrap {
    width: 108px;
    height: 108px;
  }

  .streak-hero-card .duo-btn {
    max-width: 300px;
  }

  .cal-circle {
    width: 48px;
    height: 48px;
  }

  .cal-day-name {
    font-size: 13.5px;
  }

  /* Profile Tab on iPad */
  .profile-hero-card {
    padding: 22px 24px;
    gap: 20px;
  }

  .profile-avatar-circle {
    width: 92px;
    height: 92px;
  }

  .profile-name {
    font-size: 25px;
  }

  .profile-handle {
    font-size: 14px;
  }

  .edit-profile-chip {
    padding: 8px 16px;
    font-size: 13px;
  }

  .profile-stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .profile-stat-box {
    padding: 16px;
  }

  .pstat-val {
    font-size: 21px;
  }

  .form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .duo-input {
    height: 48px;
    font-size: 15px;
  }

  .avatar-opt-btn {
    height: 50px;
    font-size: 22px;
  }

  .color-swatch {
    width: 42px;
    height: 42px;
  }

  .goal-picker-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .goal-choice-pill {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 12px 14px;
  }

  .profile-editor-card .duo-btn {
    max-width: 260px;
    align-self: flex-end;
  }

  .settings-card {
    padding: 8px 22px;
  }

  .setting-row {
    padding: 16px 0;
  }

  .setting-title {
    font-size: 16px;
  }

  .setting-desc {
    font-size: 13px;
  }

  /* Full-Screen Lesson Experience on iPad */
  .lesson-top-bar {
    max-width: 760px;
    margin: 0 auto;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 24px 10px;
    gap: 16px;
  }

  .lesson-close-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .lesson-progress-track {
    height: 18px;
  }

  .lesson-hearts-badge {
    font-size: 18px;
    gap: 6px;
  }

  .lesson-sub-strip {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    min-height: 30px;
  }

  .lesson-body {
    padding: 12px 24px 28px;
  }

  .question-stage {
    max-width: 700px;
    width: 100%;
    margin: auto;
    gap: 20px;
  }

  .question-badge {
    font-size: 12.5px;
  }

  .hint-pill-btn {
    min-height: 38px;
    padding: 6px 14px;
    font-size: 13px;
  }

  .hint-drawer {
    padding: 14px 18px;
    font-size: 14.5px;
  }

  .question-prompt-row {
    gap: 16px;
  }

  .question-prompt-row .gauss-mascot {
    width: 72px;
    height: 72px;
  }

  .prompt-bubble {
    padding: 16px 20px;
    font-size: 17px;
    border-radius: 18px;
  }

  .fill-eq-container {
    gap: 20px;
  }

  .equation-display-card {
    padding: 24px 22px;
    min-height: 94px;
    border-radius: 20px;
  }

  .equation-cloze-line {
    font-size: 20px;
    gap: 10px;
  }

  .cloze-slot {
    min-width: 68px;
    min-height: 46px;
    padding: 6px 16px;
  }

  .choice-grid {
    gap: 14px;
  }

  .math-choice-card {
    min-height: 88px;
    padding: 18px 16px;
    border-radius: 18px;
  }

  .choice-index-badge {
    width: 24px;
    height: 24px;
    font-size: 12px;
    top: 10px;
    left: 10px;
  }

  .choice-math-inner {
    font-size: 18px;
  }

  .choice-math-inner .katex {
    font-size: 1.32em !important;
  }

  /* Equation Builder on iPad */
  .builder-container {
    gap: 16px;
  }

  .builder-live-preview {
    padding: 14px 20px 16px;
  }

  .preview-math {
    min-height: 54px;
    font-size: 1.14em;
  }

  .builder-answer-tray {
    min-height: 74px;
    padding: 14px;
    gap: 10px;
  }

  .builder-bank {
    gap: 11px;
  }

  .math-token-chip {
    min-height: 50px;
    padding: 10px 18px;
    font-size: 17px;
  }

  /* Match Pairs on iPad */
  .match-pairs-grid {
    gap: 16px;
  }

  .match-col {
    gap: 12px;
  }

  .pair-tile {
    min-height: 70px;
    padding: 14px 16px;
    font-size: 15px;
    border-radius: 16px;
  }

  /* Math Keypad on iPad */
  .keypad-container {
    gap: 16px;
  }

  .keypad-input-box {
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    min-height: 64px;
    font-size: 22px;
  }

  .math-keypad-grid {
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    gap: 11px;
  }

  .math-key-btn {
    height: 58px;
    font-size: 21px;
    border-radius: 16px;
  }

  /* Duolingo iPadOS Horizontal Lesson Footer */
  .lesson-footer {
    padding: 18px calc(24px + env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) calc(24px + env(safe-area-inset-left, 0px));
  }

  .lesson-footer-inner {
    max-width: 760px;
  }

  .footer-action-btn {
    width: auto;
    min-width: 180px;
    padding: 14px 28px;
    flex-shrink: 0;
  }

  .feedback-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }

  .feedback-copy {
    flex: 1;
  }

  .feedback-heading {
    font-size: 20px;
  }

  .feedback-explanation,
  .feedback-misconception-box,
  .feedback-solution-box {
    font-size: 14.5px;
  }

  /* Lesson Complete Celebration on iPad */
  .celebrate-inner {
    max-width: 560px;
    justify-content: center;
  }

  .celebrate-title {
    font-size: 32px;
  }

  .celebrate-subtitle {
    font-size: 16px;
  }

  .celebrate-footer {
    margin-top: 12px;
    display: flex;
    justify-content: center;
  }

  .celebrate-footer .duo-btn {
    max-width: 320px;
  }
}

/* ==========================================================================
   Multi-Column Cards on iPad Air / Pro & Landscape (>= 860px / >= 900px)
   ========================================================================== */

@media (min-width: 860px) {
  .drill-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }

  .drill-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
    gap: 12px;
    position: relative;
  }

  .drill-play-pill {
    position: absolute;
    top: 16px;
    right: 16px;
  }
}

@media (min-width: 900px) {
  .course-switcher-inner {
    max-width: 880px;
  }

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

/* ==========================================================================
   iPad Landscape, iPad Pro & Desktop (>= 1024px)
   ========================================================================== */

@media (min-width: 1024px) {
  /* Full Duolingo iPadOS Sidebar */
  .bottom-nav {
    width: calc(236px + env(safe-area-inset-left, 0px));
    padding: calc(20px + env(safe-area-inset-top, 0px)) 14px calc(20px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
  }

  .sidebar-brand {
    justify-content: flex-start;
    padding: 8px 12px;
    margin-bottom: 20px;
  }

  .sidebar-brand-title {
    display: inline;
  }

  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 16px;
    height: 52px;
    gap: 14px;
  }

  .nav-label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  .top-bar {
    padding-left: 32px;
    padding-right: calc(32px + env(safe-area-inset-right, 0px));
  }

  .learn-path-page {
    max-width: 720px;
    padding: 28px 32px 56px;
  }

  .path-nodes-canvas {
    --path-curve-scale: 1.5;
  }

  .path-mascot.right-side { right: 54px; }
  .path-mascot.left-side { left: 54px; }

  .tab-page {
    max-width: 880px;
    padding: 28px 36px 56px;
  }
}

/* ==========================================================================
   iPad Landscape Vertical Height Optimization (e.g. 1024x768 / 1180x820)
   ========================================================================== */

@media (min-width: 700px) and (max-height: 820px) {
  .lesson-top-bar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-bottom: 6px;
  }

  .lesson-body {
    padding-top: 6px;
    padding-bottom: 14px;
  }

  .question-stage {
    gap: 12px;
  }

  .question-prompt-row .gauss-mascot {
    width: 58px;
    height: 58px;
  }

  .prompt-bubble {
    padding: 12px 16px;
    font-size: 15.5px;
  }

  .equation-display-card {
    padding: 14px 18px;
    min-height: 70px;
  }

  .math-choice-card {
    min-height: 72px;
    padding: 12px 14px;
  }

  .pair-tile {
    min-height: 56px;
    padding: 10px 14px;
  }

  .math-key-btn {
    height: 48px;
    font-size: 19px;
  }

  .lesson-footer {
    padding-top: 12px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .celebrate-hero {
    height: 118px;
    margin-top: 0;
  }

  .celebrate-hero .gauss-mascot {
    width: 108px;
    height: 108px;
  }

  .celebrate-title {
    font-size: 26px;
  }

  .celebrate-subtitle {
    margin-bottom: 12px;
  }

  .celebrate-stats-row {
    margin-bottom: 14px;
  }
}
