/* ============================================================
   MATH PWA — Design System v1.0
   Premium CSS for French Math Education App
   Target: 9+/10 design quality
   Light mode default / .dark-mode override
   ============================================================ */

/* ============================================================
   1. GOOGLE FONTS IMPORT
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ============================================================
   2. CSS VARIABLES
   ============================================================ */
:root {
  /* Background */
  --mp-bg:              #F7F8FC;
  --mp-bg-card:         #FFFFFF;
  --mp-bg-card-hover:   #F0F4FF;
  --mp-bg-input:        #FFFFFF;

  /* Borders */
  --mp-border:          #E2E8F0;
  --mp-border-focus:    #1E40AF;

  /* Text */
  --mp-text:            #0F172A;
  --mp-text-muted:      #64748B;
  --mp-text-dim:        #94A3B8;

  /* Primary Blue */
  --mp-blue:            #1E40AF;
  --mp-blue-soft:       rgba(30, 64, 175, 0.08);
  --mp-blue-hover:      #1E3A8A;

  /* Emerald */
  --mp-emerald:         #059669;
  --mp-emerald-soft:    rgba(5, 150, 105, 0.08);

  /* Feedback */
  --mp-red:             #DC2626;
  --mp-red-soft:        rgba(220, 38, 38, 0.08);
  --mp-amber:           #D97706;
  --mp-amber-soft:      rgba(217, 119, 6, 0.08);

  /* Spacing (4px base) */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-8:  32px;
  --s-10: 40px;

  /* Border radius */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-card:  0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-glow:  0 0 20px rgba(30, 64, 175, 0.12);

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-med:  0.3s ease;

  /* Safe area */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

/* ============================================================
   3. DARK MODE OVERRIDES (.dark-mode)
   ============================================================ */
.dark-mode {
  --mp-bg:            #0F172A;
  --mp-bg-card:       #1E293B;
  --mp-bg-card-hover: #243044;
  --mp-bg-input:      #1E293B;

  --mp-border:        #334155;
  --mp-border-focus:  #3B82F6;

  --mp-text:          #E2E8F0;
  --mp-text-muted:    #94A3B8;
  --mp-text-dim:      #64748B;

  --mp-blue:          #3B82F6;
  --mp-blue-soft:     rgba(59, 130, 246, 0.12);
  --mp-blue-hover:    #2563EB;

  --mp-emerald:       #10B981;
  --mp-emerald-soft:  rgba(16, 185, 129, 0.12);

  --mp-red:           #EF4444;
  --mp-red-soft:      rgba(239, 68, 68, 0.12);

  --mp-amber:         #F59E0B;
  --mp-amber-soft:    rgba(245, 158, 11, 0.12);

  --shadow-card:  0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-glow:  0 0 24px rgba(59, 130, 246, 0.18);
}

/* ============================================================
   4. RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--mp-text);
  background-color: var(--mp-bg);
  padding-top: var(--safe-top);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--mp-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  display: block;
  max-width: 100%;
}

ul,
ol {
  list-style: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
}

/* ============================================================
   5. LAYOUT
   ============================================================ */
.mp-app {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  min-height: 100dvh;
}

/* --- Header --- */
.mp-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-4);
  background-color: var(--mp-bg-card);
  border-bottom: 1px solid var(--mp-border);
  z-index: 100;
  gap: var(--s-3);
}

.mp-header-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  color: var(--mp-text);
  transition: background-color var(--transition-fast);
  flex-shrink: 0;
}

.mp-header-back:hover {
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
}

.mp-header-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--mp-text);
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-header-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  color: var(--mp-text-muted);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.mp-header-action:hover {
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
}

/* --- Drawer --- */
.mp-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background-color: var(--mp-bg-card);
  border-right: 1px solid var(--mp-border);
  transform: translateX(-100%);
  transition: transform var(--transition-med);
  z-index: 200;
  overflow-y: auto;
  padding: var(--s-6) 0 calc(var(--s-6) + var(--safe-bottom));
}

.mp-drawer.open {
  transform: translateX(0);
}

.mp-drawer-header {
  padding: 0 var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--mp-border);
  margin-bottom: var(--s-3);
}

.mp-drawer-title {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--mp-text);
}

.mp-drawer-subtitle {
  font-size: 0.8125rem;
  color: var(--mp-text-muted);
  margin-top: 2px;
}

.mp-drawer-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  color: var(--mp-text);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  border-radius: 0;
}

.mp-drawer-item:hover {
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
}

.mp-drawer-item.active {
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
  font-weight: 600;
}

.mp-drawer-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.mp-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
  display: none;
  backdrop-filter: blur(2px);
}

.mp-drawer-overlay.visible {
  display: block;
}

/* --- Main content --- */
.mp-main {
  padding-top: 72px;
  padding-bottom: calc(72px + var(--safe-bottom));
  padding-left: var(--s-4);
  padding-right: var(--s-4);
}

/* --- Screens --- */
.mp-screen {
  display: none;
}

.mp-screen.active {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

/* Section titles */
.mp-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--mp-text);
  margin-bottom: var(--s-4);
  margin-top: var(--s-6);
}

.mp-section-subtitle {
  font-size: 0.875rem;
  color: var(--mp-text-muted);
  margin-top: -var(--s-3);
  margin-bottom: var(--s-4);
}

