/* ============================================================
   MedCorner · Simulator Metode Angoff — Design System V3
   Mengikuti design tokens dari MedCorner v3 (D:/PROYEK VIBE/MedCorner v3)
   ========================================*/

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

/* ── Root Tokens (MedCorner v3 exact) ───────────────────── */
:root {
  --mc-primary: #004ac6;
  --mc-primary-dark: #003594;
  --mc-primary-soft: #dbe1ff;
  --mc-secondary: #059669;
  --mc-surface: #faf8ff;
  --mc-card: #ffffff;
  --mc-container: #f3f3fe;
  --mc-text: #191b23;
  --mc-muted: #434655;
  --mc-border: #c3c6d6;
  --mc-success: #006141;
  --mc-error: #ba1a1a;
  --mc-danger: #dc2626;
  --mc-warning: #d97706;
  --mc-shadow: 0 4px 20px rgba(37, 99, 235, 0.04);
  
  --mc-radius-sm: 8px;
  --mc-radius-md: 12px;
  --mc-radius-lg: 16px;
  --mc-radius-xl: 20px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Manrope, Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--mc-surface);
  color: var(--mc-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

code {
  background: var(--mc-container);
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .9em;
}

/* ── App Shell (.mc-app grid layout) ────────────────────── */
.mc-app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
  font-family: inherit;
  background: var(--mc-surface);
}

/* Sidebar */
.mc-app-sidebar {
  background: var(--mc-card);
  border-right: 1px solid rgba(195, 198, 214, 0.64);
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

/* Brand */
.mc-app-brand {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
  font-size: 24px;
  line-height: 1;
  font-family: "MedCornerBrand", "Inter", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.035em;
  text-decoration: none;
  color: var(--mc-text);
}
.mc-app-brand-med { color: #0358FE; }
.mc-app-brand-corner { color: #041B5A; }

.subtitle {
  font-size: 13px;
  color: var(--mc-muted);
  margin: 0;
}

/* Navigation */
.mc-app-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mc-app-navitem {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--mc-muted);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 150ms ease;
}
.mc-app-navitem:hover {
  background: var(--mc-container);
  color: var(--mc-primary);
}
.mc-app-navitem.is-active {
  background: var(--mc-primary);
  color: #ffffff;
}
.mc-app-navicon {
  width: 20px;
  text-align: center;
  font-weight: 800;
  font-size: 14px;
}

/* Side bottom (NBL card) */
.mc-app-sidebottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Main content area */
.mc-app-main {
  padding: 48px;
  min-width: 0;
  overflow-x: hidden;
}

/* Page headings */
.mc-app-title {
  font-size: 36px;
  line-height: 44px;
  letter-spacing: -0.02em;
  font-weight: 800;
  margin: 0 0 8px 0;
}
.mc-app-subtitle {
  color: var(--mc-muted);
  font-size: 15px;
  line-height: 22px;
  margin: 6px 0 0;
}

/* Cards */
.mc-app-card {
  background: var(--mc-card);
  border: 1px solid rgba(195, 198, 214, 0.72);
  border-radius: 12px;
  box-shadow: var(--mc-shadow);
}

/* Chips/Badges */
.mc-app-chip {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--mc-primary-soft);
  color: var(--mc-primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Buttons & Links */
.mc-app-primary-link, .btn-primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--mc-primary);
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
  border: none;
  cursor: pointer;
  transition: opacity 150ms;
}
.mc-app-primary-link:hover, .btn-primary:hover {
  opacity: 0.9;
}
.btn-secondary {
  background: var(--mc-success);
  color: white;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--mc-border);
  color: var(--mc-text);
}

/* Grid layouts */
.mc-app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}

/* Stat cards */
.mc-app-stat-card {
  padding: 24px;
}
.mc-app-stat-card span {
  color: var(--mc-muted);
  font-size: 13px;
  font-weight: 800;
}
.mc-app-stat-card strong {
  display: block;
  font-size: 32px;
  line-height: 40px;
  margin-top: 10px;
  color: var(--mc-text);
}
.mc-app-stat-card p {
  margin: 8px 0 0;
  color: var(--mc-muted);
  line-height: 1.5;
}

