:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: #080605;
  color: #F5F1EB;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Plus Jakarta Sans", system-ui, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Ambient Warm Obsidian & Molten Gold Background Mesh */
.ambient-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 12%, rgba(217, 149, 43, 0.22) 0%, transparent 45%),
    radial-gradient(circle at 85% 22%, rgba(168, 88, 28, 0.20) 0%, transparent 48%),
    radial-gradient(circle at 50% 88%, rgba(235, 179, 77, 0.14) 0%, transparent 52%),
    linear-gradient(160deg, #0b0806 0%, #140e0a 48%, #090706 100%);
}

.ambient-orb {
  position: absolute;
  border-radius: 9999px;
  filter: blur(90px);
  opacity: 0.45;
  pointer-events: none;
  animation: floatOrb 22s ease-in-out infinite alternate;
}

.ambient-orb-1 {
  width: 440px;
  height: 440px;
  top: -120px;
  left: -80px;
  background: radial-gradient(circle, rgba(242, 184, 75, 0.55), transparent 70%);
}

.ambient-orb-2 {
  width: 520px;
  height: 520px;
  top: 28%;
  right: -160px;
  background: radial-gradient(circle, rgba(196, 102, 34, 0.45), transparent 70%);
  animation-delay: -7s;
}

.ambient-orb-3 {
  width: 380px;
  height: 380px;
  bottom: -100px;
  left: 30%;
  background: radial-gradient(circle, rgba(235, 190, 105, 0.35), transparent 70%);
  animation-delay: -13s;
}

@keyframes floatOrb {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(32px, 24px, 0) scale(1.08); }
}

/* Apple Liquid Glass Surfaces */
.glass-nav {
  background: rgba(15, 11, 9, 0.68);
  backdrop-filter: blur(26px) saturate(185%);
  -webkit-backdrop-filter: blur(26px) saturate(185%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.glass-panel {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.085) 0%, rgba(255, 255, 255, 0.03) 100%);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.glass-panel-strong {
  background: linear-gradient(155deg, rgba(36, 26, 19, 0.78) 0%, rgba(18, 13, 10, 0.84) 100%);
  backdrop-filter: blur(34px) saturate(195%);
  -webkit-backdrop-filter: blur(34px) saturate(195%);
  border: 1px solid rgba(235, 190, 105, 0.22);
  box-shadow:
    0 26px 64px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 232, 185, 0.24);
}