/* ============================================================
   6. BOTTOM NAVIGATION
   ============================================================ */
.mp-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: stretch;
  background-color: var(--mp-bg-card);
  border-top: 1px solid var(--mp-border);
  z-index: 100;
}

.mp-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  padding: var(--s-2) var(--s-1);
  color: var(--mp-text-dim);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

.mp-nav-item.active {
  color: var(--mp-blue);
  font-weight: 600;
}

.mp-nav-item svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.mp-nav-item span {
  line-height: 1;
}

/* ============================================================
   7. HERO SECTION
   ============================================================ */
.mp-hero {
  background: linear-gradient(135deg, #1E40AF 0%, #059669 100%);
  border-radius: var(--r-xl);
  padding: var(--s-6) var(--s-4) 32px;
  color: white;
  text-align: center;
  margin-bottom: var(--s-6);
  position: relative;
  overflow: hidden;
}

.mp-hero::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  pointer-events: none;
}

.mp-hero::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -15%;
  width: 150px;
  height: 150px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 50%;
  pointer-events: none;
}

.mp-hero-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--s-3);
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.mp-hero-title {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: var(--s-2);
  position: relative;
  z-index: 1;
}

.mp-hero-subtitle {
  font-size: 0.9375rem;
  opacity: 0.85;
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

.mp-hero-stats {
  display: flex;
  justify-content: center;
  gap: var(--s-6);
  margin-top: var(--s-5);
  position: relative;
  z-index: 1;
}

.mp-hero-stat {
  text-align: center;
}

.mp-hero-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

.mp-hero-stat-label {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-top: 2px;
}

/* ============================================================
   8. TOPIC CARDS
   ============================================================ */
.mp-topics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
  margin-bottom: var(--s-6);
}

.mp-topic-card {
  background-color: var(--mp-bg-card);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-4);
  text-align: center;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  box-shadow: var(--shadow-card);
  border: 1.5px solid transparent;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.mp-topic-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--mp-border);
  background-color: var(--mp-bg-card-hover);
}

.mp-topic-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-card);
}

.mp-topic-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--s-2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  font-size: 1.75rem;
}

.mp-topic-label {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--mp-text);
  line-height: 1.3;
}

.mp-topic-desc {
  font-size: 0.75rem;
  color: var(--mp-text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* Premium topic card */
.mp-topic-card.premium {
  border-color: rgba(30, 64, 175, 0.2);
}

.mp-topic-card.premium::after {
  content: '🔒';
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  font-size: 0.75rem;
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ============================================================
   9. CALCULATOR INPUTS
   ============================================================ */
.mp-calc-group {
  margin-bottom: var(--s-4);
}

.mp-calc-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mp-text-muted);
  margin-bottom: var(--s-2);
}

.mp-calc-label sup {
  font-size: 0.6875rem;
  color: var(--mp-red);
  margin-left: 2px;
}

.mp-calc-input {
  width: 100%;
  padding: 12px var(--s-4);
  border: 1.5px solid var(--mp-border);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 500;
  text-align: right;
  background-color: var(--mp-bg-input);
  color: var(--mp-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.mp-calc-input:focus {
  border-color: var(--mp-border-focus);
  box-shadow: var(--shadow-glow);
  outline: none;
}

.mp-calc-input::placeholder {
  color: var(--mp-text-dim);
  font-weight: 400;
}

.mp-calc-input.error {
  border-color: var(--mp-red);
  box-shadow: 0 0 16px rgba(220, 38, 38, 0.1);
  animation: shake-error 0.4s ease-out;
}

.mp-calc-input::-webkit-outer-spin-button,
.mp-calc-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.mp-calc-input[type='number'] {
  -moz-appearance: textfield;
}

/* Select */
.mp-calc-select {
  width: 100%;
  padding: 12px var(--s-10) 12px var(--s-4);
  border: 1.5px solid var(--mp-border);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  background-color: var(--mp-bg-input);
  color: var(--mp-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  -webkit-appearance: none;
  appearance: none;
}

.mp-calc-select:focus {
  border-color: var(--mp-border-focus);
  box-shadow: var(--shadow-glow);
  outline: none;
}

/* Shape selector */
.mp-shape-selector {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding-bottom: var(--s-2);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.mp-shape-selector::-webkit-scrollbar {
  display: none;
}

.mp-shape-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-3);
  background-color: var(--mp-bg-card);
  border: 1.5px solid var(--mp-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 72px;
}

.mp-shape-card:hover,
.mp-shape-card.active {
  border-color: var(--mp-blue);
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
}

.mp-shape-card span {
  font-size: 0.75rem;
  font-weight: 600;
  color: inherit;
}

/* Input helper text */
.mp-calc-helper {
  font-size: 0.75rem;
  color: var(--mp-text-dim);
  margin-top: var(--s-1);
}

.mp-calc-helper.error-msg {
  color: var(--mp-red);
}

/* ============================================================
   10. RESULT DISPLAY
   ============================================================ */
.mp-result-card {
  background: linear-gradient(135deg, var(--mp-blue-soft) 0%, var(--mp-emerald-soft) 100%);
  border: 1px solid rgba(30, 64, 175, 0.15);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-top: var(--s-4);
  animation: spring-result 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mp-result-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mp-text-muted);
  margin-bottom: var(--s-2);
}

.mp-result-value {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--mp-blue);
  line-height: 1.2;
  word-break: break-all;
}

.mp-result-unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--mp-text-muted);
  margin-left: var(--s-2);
  font-family: var(--font-body);
}