/* Panels & Rows */
.mc-app-panel {
  padding: 28px;
}
.mc-app-panel h2 {
  margin: 0 0 18px;
  font-size: 24px;
  line-height: 32px;
}
.mc-app-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 0;
  border-top: 1px solid #e1e1ed;
}
.mc-app-row:first-child {
  border-top: none;
}
.mc-app-row a {
  color: var(--mc-primary);
  text-decoration: none;
  font-weight: 800;
}

/* Progress bars / meters */
.mc-app-progress {
  height: 12px;
  border-radius: 999px;
  background: #e1e1ed;
  overflow: hidden;
}
.mc-app-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--mc-primary);
}

/* Screen system */
.screen {
  display: none;
  animation: mc-app-route-entry 200ms ease-out;
}
.screen.active {
  display: block;
}
@keyframes mc-app-route-entry {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Section containers */
.section-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.section-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: .5rem;
}
.section-subtitle {
  color: var(--mc-muted);
  margin-bottom: 1.5rem;
  font-size: 15px;
}

/* Hero sections */
.hero-section {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 48px 0;
  margin-bottom: 48px;
}
.hero-content {
  flex: 1;
}
.hero-visual {
  flex: 0 0 280px;
}
.hero-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--mc-primary-soft);
  color: var(--mc-primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* Feature cards */
.feature-card {
  padding: 24px;
}
.feature-icon {
  font-size: 32px;
  margin-bottom: 12px;
}
.feature-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}
.feature-card p {
  margin: 0;
  color: var(--mc-muted);
  font-size: 14px;
}

/* Tutorial */
.tutorial-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
}
.tutorial-sidebar {
  position: sticky;
  top: 100px;
}
.tutorial-steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tutorial-steps-list li {
  padding: 12px 16px;
  margin-bottom: 4px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}
.tutorial-steps-list li.is-active {
  background: var(--mc-primary);
  color: white;
}
.tutorial-steps-list li.is-done::after {
  content: '✓';
  margin-left: 8px;
  color: var(--mc-success);
}
.tutorial-content {
  padding: 24px;
  background: var(--mc-card);
  border: 1px solid rgba(195, 198, 214, 0.72);
  border-radius: 12px;
  box-shadow: var(--mc-shadow);
}
.tutorial-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
}

/* Info boxes */
.info-box {
  padding: 20px 24px;
  border-left: 4px solid var(--mc-primary);
  background: var(--mc-primary-soft);
  border-radius: 0 8px 8px 0;
  margin: 24px 0;
}
.info-box--blue {
  border-color: var(--mc-primary);
  background: var(--mc-primary-soft);
}
.info-box--green {
  border-color: var(--mc-success);
  background: #e4f2ea;
}
.info-box--yellow {
  border-color: var(--mc-warning);
  background: #fef3c7;
}
.info-box h4 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

/* Workflow steps */
.workflow-steps {
  list-style: none;
  padding: 0;
  counter-reset: step-counter;
}
.workflow-steps li {
  position: relative;
  padding-left: 40px;
  margin-bottom: 16px;
}
.workflow-steps li::before {
  counter-increment: step-counter;
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--mc-primary-soft);
  color: var(--mc-primary-dark);
  font-weight: 800;
  font-size: 14px;
  display: grid;
  place-items: center;
}

/* Simulation phases */
.sim-phase {
  display: none;
}
.sim-phase.active {
  display: block;
}
.phase-header {
  margin-bottom: 32px;
}
.phase-badge {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--mc-primary-soft);
  color: var(--mc-primary-dark);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 12px;
}

/* Item cards (questions) */
.item-card {
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  transition: border-color 200ms ease, box-shadow 200ms ease, background-color 200ms ease;
}