.glass-subcard {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.glass-pill {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.glass-pill:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(235, 190, 105, 0.42);
  transform: translateY(-1px);
}

.glass-pill:active {
  transform: scale(0.98);
}

.glass-gold-btn {
  background: linear-gradient(135deg, #f3ca6e 0%, #d99b38 55%, #b9751d 100%);
  color: #160e06;
  border: 1px solid rgba(255, 236, 188, 0.65);
  box-shadow:
    0 8px 24px rgba(217, 155, 56, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.glass-gold-btn:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow:
    0 12px 30px rgba(217, 155, 56, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.glass-gold-btn:active {
  transform: scale(0.98);
}

/* Segmented Controls (iOS Style) */
.segmented-track {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 9999px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.segmented-btn {
  border-radius: 9999px;
  transition: all 0.22s ease;
  color: #c2b8ae;
}

.segmented-btn.active {
  background: linear-gradient(180deg, rgba(243, 202, 110, 0.26) 0%, rgba(217, 155, 56, 0.14) 100%);
  color: #fef3c7;
  border: 1px solid rgba(243, 202, 110, 0.42);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Seamless Black-Background Logo Blending */
.logo-blend-hero {
  mix-blend-mode: lighten;
  -webkit-mask-image: radial-gradient(ellipse 92% 92% at 50% 50%, #000 70%, transparent 100%);
  mask-image: radial-gradient(ellipse 92% 92% at 50% 50%, #000 70%, transparent 100%);
}

.logo-blend-video {
  mix-blend-mode: screen;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 58%, transparent 96%);
  mask-image: radial-gradient(circle at 50% 50%, #000 58%, transparent 96%);
}

/* Portrait Avatars */
.henry-avatar {
  border: 2px solid rgba(235, 190, 105, 0.78);
  box-shadow: 0 0 18px rgba(224, 170, 62, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  object-fit: cover;
  object-position: center 18%;
}

.krusty-avatar {
  background: radial-gradient(circle at 50% 35%, #fff8ec, #e8cfa0);
  border: 2px solid rgba(235, 190, 105, 0.78);
  box-shadow: 0 0 16px rgba(224, 170, 62, 0.28);
  object-fit: cover;
  object-position: center 15%;
}

/* 9:16 Apple Glass Device Frame for Krusty's Video */
.device-frame {
  padding: 10px;
  border-radius: 34px;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(243, 202, 110, 0.32);
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

/* Active Video Chapter Highlight */
.chapter-card.chapter-active {
  border-color: rgba(243, 202, 110, 0.65);
  background: linear-gradient(135deg, rgba(243, 202, 110, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
  box-shadow: 0 0 24px rgba(217, 155, 56, 0.18);
}

/* Custom Glass Input Fields */
.glass-input {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-radius: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-input:focus {
  outline: none;
  border-color: rgba(243, 202, 110, 0.7);
  box-shadow: 0 0 0 3px rgba(243, 202, 110, 0.18);
}

.glass-select {
  background-color: rgba(18, 13, 10, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f5f1eb;
  border-radius: 12px;
}

.glass-select:focus {
  outline: none;
  border-color: rgba(243, 202, 110, 0.7);
}

/* Tactile Apple-style Range Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff7e2 0%, #eab95b 100%);
  border: 2px solid #ffffff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5), 0 0 12px rgba(243, 202, 110, 0.55);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff7e2 0%, #eab95b 100%);
  border: 2px solid #ffffff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Hide Scrollbar Utility */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Toast Notification */
#toast-box {
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Dark obsidian backdrop kept behind black-ground logos in both themes */
.media-dark-stage {
  background: radial-gradient(circle at 50% 45%, #1a130d 0%, #090705 100%);
}

.logo-stage-hero {
  transition: all 0.3s ease;
}

/* Recipe Pantry hero animation: a small glass-framed screen */
.rp-hero-stage {
  border-radius: 24px;
  overflow: hidden;
  background: #e9e8e6;
  border: 1px solid rgba(243, 202, 110, 0.55);
  box-shadow:
    0 22px 48px rgba(0, 0, 0, 0.45),
    0 0 0 6px rgba(255, 255, 255, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  /* keeps the rounded corners clipping the video in Safari */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  transform: translateZ(0);
}
html.light-mode .rp-hero-stage {
  border-color: rgba(217, 155, 56, 0.5);
  box-shadow:
    0 18px 40px rgba(90, 60, 20, 0.20),
    0 0 0 6px rgba(255, 255, 255, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.rp-hero-stage video { display: block; }

/* ==================== LIGHT (WHITE) APPLE LIQUID GLASS THEME ==================== */
html.light-mode {
  color-scheme: light;
}

html.light-mode body {
  background-color: #FAF6F0;
  color: #1C1510;
}

html.light-mode .ambient-canvas {
  background:
    radial-gradient(circle at 14% 10%, rgba(235, 180, 75, 0.24) 0%, transparent 46%),
    radial-gradient(circle at 86% 20%, rgba(217, 138, 62, 0.18) 0%, transparent 48%),
    radial-gradient(circle at 50% 90%, rgba(243, 202, 110, 0.20) 0%, transparent 54%),
    linear-gradient(160deg, #FCF9F4 0%, #F4ECE1 50%, #FBF8F3 100%);
}

html.light-mode .ambient-orb {
  opacity: 0.32;
}

html.light-mode .glass-nav {
  background: rgba(255, 252, 247, 0.80);
  border-bottom: 1px solid rgba(130, 92, 46, 0.14);
  box-shadow: 0 8px 28px rgba(72, 48, 22, 0.08);
}

html.light-mode .glass-panel {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.82) 0%, rgba(255, 251, 245, 0.68) 100%);
  border: 1px solid rgba(140, 98, 45, 0.14);
  box-shadow:
    0 18px 42px rgba(72, 48, 22, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

html.light-mode .glass-panel-strong {
  background: linear-gradient(155deg, rgba(255, 254, 251, 0.92) 0%, rgba(252, 246, 237, 0.86) 100%);
  border: 1px solid rgba(196, 138, 42, 0.28);
  box-shadow:
    0 22px 54px rgba(72, 48, 22, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.98);
}

html.light-mode .glass-subcard {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(140, 98, 45, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

html.light-mode .glass-pill {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(140, 98, 45, 0.18);
  color: #2E231A;
  box-shadow: 0 2px 8px rgba(72, 48, 22, 0.05);
}

html.light-mode .glass-pill:hover {
  background: #FFFFFF;
  border-color: rgba(196, 138, 42, 0.55);
}

html.light-mode .segmented-track {
  background: rgba(120, 88, 52, 0.09);
  border: 1px solid rgba(120, 88, 52, 0.14);
  box-shadow: inset 0 1px 4px rgba(72, 48, 22, 0.08);
}

html.light-mode .segmented-btn {
  color: #5C4B3D;
}

html.light-mode .segmented-btn.active {
  background: #FFFFFF;
  color: #1A130D;
  border: 1px solid rgba(196, 138, 42, 0.42);
  box-shadow: 0 3px 10px rgba(72, 48, 22, 0.10);
}

html.light-mode .glass-input,
html.light-mode .glass-select {
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(140, 98, 45, 0.22);
  color: #1A130D;
}

html.light-mode input[type="range"] {
  background: rgba(120, 88, 52, 0.18);
}

html.light-mode .device-frame {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.92), rgba(242, 232, 217, 0.82));
  border: 1px solid rgba(196, 138, 42, 0.38);
  box-shadow:
    0 22px 48px rgba(72, 48, 22, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

html.light-mode .chapter-card.chapter-active {
  border-color: rgba(196, 138, 42, 0.65);
  background: linear-gradient(135deg, rgba(243, 202, 110, 0.22) 0%, rgba(255, 255, 255, 0.85) 100%);
  box-shadow: 0 6px 20px rgba(196, 138, 42, 0.14);
}

/* Frame the black-background Recipe Pantry logo inside a crisp obsidian-gold medallion in Light Mode */
html.light-mode .logo-stage-hero {
  background: radial-gradient(circle at 50% 45%, #19120c 0%, #090705 100%);
  border-radius: 28px;
  padding: 12px;
  border: 1px solid rgba(217, 155, 56, 0.48);
  box-shadow: 0 18px 36px rgba(42, 28, 12, 0.22);
}

/* Accessible Light Mode Typography & Surface Contrast Overrides */
html.light-mode .text-white { color: #1A130D; }
html.light-mode .text-stone-200 { color: #2D231B; }
html.light-mode .text-stone-300,
html.light-mode .text-stone-300\/90 { color: #4A3D32; }
html.light-mode .text-stone-400 { color: #6B5B4E; }
html.light-mode .text-stone-500 { color: #7E6E60; }
html.light-mode .text-amber-100,
html.light-mode .text-amber-200,
html.light-mode .text-amber-200\/90 { color: #8A5207; }
html.light-mode .text-amber-300,
html.light-mode .text-amber-300\/90,
html.light-mode .text-amber-300\/95,
html.light-mode .text-amber-400 { color: #9A5B08; }
html.light-mode .text-sky-200,
html.light-mode .text-sky-300 { color: #0369A1; }
html.light-mode .text-emerald-200,
html.light-mode .text-emerald-300 { color: #047857; }
html.light-mode .text-orange-300 { color: #C2410C; }
html.light-mode .text-fuchsia-100,
html.light-mode .text-fuchsia-200,
html.light-mode .text-fuchsia-300,
html.light-mode .text-fuchsia-300\/90 { color: #A21CAF; }
html.light-mode .text-indigo-200 { color: #4338CA; }
html.light-mode .hero-gradient-word {
  background-image: linear-gradient(to right, #A65E08, #D48116, #8F4208);
}
html.light-mode .border-white\/10 { border-color: rgba(120, 88, 52, 0.15); }
html.light-mode .divide-white\/\[0\.07\] > :not([hidden]) ~ :not([hidden]) { border-color: rgba(120, 88, 52, 0.12); }
html.light-mode .bg-black\/25,
html.light-mode .bg-black\/50 { background-color: rgba(120, 88, 52, 0.055); }
html.light-mode .bg-white\/5,
html.light-mode .bg-white\/\[0\.03\],
html.light-mode .bg-white\/10 { background-color: rgba(120, 88, 52, 0.065); }
html.light-mode .bg-white\/15 { background-color: rgba(120, 88, 52, 0.16); }
html.light-mode .hover\:text-amber-200:hover { color: #9A5B08; }
html.light-mode .hover\:bg-white\/20:hover { background-color: rgba(120, 88, 52, 0.14); }
html.light-mode .bg-amber-400\/15,
html.light-mode .bg-amber-500\/15 { background-color: rgba(217, 155, 56, 0.15); }
html.light-mode .bg-sky-400\/15,
html.light-mode .bg-sky-500\/15 { background-color: rgba(14, 165, 233, 0.12); }
html.light-mode .bg-emerald-500\/10 { background-color: rgba(16, 185, 129, 0.11); }
html.light-mode .bg-fuchsia-500\/10,
html.light-mode .bg-fuchsia-500\/15 { background-color: rgba(217, 70, 239, 0.10); }
html.light-mode .bg-indigo-500\/15 { background-color: rgba(99, 102, 241, 0.12); }
html.light-mode #krusty-modal { background-color: rgba(28, 21, 16, 0.55); }

/* ==================== STUDIO COMPONENTS (Checker, FAQ, diagnostics) ==================== */
.scroll-target {
  scroll-margin-top: 84px;
}

.step-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: #160e06;
  background: linear-gradient(135deg, #f3ca6e 0%, #d99b38 60%, #b9751d 100%);
  border: 1px solid rgba(255, 236, 188, 0.65);
  box-shadow: 0 4px 14px rgba(217, 155, 56, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #d6ccc2;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.13);
}
.status-pill-ok {
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(52, 211, 153, 0.35);
}
.status-pill-warn {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(251, 191, 36, 0.45);
}

/* Compact exact-value field that sits beside a slider */
.pct-input {
  width: 4.6rem;
  padding: 0.25rem 0.45rem;
  text-align: right;
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.paste-area {
  width: 100%;
  min-height: 11rem;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  resize: vertical;
  font-variant-numeric: tabular-nums;
}
.paste-area::placeholder,
.glass-input::placeholder {
  color: rgba(214, 204, 194, 0.45);
}

/* Stacked diagnostic messages */
.diag {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.9rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #e7e0d8;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.diag strong { color: #ffffff; }
.diag a { color: inherit; }
.diag-tag {
  flex-shrink: 0;
  margin-top: 0.1rem;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #d6ccc2;
  background: rgba(255, 255, 255, 0.09);
}
.diag-info .diag-tag { color: #bae6fd; background: rgba(56, 189, 248, 0.16); }
.diag-ok { background: rgba(16, 185, 129, 0.1); border-color: rgba(52, 211, 153, 0.3); color: #d1fae5; }
.diag-ok .diag-tag { color: #a7f3d0; background: rgba(16, 185, 129, 0.2); }
.diag-note { background: rgba(245, 158, 11, 0.09); border-color: rgba(251, 191, 36, 0.28); color: #fef3c7; }
.diag-note .diag-tag { color: #fde68a; background: rgba(245, 158, 11, 0.2); }
.diag-warn { background: rgba(245, 158, 11, 0.16); border-color: rgba(251, 191, 36, 0.5); color: #fef3c7; }
.diag-warn .diag-tag { color: #1c1204; background: #fbbf24; }
.diag-extreme {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(248, 113, 113, 0.6);
  color: #fee2e2;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
  font-size: 0.8rem;
}
.diag-extreme .diag-tag { color: #ffffff; background: #dc2626; }

/* Review table rows */
.checker-row.row-flagged {
  border-color: rgba(251, 191, 36, 0.6);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.row-extra:empty { display: none; }
.row-extra { margin-top: 0.6rem; display: grid; gap: 0.5rem; }
.flag-box {
  display: grid;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.8rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #fef3c7;
  background: rgba(245, 158, 11, 0.12);
  border: 1px dashed rgba(251, 191, 36, 0.5);
}
.flag-box ul { margin: 0; padding-left: 1.1rem; list-style: disc; }
.flag-box button { justify-self: start; }
.flag-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #1c1204;
  background: #fbbf24;
}

.lock-panel {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #d6ccc2;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.18);
}

.metric-tile {
  border-radius: 1rem;
  padding: 0.8rem 0.6rem;
  text-align: center;
}
.metric-tile .metric-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a8a29e;
}
.metric-tile .metric-value {
  display: block;
  margin-top: 0.15rem;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.metric-tile .metric-sub {
  display: block;
  font-size: 11px;
  color: #a8a29e;
  font-variant-numeric: tabular-nums;
}

.arith {
  padding: 0.6rem 0.75rem;
  border-radius: 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  color: #fde68a;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(243, 202, 110, 0.25);
}
.solver-steps {
  margin: 0;
  padding-left: 1.2rem;
  list-style: decimal;
  display: grid;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: #d6ccc2;
  font-variant-numeric: tabular-nums;
}
.solver-steps strong { color: #ffffff; }

/* FAQ */
.faq-card { position: relative; }
.faq-featured {
  border-color: rgba(243, 202, 110, 0.55);
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(243, 202, 110, 0.1), inset 0 1px 0 rgba(255, 232, 185, 0.24);
}
.faq-card:target {
  border-color: rgba(243, 202, 110, 0.75);
  box-shadow: 0 0 0 4px rgba(243, 202, 110, 0.18), 0 20px 50px rgba(0, 0, 0, 0.4);
}
.faq-copy-link {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  opacity: 0.6;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.faq-copy-link:hover,
.faq-copy-link:focus-visible { opacity: 1; background: rgba(255, 255, 255, 0.1); }
.faq-hook { font-family: "Playfair Display", Georgia, serif; font-style: italic; }
.faq-example { font-variant-numeric: tabular-nums; }

.print-only { display: none; }

button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(243, 202, 110, 0.85);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ambient-orb { animation: none; }
}

/* Light mode for the Studio components */
html.light-mode .status-pill { color: #4A3D32; background: rgba(120, 88, 52, 0.07); border-color: rgba(120, 88, 52, 0.18); }
html.light-mode .status-pill-ok { color: #046148; background: rgba(16, 185, 129, 0.12); border-color: rgba(5, 150, 105, 0.35); }
html.light-mode .status-pill-warn { color: #8A4B07; background: rgba(245, 158, 11, 0.16); border-color: rgba(217, 119, 6, 0.45); }
html.light-mode .paste-area::placeholder,
html.light-mode .glass-input::placeholder { color: rgba(107, 91, 78, 0.6); }
html.light-mode .diag { color: #3A2E24; background: rgba(255, 255, 255, 0.7); border-color: rgba(140, 98, 45, 0.16); }
html.light-mode .diag strong { color: #1A130D; }
html.light-mode .diag-tag { color: #4A3D32; background: rgba(120, 88, 52, 0.1); }
html.light-mode .diag-info .diag-tag { color: #075985; background: rgba(14, 165, 233, 0.14); }
html.light-mode .diag-ok { color: #064E3B; background: rgba(16, 185, 129, 0.1); border-color: rgba(5, 150, 105, 0.3); }
html.light-mode .diag-ok .diag-tag { color: #046148; background: rgba(16, 185, 129, 0.18); }
html.light-mode .diag-note { color: #6B3F06; background: rgba(245, 158, 11, 0.1); border-color: rgba(217, 119, 6, 0.3); }
html.light-mode .diag-note .diag-tag { color: #7A4706; background: rgba(245, 158, 11, 0.22); }
html.light-mode .diag-warn { color: #5F3505; background: rgba(245, 158, 11, 0.18); border-color: rgba(217, 119, 6, 0.55); }
html.light-mode .diag-warn .diag-tag { color: #1c1204; background: #f59e0b; }
html.light-mode .diag-extreme { color: #7F1D1D; background: rgba(239, 68, 68, 0.1); border-color: rgba(220, 38, 38, 0.55); }
html.light-mode .diag-extreme strong { color: #7F1D1D; }
html.light-mode .diag-extreme .diag-tag { color: #ffffff; background: #dc2626; }
html.light-mode .checker-row.row-flagged { border-color: rgba(217, 119, 6, 0.6); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14); }
html.light-mode .flag-box { color: #5F3505; background: rgba(245, 158, 11, 0.12); border-color: rgba(217, 119, 6, 0.5); }
html.light-mode .lock-panel { color: #4A3D32; background: rgba(120, 88, 52, 0.05); border-color: rgba(120, 88, 52, 0.25); }
html.light-mode .metric-tile .metric-label,
html.light-mode .metric-tile .metric-sub { color: #6B5B4E; }
html.light-mode .arith { color: #7A4706; background: rgba(243, 202, 110, 0.16); border-color: rgba(196, 138, 42, 0.35); }
html.light-mode .solver-steps { color: #4A3D32; }
html.light-mode .solver-steps strong { color: #1A130D; }
html.light-mode .faq-featured { border-color: rgba(196, 138, 42, 0.6); box-shadow: 0 22px 54px rgba(72, 48, 22, 0.14), 0 0 0 4px rgba(243, 202, 110, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.98); }
html.light-mode .faq-card:target { border-color: rgba(196, 138, 42, 0.8); box-shadow: 0 0 0 4px rgba(243, 202, 110, 0.3), 0 18px 42px rgba(72, 48, 22, 0.1); }
html.light-mode .faq-copy-link:hover,
html.light-mode .faq-copy-link:focus-visible { background: rgba(120, 88, 52, 0.1); }
html.light-mode .hover\:text-rose-300:hover { color: #BE123C; }
html.light-mode .text-rose-300 { color: #BE123C; }
html.light-mode #pantry-modal { background-color: rgba(28, 21, 16, 0.55); }
html.light-mode .bg-white\/\[0\.03\] { background-color: rgba(120, 88, 52, 0.065); }

/* ==================== CLEAN BLACK-ON-WHITE PRINT ==================== */
/* ======================================================================
   TOUCH & PHONE POLISH (iPhone and Android)
   ====================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
button, a, select, label, summary, input[type="range"], .chapter-card { touch-action: manipulation; }
nav.sticky, body > nav:first-of-type { padding-top: env(safe-area-inset-top); }

/* Hover lifts stick after a tap on touch screens. Keep press feedback only. */
@media (hover: none) {
  .glass-pill:hover, .glass-gold-btn:hover, .chapter-card:hover { transform: none; filter: none; }
  .glass-pill:active, .glass-gold-btn:active, .segmented-btn:active, .tabbar-btn:active { transform: scale(0.96); }
}

/* Bottom tab bar */
#mobile-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(16, 11, 8, 0.78);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}
html.light-mode #mobile-tabbar {
  background: rgba(253, 250, 245, 0.82);
  border-top-color: rgba(120, 85, 40, 0.16);
  box-shadow: 0 -8px 28px rgba(120, 85, 40, 0.10);
}
.tabbar-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 50px; border-radius: 16px;
  font-size: 11px; font-weight: 600; line-height: 1.1; color: #a89c90;
  transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease;
}
.tabbar-icon { font-size: 20px; line-height: 1; filter: grayscale(0.85) opacity(0.75); transition: filter 0.2s ease; }
.tabbar-btn.active { color: #fde9b5; background: rgba(243, 202, 110, 0.14); }
.tabbar-btn.active .tabbar-icon { filter: none; }
html.light-mode .tabbar-btn { color: #7a6a58; }
html.light-mode .tabbar-btn.active { color: #8a5a12; background: rgba(217, 155, 56, 0.16); }
@media (min-width: 640px) { #mobile-tabbar { display: none; } }

#mobile-summary-bar { bottom: 12px; }

@media (max-width: 639px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  body[data-tab="calculator"] { padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
  #mobile-summary-bar { bottom: calc(70px + env(safe-area-inset-bottom)); }
  #studio-tabs { padding-top: 0; padding-bottom: 0; }

  /* 16px fields stop iOS Safari from zooming the page on focus */
  input:not([type="range"]), select, textarea { font-size: 16px !important; }

  /* 44pt minimum touch targets */
  .glass-pill, .glass-gold-btn, .segmented-btn, .glass-select, .glass-input:not(textarea),
  .faq-copy-link, .row-remove, #theme-toggle-btn { min-height: 44px; }
  button.glass-pill:not(.hidden), button.glass-gold-btn:not(.hidden) { display: inline-flex; align-items: center; justify-content: center; }
  .segmented-btn { min-width: 44px; }
  #tab-checker button[onclick="clearChecker()"], #tab-calculator button[onclick*="toggleFlourDrawer"] { min-height: 44px; }
  .faq-copy-link, .row-remove, #theme-toggle-btn { min-width: 44px; }
  #krusty-modal .row-remove, #pantry-modal .row-remove { width: 44px; height: 44px; }
  .segmented-btn { padding-left: 12px; padding-right: 12px; }
  .pct-input { width: 84px; }
  .checker-row .glass-select { padding-left: 8px; padding-right: 4px; }

  /* Nothing smaller than 11px */
  .text-\[9px\], .text-\[10px\] { font-size: 11px !important; }
  .diag-tag, .flag-badge { font-size: 11px; }

  /* Lighter glass on small GPUs: pills sit on frosted panels already */
  .glass-pill { -webkit-backdrop-filter: none; backdrop-filter: none; }

  /* Sheets rise from the bottom like native modals */
  #pantry-modal, #krusty-modal { align-items: flex-end; padding: 0; }
  #pantry-modal > div, #krusty-modal > div {
    max-width: none; border-radius: 28px 28px 0 0; max-height: 92dvh;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    overscroll-behavior: contain; animation: sheet-up 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  }
  #formula-title-input { font-size: 18px !important; }

  /* Toasts sit above the tab bar, clear of headings and the notch */
  #toast-box {
    top: auto; bottom: calc(84px + env(safe-area-inset-bottom));
    width: max-content; max-width: calc(100vw - 32px);
    border-radius: 18px; text-align: center; font-size: 13px;
  }
  body[data-tab="calculator"] #toast-box { bottom: calc(150px + env(safe-area-inset-bottom)); }
  nav.glass-nav button[onclick="openKrustyModal()"] { padding-right: 6px; }
  .scroll-target { scroll-margin-top: 72px; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #pantry-modal > div, #krusty-modal > div { animation: none; } }

@media print {
  @page { margin: 14mm; }
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  body { padding: 0 !important; }
  .ambient-canvas,
  .no-print {
    display: none !important;
  }
  .print-only { display: block !important; }
  * {
    color: #000000 !important;
    text-shadow: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    -webkit-text-fill-color: #000000 !important;
  }
  .glass-panel,
  .glass-panel-strong,
  .glass-subcard,
  .diag,
  .arith,
  .lock-panel,
  .flag-box,
  .status-pill,
  .glass-input,
  .glass-select,
  .bg-black\/25,
  .bg-white\/\[0\.03\] {
    background: #ffffff !important;
    border-color: #bdbdbd !important;
  }
  .diag-tag, .flag-badge, .step-num {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
  }
  #dough-composition-bar { display: none !important; }
  main { padding: 0 !important; }
  .lg\:sticky { position: static !important; }
  table { page-break-inside: avoid; }
  input, select, textarea { border: 1px solid #bdbdbd !important; }
}

/* Utility guard: component display rules must never beat .hidden */
.lock-panel.hidden, .diag.hidden, .flag-box.hidden, .metric-tile.hidden { display: none; }