.mp-result-formula {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--mp-text-muted);
  margin-top: var(--s-1);
  padding: var(--s-2) var(--s-3);
  background-color: rgba(0, 0, 0, 0.04);
  border-radius: var(--r-sm);
}

.mp-result-steps {
  margin-top: var(--s-3);
  border-top: 1px solid var(--mp-border);
  padding-top: var(--s-3);
}

.mp-result-steps-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mp-text-muted);
  margin-bottom: var(--s-2);
}

.mp-step {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px dashed var(--mp-border);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--mp-text);
}

.mp-step:last-child {
  border-bottom: none;
}

.mp-step-number {
  color: var(--mp-blue);
  font-weight: 700;
  min-width: 20px;
  flex-shrink: 0;
}

.mp-step-expr {
  flex: 1;
}

.mp-step-equals {
  color: var(--mp-text-muted);
  margin: 0 var(--s-2);
}

.mp-step-result {
  color: var(--mp-emerald);
  font-weight: 700;
}

/* Result success pulse */
.mp-result-card.pulse {
  animation: spring-result 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
             pulse-glow 0.6s ease-out 0.2s;
}

/* ============================================================
   11. FRACTION DISPLAY
   ============================================================ */
.mp-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.mp-frac-num {
  padding-bottom: 2px;
  line-height: 1.2;
}

.mp-frac-den {
  padding-top: 2px;
  border-top: 2px solid currentColor;
  line-height: 1.2;
}

.mp-frac-op {
  font-size: 1.25rem;
  margin: 0 var(--s-2);
  vertical-align: middle;
  font-family: var(--font-mono);
  color: var(--mp-text-muted);
}

/* Mixed number */
.mp-mixed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  vertical-align: middle;
}

.mp-mixed-whole {
  font-weight: 700;
}

/* ============================================================
   12. BUTTONS
   ============================================================ */
.mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 12px var(--s-6);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1;
  min-height: 44px;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.mp-btn:active {
  transform: scale(0.97);
}

.mp-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.mp-btn-primary {
  background-color: var(--mp-blue);
  color: white;
}

.mp-btn-primary:hover {
  background-color: var(--mp-blue-hover);
}

/* Emerald */
.mp-btn-emerald {
  background-color: var(--mp-emerald);
  color: white;
}

.mp-btn-emerald:hover {
  background-color: #047857;
}

/* Outline */
.mp-btn-outline {
  border: 1.5px solid var(--mp-border);
  background-color: transparent;
  color: var(--mp-text);
}

.mp-btn-outline:hover {
  border-color: var(--mp-blue);
  color: var(--mp-blue);
  background-color: var(--mp-blue-soft);
}

/* Ghost */
.mp-btn-ghost {
  background-color: transparent;
  color: var(--mp-text-muted);
}

.mp-btn-ghost:hover {
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
}

/* Danger */
.mp-btn-danger {
  background-color: var(--mp-red);
  color: white;
}

.mp-btn-danger:hover {
  background-color: #B91C1C;
}

/* Full width */
.mp-btn-full {
  width: 100%;
}

/* Size variants */
.mp-btn-sm {
  padding: var(--s-2) var(--s-3);
  font-size: 0.8125rem;
  min-height: 36px;
}

.mp-btn-lg {
  padding: 14px var(--s-8);
  font-size: 1rem;
  min-height: 52px;
  border-radius: var(--r-lg);
}

/* Premium button with shimmer */
.mp-btn-premium {
  background: linear-gradient(135deg, #1E40AF, #059669);
  color: white;
  overflow: hidden;
}

.mp-btn-premium:hover {
  background: linear-gradient(135deg, #1E3A8A, #047857);
}

.mp-btn-premium::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.25),
    transparent
  );
  animation: shimmer 3s infinite;
}

/* Icon button */
.mp-btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--r-md);
  flex-shrink: 0;
}

/* ============================================================
   13. PAYWALL
   ============================================================ */
.mp-paywall {
  background: linear-gradient(135deg, var(--mp-blue-soft) 0%, var(--mp-emerald-soft) 100%);
  border: 1px solid rgba(30, 64, 175, 0.15);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  text-align: center;
  margin: var(--s-4) 0;
}

.mp-paywall-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--s-3);
  background: linear-gradient(135deg, var(--mp-blue), var(--mp-emerald));
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.mp-paywall-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--mp-text);
  margin-bottom: var(--s-2);
}

.mp-paywall-desc {
  font-size: 0.9375rem;
  color: var(--mp-text-muted);
  line-height: 1.6;
  margin: var(--s-2) 0 var(--s-4);
}

.mp-paywall-price-wrap {
  margin: var(--s-4) 0;
}

.mp-paywall-price {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--mp-blue);
  line-height: 1;
}

.mp-paywall-once {
  font-size: 0.8125rem;
  color: var(--mp-text-dim);
  margin-top: var(--s-1);
  font-weight: 500;
}

.mp-paywall-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
  margin: var(--s-4) 0 var(--s-5);
  text-align: left;
}

.mp-paywall-feature {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  font-size: 0.875rem;
  color: var(--mp-text);
  line-height: 1.4;
}