/* Highlight Box Merah untuk soal yang belum ditentukan persentasenya */
.item-card.item-card--unrated {
  border: 2px solid #ef4444 !important;
  background-color: #fff8f8 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18), 0 6px 16px rgba(239, 68, 68, 0.12) !important;
}

.item-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.item-number {
  font-weight: 800;
  font-size: 14px;
  color: var(--mc-muted);
  margin-bottom: 0;
}

/* Badge Status Dinilai vs Belum Ditentukan */
.item-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  transition: all 180ms ease;
  white-space: nowrap;
}
.item-status-badge--unrated {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid rgba(185, 28, 28, 0.25);
}
.item-status-badge--rated {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid rgba(21, 128, 61, 0.25);
}
.item-subject {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--mc-primary-soft);
  color: var(--mc-primary-dark);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 12px;
}
.item-stem {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 16px;
}
.item-image {
  margin: 16px 0;
  border-radius: 12px;
  overflow: hidden;
}
.item-options {
  margin: 20px 0;
}
.option-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid var(--mc-border);
  background: white;
  cursor: pointer;
}
.option-item:hover {
  border-color: var(--mc-primary);
}
.option-letter {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--mc-primary-soft);
  color: var(--mc-primary-dark);
  font-weight: 800;
  font-size: 14px;
  display: grid;
  place-items: center;
}
.angoff-slider {
  width: 100%;
  margin: 16px 0;
}
.angoff-slider input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e1e1ed;
  outline: none;
}

/* Touch-friendly precise stepper buttons (mobile-first) */
.slider-steppers {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.slider-step-btn {
  flex: 1;
  min-height: 44px;
  padding: 8px 4px;
  border: 1px solid var(--mc-border);
  border-radius: 8px;
  background: var(--mc-card);
  color: var(--mc-primary);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 120ms ease;
}
.slider-step-btn:hover, .slider-step-btn:active {
  background: var(--mc-primary);
  color: #ffffff;
  border-color: var(--mc-primary);
}
.angoff-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--mc-primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.slider-value {
  font-weight: 800;
  font-size: 16px;
  color: var(--mc-primary);
  text-align: right;
  margin-top: 8px;
}

/* Analysis section */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.flagged-items-list {
  margin: 24px 0;
}
.flagged-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--mc-container);
  margin-bottom: 8px;
}
.badge-warning {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
}
.badge-danger {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 800;
}

/* Discussion */
.discussion-card {
  padding: 20px;
  margin-bottom: 16px;
  border-left: 4px solid var(--mc-warning);
  background: var(--mc-card);
  border-radius: 0 8px 8px 0;
}
.discussion-comment {
  padding: 12px 16px;
  margin: 8px 0;
  border-radius: 8px;
  background: var(--mc-container);
}

/* Results */
.results-hero {
  text-align: center;
  padding: 48px 24px;
  margin-bottom: 32px;
}
.cutoff-display {
  font-size: 72px;
  font-weight: 800;
  color: var(--mc-primary);
  line-height: 1;
  margin: 16px 0;
}
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.derivation-steps {
  list-style: none;
  padding: 0;
  margin: 24px 0;
}
.derivation-steps li {
  padding: 16px;
  margin-bottom: 12px;
  background: var(--mc-card);
  border: 1px solid var(--mc-border);
  border-radius: 8px;
}
.item-score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.score-bar {
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--mc-primary) calc(var(--p) * 1%), #e1e1ed calc(var(--p) * 1%));
  flex: 1;
}

/* Collective NBL */
.collective-nbl {
  background: linear-gradient(135deg, var(--mc-primary-soft) 0%, white 100%);
  border: 1px solid var(--mc-primary);
  padding: 24px;
  border-radius: 12px;
  margin-top: 32px;
}
.nbl-badges {
  display: flex;
  gap: 12px;
  margin: 16px 0;
}
.nbl-comparison-card {
  padding: 20px;
  background: white;
  border: 1px solid var(--mc-border);
  border-radius: 12px;
  text-align: center;
}
.nbl-comparison-card .nbl-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--mc-primary);
}
.nbl-comparison-card .nbl-label {
  font-size: 12px;
  color: var(--mc-muted);
  font-weight: 700;
}