.mp-paywall-feature svg {
  color: var(--mp-emerald);
  flex-shrink: 0;
  margin-top: 1px;
  width: 16px;
  height: 16px;
}

.mp-paywall-key-input {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--mp-border);
}

.mp-paywall-key-input .mp-calc-input {
  text-align: center;
  font-size: 1rem;
  letter-spacing: 0.1em;
}

/* ============================================================
   14. EXERCISE MODE
   ============================================================ */
.mp-exercise-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}

.mp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--mp-border);
  transition: all var(--transition-med);
  flex-shrink: 0;
}

.mp-dot.correct {
  background-color: var(--mp-emerald);
}

.mp-dot.wrong {
  background-color: var(--mp-red);
}

.mp-dot.current {
  background-color: var(--mp-blue);
  transform: scale(1.3);
}

.mp-dot.skipped {
  background-color: var(--mp-amber);
}

.mp-exercise-card {
  background-color: var(--mp-bg-card);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--mp-border);
}

.mp-exercise-num {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mp-text-dim);
  margin-bottom: var(--s-3);
}

.mp-exercise-question {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--mp-text);
  margin-bottom: var(--s-4);
  line-height: 1.6;
}

.mp-exercise-input {
  width: 100%;
  text-align: center;
  font-size: 1.5rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: var(--s-4);
  border: 2px solid var(--mp-border);
  border-radius: var(--r-md);
  background-color: var(--mp-bg-input);
  color: var(--mp-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.mp-exercise-input:focus {
  border-color: var(--mp-blue);
  box-shadow: var(--shadow-glow);
  outline: none;
}

.mp-exercise-input.correct {
  border-color: var(--mp-emerald);
  background-color: var(--mp-emerald-soft);
  color: var(--mp-emerald);
}

.mp-exercise-input.wrong {
  border-color: var(--mp-red);
  background-color: var(--mp-red-soft);
  color: var(--mp-red);
  animation: shake-error 0.4s ease-out;
}

.mp-exercise-feedback {
  padding: var(--s-3);
  border-radius: var(--r-md);
  margin-top: var(--s-3);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 500;
  font-size: 0.9375rem;
}

.mp-exercise-feedback svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.mp-exercise-feedback.correct {
  background-color: rgba(5, 150, 105, 0.1);
  color: var(--mp-emerald);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.mp-exercise-feedback.wrong {
  background-color: rgba(220, 38, 38, 0.1);
  color: var(--mp-red);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.mp-correction {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.mp-correction.open {
  max-height: 500px;
}

.mp-correction-inner {
  padding-top: var(--s-3);
  border-top: 1px dashed var(--mp-border);
  margin-top: var(--s-3);
}

.mp-correction-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mp-text-muted);
  margin-bottom: var(--s-2);
}

/* Score ring (Apple Watch style) */
.mp-score-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: var(--s-4) auto;
}

.mp-score-ring svg {
  transform: rotate(-90deg);
}

.mp-score-ring-bg {
  fill: none;
  stroke: var(--mp-border);
  stroke-width: 6;
}

.mp-score-ring-fg {
  fill: none;
  stroke: var(--mp-emerald);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mp-score-ring-text {
  position: absolute;
  text-align: center;
}

.mp-score-ring-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--mp-text);
  line-height: 1;
}

.mp-score-ring-label {
  font-size: 0.75rem;
  color: var(--mp-text-muted);
  font-weight: 500;
}

/* MCQ options */
.mp-mcq-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.mp-mcq-option {
  padding: var(--s-3);
  border: 1.5px solid var(--mp-border);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background-color: var(--mp-bg-card);
  color: var(--mp-text);
  font-size: 1rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mp-mcq-option:hover:not(:disabled) {
  border-color: var(--mp-blue);
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
}

.mp-mcq-option.selected {
  border-color: var(--mp-blue);
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
}

.mp-mcq-option.correct {
  border-color: var(--mp-emerald);
  background-color: var(--mp-emerald-soft);
  color: var(--mp-emerald);
}

.mp-mcq-option.wrong {
  border-color: var(--mp-red);
  background-color: var(--mp-red-soft);
  color: var(--mp-red);
}

/* ============================================================
   15. FORMULA REFERENCE
   ============================================================ */
.mp-level-pills {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding-bottom: var(--s-2);
  margin-bottom: var(--s-4);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.mp-level-pills::-webkit-scrollbar {
  display: none;
}

.mp-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--mp-border);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  background-color: var(--mp-bg-card);
  color: var(--mp-text-muted);
  flex-shrink: 0;
}

.mp-pill:hover {
  border-color: var(--mp-blue);
  color: var(--mp-blue);
}

.mp-pill.active {
  background-color: var(--mp-blue);
  color: white;
  border-color: var(--mp-blue);
}

.mp-formula-category {
  margin-bottom: var(--s-4);
}

.mp-formula-category-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mp-text-dim);
  margin-bottom: var(--s-2);
  padding: 0 var(--s-1);
}

.mp-formula-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-3);
  border-bottom: 1px solid var(--mp-border);
  background-color: var(--mp-bg-card);
  transition: background-color var(--transition-fast);
  cursor: pointer;
}

.mp-formula-item:first-child {
  border-radius: var(--r-md) var(--r-md) 0 0;
}

.mp-formula-item:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--r-md) var(--r-md);
}

.mp-formula-item:only-child {
  border-radius: var(--r-md);
}

.mp-formula-item:hover {
  background-color: var(--mp-bg-card-hover);
}

.mp-formula-item .mp-formula-name {
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--mp-text);
  flex: 1;
}

.mp-formula-item .mp-formula {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--mp-blue);
  background-color: var(--mp-blue-soft);
  padding: 3px var(--s-2);
  border-radius: var(--r-sm);
  white-space: nowrap;
}

/* ============================================================
   16. CONVERTISSEUR
   ============================================================ */
.mp-convert-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.mp-convert-row .mp-calc-input {
  flex: 1;
}

.mp-convert-swap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--mp-border);
  background-color: var(--mp-bg-card);
  color: var(--mp-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.mp-convert-swap:hover {
  border-color: var(--mp-blue);
  color: var(--mp-blue);
  background-color: var(--mp-blue-soft);
}

.mp-convert-swap.rotating {
  animation: rotate-swap 0.3s ease-out;
}

.mp-convert-swap svg {
  width: 20px;
  height: 20px;
}

.mp-convert-unit {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--mp-text-muted);
  min-width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.mp-convert-arrow {
  display: flex;
  justify-content: center;
  margin: var(--s-2) 0;
  color: var(--mp-text-dim);
}

.mp-convert-result {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--mp-blue);
  text-align: center;
  padding: var(--s-4);
  background-color: var(--mp-blue-soft);
  border-radius: var(--r-md);
}

/* ============================================================
   17. HISTORIQUE
   ============================================================ */
.mp-history-empty {
  text-align: center;
  padding: var(--s-10) var(--s-4);
  color: var(--mp-text-muted);
}

.mp-history-empty svg {
  margin: 0 auto var(--s-3);
  opacity: 0.4;
  width: 48px;
  height: 48px;
}

.mp-history-section {
  margin-bottom: var(--s-4);
}

.mp-history-date {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mp-text-dim);
  padding: var(--s-2) 0 var(--s-2);
}

.mp-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3);
  border-bottom: 1px solid var(--mp-border);
  background-color: var(--mp-bg-card);
  gap: var(--s-3);
  transition: background-color var(--transition-fast);
}

.mp-history-item:first-of-type {
  border-radius: var(--r-md) var(--r-md) 0 0;
}

.mp-history-item:last-of-type {
  border-bottom: none;
  border-radius: 0 0 var(--r-md) var(--r-md);
}

.mp-history-item:hover {
  background-color: var(--mp-bg-card-hover);
}

.mp-history-content {
  flex: 1;
  min-width: 0;
}

.mp-history-topic {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--mp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-history-detail {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--mp-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-fav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  color: var(--mp-text-dim);
  transition: all var(--transition-fast);
  cursor: pointer;
  flex-shrink: 0;
}

.mp-fav-btn:hover {
  color: var(--mp-amber);
  background-color: var(--mp-amber-soft);
}

.mp-fav-btn.active {
  color: var(--mp-amber);
}

.mp-fav-btn svg {
  width: 20px;
  height: 20px;
}

.mp-history-score {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--s-2);
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.mp-history-score.good {
  background-color: var(--mp-emerald-soft);
  color: var(--mp-emerald);
}

.mp-history-score.bad {
  background-color: var(--mp-red-soft);
  color: var(--mp-red);
}

.mp-history-score.medium {
  background-color: var(--mp-amber-soft);
  color: var(--mp-amber);
}

/* ============================================================
   18. ONBOARDING
   ============================================================ */
.mp-onboarding {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}

.mp-onboarding-card {
  background-color: var(--mp-bg-card);
  border-radius: var(--r-xl);
  max-width: 360px;
  width: 100%;
  padding: var(--s-8);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  animation: spring-result 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mp-onboarding-step {
  display: none;
}

.mp-onboarding-step.active {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

.mp-onboarding-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--s-4);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.mp-onboarding-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--mp-text);
  text-align: center;
  margin-bottom: var(--s-2);
}

.mp-onboarding-desc {
  font-size: 0.9375rem;
  color: var(--mp-text-muted);
  text-align: center;
  line-height: 1.6;
  margin-bottom: var(--s-6);
}

.mp-onboarding-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: var(--s-5);
}

.mp-onboarding-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

/* ============================================================
   19. CONFETTI
   ============================================================ */
.mp-confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2000;
  overflow: hidden;
}

.mp-confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  animation: confetti-fall linear forwards;
}

/* ============================================================
   20. DESKTOP SIDEBAR (768px+)
   ============================================================ */