/* References */
.reference-card {
  padding: 24px;
  margin-bottom: 16px;
  background: var(--mc-card);
  border: 1px solid var(--mc-border);
  border-radius: 12px;
}
.ref-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.ref-type-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.ref-type-badge-journal { background: var(--mc-primary-soft); color: var(--mc-primary-dark); }
.ref-type-badge-paper { background: var(--mc-container); color: var(--mc-muted); }
.ref-type-badge-web { background: #e4f2ea; color: var(--mc-success); }
.ref-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--mc-text);
  margin: 0;
  flex: 1;
}
.ref-meta {
  font-size: 13px;
  color: var(--mc-muted);
  margin: 8px 0;
}
.ref-abstract {
  font-size: 14px;
  line-height: 1.6;
  margin: 12px 0;
}
.ref-link-btn {
  display: inline-flex;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  background: var(--mc-primary);
  color: white;
  transition: opacity 150ms;
}
.ref-link-btn:hover {
  opacity: 0.9;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}
.toast {
  padding: 16px 20px;
  background: var(--mc-text);
  color: white;
  border-radius: 8px;
  box-shadow: var(--mc-shadow);
  margin-top: 8px;
  font-size: 14px;
  animation: toast-enter 300ms ease;
}
@keyframes toast-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* Footer */
.app-footer {
  margin-top: 48px;
  padding: 24px 0;
  border-top: 1px solid var(--mc-border);
  text-align: center;
  color: var(--mc-muted);
  font-size: 13px;
}

/* Progress bar */
.progress-bar-wrap {
  height: 3px;
  background: var(--mc-border-light);
}
.progress-bar-fill {
  height: 100%;
  background: var(--mc-primary);
  width: 0;
  transition: width 300ms ease;
}
.progress-label {
  max-width: 1100px;
  margin: 0 auto;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--mc-muted);
  text-align: center;
}

/* Chart Container Rigid Sizing (Prevents Chart.js infinite resize loop) */
.mc-chart-box {
  position: relative;
  width: 100%;
  height: 320px;
  max-height: 320px;
  overflow: hidden;
}