@media (min-width: 768px) {
  .mp-nav {
    display: none;
  }

  .mp-drawer {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(0);
    width: 240px;
    border-right: 1px solid var(--mp-border);
    background-color: var(--mp-bg-card);
    padding-top: 80px;
    transition: none;
  }

  .mp-drawer-overlay {
    display: none !important;
  }

  .mp-app {
    max-width: none;
    margin-left: 240px;
  }

  .mp-header {
    left: 240px;
    max-width: none;
    width: calc(100% - 240px);
    transform: none;
  }

  .mp-main {
    max-width: 540px;
    margin: 0 auto;
    padding-top: 80px;
    padding-bottom: var(--s-10);
  }

  .mp-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 240px;
    background-color: var(--mp-bg-card);
    border-right: 1px solid var(--mp-border);
    overflow-y: auto;
    z-index: 100;
    padding: var(--s-6) 0;
  }

  .mp-sidebar-logo {
    padding: 0 var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--mp-border);
    margin-bottom: var(--s-3);
  }

  .mp-sidebar-section {
    padding: var(--s-2) var(--s-4) var(--s-1);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--mp-text-dim);
  }

  .mp-sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 10px var(--s-4);
    color: var(--mp-text-muted);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    cursor: pointer;
    border-left: 3px solid transparent;
  }

  .mp-sidebar-item:hover {
    background-color: var(--mp-blue-soft);
    color: var(--mp-blue);
  }

  .mp-sidebar-item.active {
    background-color: var(--mp-blue-soft);
    color: var(--mp-blue);
    font-weight: 600;
    border-left-color: var(--mp-blue);
  }

  .mp-sidebar-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .mp-premium-badge {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background-color: var(--mp-blue-soft);
    color: var(--mp-blue);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    margin-left: auto;
  }

  .mp-sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--s-4);
    border-top: 1px solid var(--mp-border);
  }
}

/* ============================================================
   21. PRINT STYLES
   ============================================================ */
@media print {
  .mp-nav,
  .mp-header,
  .mp-drawer,
  .mp-drawer-overlay,
  .mp-paywall,
  .mp-sidebar,
  .mp-onboarding,
  .mp-confetti,
  .mp-btn-premium {
    display: none !important;
  }

  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .mp-main {
    padding: 0;
    margin: 0;
  }

  .mp-result-card {
    border: 1px solid #ccc;
    background: none;
  }

  .mp-result-value {
    color: black;
  }

  .mp-app {
    max-width: 100%;
    margin: 0;
  }
}

/* ============================================================
   22. ANIMATIONS & KEYFRAMES
   ============================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  from {
    left: -100%;
  }
  to {
    left: 150%;
  }
}

@keyframes spring-result {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake-error {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-8px); }
  30%  { transform: translateX(8px); }
  45%  { transform: translateX(-5px); }
  60%  { transform: translateX(5px); }
  75%  { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

@keyframes pulse-glow {
  0%   { box-shadow: 0 0 0px rgba(5, 150, 105, 0); }
  50%  { box-shadow: 0 0 20px rgba(5, 150, 105, 0.35); }
  100% { box-shadow: 0 0 0px rgba(5, 150, 105, 0); }
}

@keyframes slide-down {
  from { max-height: 0; opacity: 0; }
  to   { max-height: 500px; opacity: 1; }
}

@keyframes rotate-swap {
  from { transform: rotate(0deg); }
  to   { transform: rotate(180deg); }
}

@keyframes confetti-fall {
  0% {
    top: -10px;
    opacity: 1;
    transform: rotate(0deg) translateX(0);
  }
  80% {
    opacity: 1;
  }
  100% {
    top: 110vh;
    opacity: 0;
    transform: rotate(720deg) translateX(80px);
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* ============================================================
   23. ACCESSIBILITY
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 2px solid var(--mp-blue);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* High contrast ratios: all key text combinations meet 4.5:1 */
/* --mp-text (#0F172A) on --mp-bg (#F7F8FC): ~16.5:1 */
/* --mp-text-muted (#64748B) on white: ~4.6:1 */
/* white on --mp-blue (#1E40AF): ~6.8:1 */
/* white on --mp-emerald (#059669): ~4.6:1 */

/* Skip to content */
.mp-skip-link {
  position: absolute;
  top: -100%;
  left: var(--s-4);
  z-index: 9999;
  padding: var(--s-2) var(--s-4);
  background-color: var(--mp-blue);
  color: white;
  border-radius: 0 0 var(--r-md) var(--r-md);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition-fast);
}

.mp-skip-link:focus {
  top: 0;
}

/* ============================================================
   24. UTILITY CLASSES
   ============================================================ */

/* Cards */
.mp-card {
  background-color: var(--mp-bg-card);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--mp-border);
}

.mp-card + .mp-card {
  margin-top: var(--s-3);
}

/* Dividers */
.mp-divider {
  height: 1px;
  background-color: var(--mp-border);
  margin: var(--s-5) 0;
  border: none;
}

/* Badges */
.mp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--s-2);
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.mp-badge-blue {
  background-color: var(--mp-blue-soft);
  color: var(--mp-blue);
}

.mp-badge-emerald {
  background-color: var(--mp-emerald-soft);
  color: var(--mp-emerald);
}

.mp-badge-red {
  background-color: var(--mp-red-soft);
  color: var(--mp-red);
}

.mp-badge-amber {
  background-color: var(--mp-amber-soft);
  color: var(--mp-amber);
}

/* Spinner */
.mp-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--mp-border);
  border-top-color: var(--mp-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.mp-spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

/* Skeleton loading */
.mp-skeleton {
  background: linear-gradient(90deg, var(--mp-border) 25%, var(--mp-bg-card-hover) 50%, var(--mp-border) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Text helpers */
.mp-text-center { text-align: center; }
.mp-text-right  { text-align: right; }
.mp-text-muted  { color: var(--mp-text-muted); }
.mp-text-dim    { color: var(--mp-text-dim); }
.mp-text-blue   { color: var(--mp-blue); }
.mp-text-emerald { color: var(--mp-emerald); }
.mp-text-red    { color: var(--mp-red); }
.mp-text-sm     { font-size: 0.875rem; }
.mp-text-xs     { font-size: 0.75rem; }
.mp-font-mono   { font-family: var(--font-mono); }
.mp-font-bold   { font-weight: 700; }

/* Spacing helpers */
.mp-mt-0 { margin-top: 0; }
.mp-mt-2 { margin-top: var(--s-2); }
.mp-mt-3 { margin-top: var(--s-3); }
.mp-mt-4 { margin-top: var(--s-4); }
.mp-mt-6 { margin-top: var(--s-6); }
.mp-mb-0 { margin-bottom: 0; }
.mp-mb-2 { margin-bottom: var(--s-2); }
.mp-mb-3 { margin-bottom: var(--s-3); }
.mp-mb-4 { margin-bottom: var(--s-4); }
.mp-mb-6 { margin-bottom: var(--s-6); }

/* Flex helpers */
.mp-flex         { display: flex; }
.mp-flex-col     { flex-direction: column; }
.mp-items-center { align-items: center; }
.mp-justify-between { justify-content: space-between; }
.mp-gap-2        { gap: var(--s-2); }
.mp-gap-3        { gap: var(--s-3); }
.mp-gap-4        { gap: var(--s-4); }

/* Visibility */
.mp-hidden { display: none !important; }
.mp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Toast notifications */
.mp-toast-container {
  position: fixed;
  bottom: calc(72px + var(--safe-bottom) + var(--s-3));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  pointer-events: none;
  width: 100%;
  max-width: 400px;
  padding: 0 var(--s-4);
}

.mp-toast {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background-color: var(--mp-text);
  color: var(--mp-bg);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-hover);
  pointer-events: auto;
  animation: slide-down 0.3s ease-out;
  width: 100%;
}

.mp-toast.success {
  background-color: var(--mp-emerald);
  color: white;
}

.mp-toast.error {
  background-color: var(--mp-red);
  color: white;
}

.mp-toast svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Progress bar */
.mp-progress {
  width: 100%;
  height: 6px;
  background-color: var(--mp-border);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: var(--s-3) 0;
}

.mp-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--mp-blue), var(--mp-emerald));
  border-radius: var(--r-full);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Timer */
.mp-timer {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--mp-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mp-timer.warning {
  color: var(--mp-amber);
}

.mp-timer.danger {
  color: var(--mp-red);
  animation: skeleton-pulse 1s ease-in-out infinite;
}

/* Empty state */
.mp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-10) var(--s-4);
  text-align: center;
  gap: var(--s-3);
  color: var(--mp-text-muted);
}

.mp-empty svg {
  opacity: 0.35;
  width: 56px;
  height: 56px;
}

.mp-empty-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--mp-text);
}

.mp-empty-desc {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Number hero display */
.mp-number-hero {
  font-size: 2.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--mp-text);
  line-height: 1;
}

/* Caption */
.mp-caption {
  font-size: 0.8125rem;
  color: var(--mp-text-dim);
  line-height: 1.5;
}

/* Label */
.mp-label {
  font-size: 0.875rem;
  color: var(--mp-text-muted);
  font-weight: 500;
}

/* ──────────────────────────────────────────────────────────────
   MISSING CLASSES PATCH — HTML/CSS alignment
   ────────────────────────────────────────────────────────────── */

/* Header logo & menu */
.mp-header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--mp-text);
}
.mp-logo-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.mp-header-menu {
  background: none;
  border: none;
  color: var(--mp-text);
  padding: 8px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.15s;
}
.mp-header-menu:hover {
  background: var(--mp-blue-soft);
}

/* Section label */
.mp-section-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mp-text-muted);
  margin: var(--s-5) 0 var(--s-3);
}

/* Topic card extras */
.mp-topic-desc {
  font-size: 0.75rem;
  color: var(--mp-text-dim);
  margin-top: 2px;
}
.mp-topic-premium {
  position: relative;
}
.mp-topic-badge {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Hero level badge */
.mp-hero-level {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-top: var(--s-3);
}

/* Drawer extras */
.mp-drawer-nav {
  padding: var(--s-2) 0;
}
.mp-drawer-link {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  color: var(--mp-text);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.15s;
  border-radius: var(--r-sm);
  margin: 0 var(--s-2);
}
.mp-drawer-link:hover {
  background: var(--mp-blue-soft);
}
.mp-drawer-link.active {
  background: var(--mp-blue-soft);
  color: var(--mp-blue);
  font-weight: 600;
}
.mp-drawer-link svg {
  flex-shrink: 0;
}
.mp-drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--mp-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.mp-drawer-divider {
  height: 1px;
  background: var(--mp-border);
  margin: var(--s-2) var(--s-4);
}

/* Badge premium */
.mp-badge-premium {
  display: inline-block;
  background: var(--mp-blue-soft);
  color: var(--mp-blue);
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-left: auto;
}

/* Fractions input layout */
.mp-fraction-input {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  justify-content: center;
}
.mp-frac-input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  min-width: 80px;
}
.mp-frac-bar {
  width: 100%;
  height: 2px;
  background: var(--mp-text);
  margin: var(--s-1) 0;
}
.mp-frac-op-selector {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  margin: var(--s-2) 0;
}
.mp-frac-op {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--mp-border);
  background: var(--mp-bg-card);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--mp-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mp-frac-op:hover {
  border-color: var(--mp-blue);
  color: var(--mp-blue);
}
.mp-frac-op.active {
  background: var(--mp-blue);
  color: white;
  border-color: var(--mp-blue);
}