.mc-chart-box canvas {
  display: block;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════
   MOBILE OPTIMIZATION — Android & iOS WebKit
   Mobile-only components are HIDDEN by default (desktop-first),
   revealed below the 768px breakpoint.
   ══════════════════════════════════════════════════════════ */

/* Mobile-only elements hidden on desktop */
.mc-mobile-header,
.mc-mobile-bottom-nav {
  display: none;
}

/* iOS Safari & Android tap polish (all viewports) */
* {
  -webkit-tap-highlight-color: transparent;
}
button, .mc-app-navitem, .mc-mobile-navitem {
  touch-action: manipulation; /* removes 300ms tap delay + double-tap zoom */
}

/* Phase progression buttons: responsive width via class (no inline min-width) */
.btn-phase-next {
  min-width: 280px;
}

/* Slider value badge — larger for legibility */
.angoff-slider .slider-value {
  font-size: 18px;
}

@media (max-width: 980px) {
  .mc-app {
    grid-template-columns: 1fr;
  }
  .mc-app-sidebar {
    min-height: auto;
    padding: 20px 16px;
    flex-direction: row;
    flex-wrap: wrap;
    position: static; /* sticky sidebar breaks single-column flow */
  }
  .mc-app-nav, .mc-app-sidebottom {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
  .mc-app-main {
    padding: 32px 16px;
  }
  .hero-section {
    flex-direction: column;
  }
  .tutorial-layout {
    grid-template-columns: 1fr;
  }
  .results-grid, .stat-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Phone breakpoint (<= 768px): app-like shell ── */
@media (max-width: 768px) {
  /* Hide desktop sidebar — replaced by top header + bottom nav */
  .mc-app-sidebar {
    display: none;
  }

  /* Mobile top header (sticky, notch-safe) */
  .mc-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: var(--mc-card);
    border-bottom: 1px solid rgba(195, 198, 214, 0.64);
    box-shadow: var(--mc-shadow);
  }
  .mc-mobile-badge {
    font-size: 12px;
    font-weight: 800;
    color: var(--mc-primary-dark);
    background: var(--mc-primary-soft);
    padding: 6px 10px;
    border-radius: 999px;
    white-space: nowrap;
  }

  /* Mobile bottom navigation bar (thumb zone) */
  .mc-mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: var(--mc-card);
    border-top: 1px solid rgba(195, 198, 214, 0.64);
    padding-bottom: env(safe-area-inset-bottom, 0px); /* iPhone home bar */
  }
  .mc-mobile-navitem {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px; /* ≥44px touch target */
    padding: 8px 4px;
    border: 0;
    background: transparent;
    color: var(--mc-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: color 150ms ease;
  }
  .mc-mobile-navitem.is-active {
    color: var(--mc-primary);
  }
  .mc-mobile-navicon {
    font-size: 20px;
    line-height: 1;
  }
  .mc-mobile-navlabel {
    line-height: 1.2;
  }

  /* Keep content clear of the fixed bottom nav */
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  /* Main content padding */
  .mc-app-main {
    padding: 20px 16px;
  }
  .section-container {
    padding: 1.25rem 0.25rem;
  }

  /* Typography scale-down */
  .mc-app-title {
    font-size: 28px !important;
    line-height: 34px !important;
  }
  .section-title {
    font-size: 24px;
  }
  .mc-app-subtitle {
    font-size: 14px;
  }
  .cutoff-display {
    font-size: 44px;
  }

  /* Hero: stacked, full-width actions */
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions .btn-primary,
  .hero-actions .btn-outline {
    width: 100%;
    min-height: 48px;
  }

  /* Phase buttons: full width, 48px+ touch height */
  .btn-phase-next {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    font-size: 15px;
  }

  /* Question cards: comfortable reading width */
  .item-card {
    padding: 16px;
  }
  .item-stem {
    font-size: 15px;
  }
  .option-item {
    padding: 12px;
    min-height: 44px; /* tap target */
  }

  /* Angoff slider: bigger thumb + track for fingers */
  .angoff-slider input[type="range"] {
    height: 12px;
  }
  .angoff-slider input[type="range"]::-webkit-slider-thumb {
    width: 32px;
    height: 32px;
  }
  .angoff-slider input[type="range"]::-moz-range-thumb {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--mc-primary);
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  }

  /* Chart: adaptive height, no overflow */
  .mc-chart-box {
    height: 260px;
    max-height: 260px;
  }

  /* Results hero: stack the comparison card */
  .collective-nbl__left {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .collective-nbl__right {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--mc-border-light);
    padding-top: 12px;
  }

  /* Flagged rows wrap gracefully */
  .flagged-item-row {
    flex-wrap: wrap;
  }

  /* Toast: centered above bottom nav, safe-area aware */
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  /* Reference cards: readable padding */
  .reference-card {
    padding: 16px;
  }

  /* Tutorial tables: horizontal scroll instead of overflow break */
  .tut-example-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Footer clearance above bottom nav */
  .app-footer {
    margin-bottom: 16px;
  }
}

/* ── Small phones (<= 400px, e.g. iPhone SE 1st gen) ── */
@media (max-width: 400px) {
  .mc-app-main {
    padding: 16px 12px;
  }
  .mc-app-title {
    font-size: 24px !important;
    line-height: 30px !important;
  }
  .cutoff-display {
    font-size: 38px;
  }
  .mc-mobile-navlabel {
    font-size: 10px;
  }
}

/* ── Landscape phones: chart stays readable ── */
@media (max-height: 500px) and (orientation: landscape) {
  .mc-chart-box {
    height: 200px;
    max-height: 200px;
  }
}