/* Convertisseur layout */
.mp-convert-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.mp-convert-left,
.mp-convert-right {
  flex: 1;
}
.mp-convert-swap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--mp-border);
  background: var(--mp-bg-card);
  color: var(--mp-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  flex-shrink: 0;
}
.mp-convert-swap:hover {
  border-color: var(--mp-blue);
  color: var(--mp-blue);
}
.mp-convert-swap:active {
  animation: rotate-swap 0.3s ease;
}

/* Settings */
.mp-settings-group {
  margin-bottom: var(--s-6);
}
.mp-setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s-3) 0;
  font-size: 0.9375rem;
}
.mp-license-row {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-2);
}
.mp-license-row .mp-calc-input {
  flex: 1;
  text-align: left;
  font-size: 0.875rem;
}
.mp-premium-status {
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: var(--s-2);
}

/* Toggle switch */
.mp-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.mp-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.mp-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--mp-border);
  border-radius: var(--r-full);
  transition: background 0.3s;
}
.mp-toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}
.mp-toggle input:checked + .mp-toggle-slider {
  background: var(--mp-blue);
}
.mp-toggle input:checked + .mp-toggle-slider::before {
  transform: translateX(20px);
}

/* About section */
.mp-about p {
  font-size: 0.875rem;
  color: var(--mp-text-muted);
  line-height: 1.6;
  margin-bottom: var(--s-2);
}
.mp-about a {
  color: var(--mp-blue);
  text-decoration: none;
}

/* Calculator container */
.mp-calc-container {
  margin-bottom: var(--s-4);
}

/* Onboarding steps */
.mp-onboarding-steps {
  list-style: none;
  padding: 0;
  margin: var(--s-4) 0;
  text-align: left;
}
.mp-onboarding-steps li {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  font-size: 0.9375rem;
  color: var(--mp-text);
}
.mp-onboarding-steps .step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mp-blue-soft);
  color: var(--mp-blue);
  font-weight: 700;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

/* Exercise actions */
.mp-exercise-actions {
  display: flex;
  gap: var(--s-3);
  margin-top: var(--s-4);
}

/* Export preview */
.mp-export-preview {
  background: var(--mp-bg-card);
  border: 1px solid var(--mp-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  margin: var(--s-4) 0;
  min-height: 200px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--mp-text-muted);
}

/* Lists */
.mp-recent-list,
.mp-history-list,
.mp-formulaire-list {
  margin-top: var(--s-3);
}

/* Empty state */
.mp-empty-state {
  text-align: center;
  padding: var(--s-10) var(--s-4);
  color: var(--mp-text-dim);
}
.mp-empty-state svg {
  margin-bottom: var(--s-3);
}
.mp-empty-state p {
  font-size: 0.9375rem;
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Result formula text */
.mp-result-formula {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  color: var(--mp-text-muted);
  text-align: center;
}

/* ──────────────────────────────────────────────────────────────
   FIX: Entrance animations (staggered cards)
   ────────────────────────────────────────────────────────────── */
@keyframes card-enter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.mp-topic-card {
  opacity: 0;
  animation: card-enter 0.35s ease forwards;
}
.mp-topic-card:nth-child(1) { animation-delay: 0.05s; }
.mp-topic-card:nth-child(2) { animation-delay: 0.1s; }
.mp-topic-card:nth-child(3) { animation-delay: 0.15s; }
.mp-topic-card:nth-child(4) { animation-delay: 0.2s; }
.mp-topic-card:nth-child(5) { animation-delay: 0.25s; }
.mp-topic-card:nth-child(6) { animation-delay: 0.3s; }

/* Hero entrance */
.mp-hero {
  animation: card-enter 0.4s ease forwards;
}

/* Stats counter on home */
.mp-stats-bar {
  display: flex;
  justify-content: center;
  gap: var(--s-6);
  margin: var(--s-4) 0;
  padding: var(--s-3) 0;
}
.mp-stat {
  text-align: center;
}
.mp-stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--mp-blue);
  font-family: 'JetBrains Mono', monospace;
}
.mp-stat-label {
  font-size: 0.6875rem;
  color: var(--mp-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

/* Social proof on paywall */
.mp-paywall-proof {
  display: flex;
  justify-content: center;
  gap: var(--s-4);
  margin: var(--s-3) 0;
  font-size: 0.75rem;
  color: var(--mp-text-dim);
}
.mp-paywall-proof-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Animated result value */
.mp-result-value {
  animation: spring-result 0.4s ease;
}

/* Input focus glow */
.mp-calc-input:focus {
  border-color: var(--mp-blue) !important;
  box-shadow: 0 0 0 3px rgba(30,64,175,0.1) !important;
  outline: none;
}

/* Shape selector scroll */
.mp-shape-selector {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding-bottom: var(--s-2);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mp-shape-selector::-webkit-scrollbar { display: none; }

@media (prefers-reduced-motion: reduce) {
  .mp-topic-card,
  .mp-hero,
  .mp-result-value {
    animation: none !important;
    opacity: 1 !important;
  }
}
