:root {
  color-scheme: light dark;
  --bg: #f7f1ea;
  --surface: #fffdfa;
  --surface-sunken: #f3eae0;
  --text: #2a1d16;
  --muted: #6f5b4e;
  --line: #dfd0c1;
  --accent: #8a3b12;
  --accent-text: #fff8f1;
  --result-bg: #8a3b12;
  --result-text: #fff8f1;
  --result-muted: #f4d9c3;
  --result-line: #ad5f33;
  --error: #b3261e;
  --chart-cooked: #b5500f;
  --chart-smoke: #1f8fb8;
  --chart-trim: #e0a100;
  --glow: #f2a65e;
  --ember: #ffc27a;
  --header-height: 61px;
  --gutter-left: max(16px, env(safe-area-inset-left));
  --gutter-right: max(16px, env(safe-area-inset-right));
  --heat: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1613;
    --surface: #27201b;
    --surface-sunken: #1f1915;
    --text: #f3e9df;
    --muted: #b8a596;
    --line: #443629;
    --accent: #e8935a;
    --accent-text: #2a1408;
    --result-bg: #3a2517;
    --result-text: #fff3e7;
    --result-muted: #d3b39b;
    --result-line: #5c3d28;
    --error: #ff9f94;
    --chart-cooked: #cf4f1c;
    --chart-smoke: #2a8fd0;
    --chart-trim: #b08f12;
    --glow: #a8481a;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}

/* Warms up behind the page as the form fills in. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 55% at 50% 105%, var(--glow), transparent 72%);
  opacity: calc(var(--heat) * 0.55);
  pointer-events: none;
  transition: opacity 0.6s ease;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.site-header-inner {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px var(--gutter-right) 8px var(--gutter-left);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 6px;
  min-height: 44px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.flame {
  width: 30px;
  height: 30px;
  overflow: visible;
  transform: scale(calc(0.8 + var(--heat) * 0.45));
  transform-origin: 50% 80%;
  transition: transform 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.flame-outer {
  fill: #e8792f;
}

.flame-inner {
  fill: #ffd9a0;
}

.flame-outer,
.flame-inner {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: flicker 1.6s ease-in-out infinite alternate;
}

.flame-inner {
  animation-duration: 1.1s;
}

@keyframes flicker {
  from {
    transform: scale(1, 1) skewX(-2deg);
  }
  to {
    transform: scale(0.95, 1.07) skewX(2deg);
  }
}

.menu-toggle {
  display: none;
}

.tabs {
  position: relative;
  display: flex;
  flex: 1;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  z-index: 1;
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease, transform 0.12s ease;
}

.tab:hover {
  color: var(--text);
}

.tab:active {
  transform: scale(0.95);
}

.tab[aria-current="page"] {
  color: var(--accent-text);
}

.tab:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tab-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 999px;
  background: var(--accent);
}

.tab-indicator.is-ready {
  transition: transform 0.32s cubic-bezier(0.3, 1.3, 0.5, 1), width 0.32s ease;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px var(--gutter-right) calc(88px + env(safe-area-inset-bottom)) var(--gutter-left);
}

.view-body,
.layout {
  display: grid;
  gap: 16px;
}

.layout {
  align-items: start;
}

.masthead {
  padding: 4px 4px 0;
}

h1 {
  margin: 2px 0 4px;
  font-size: 2.1rem;
  line-height: 1.1;
}

h1:focus {
  outline: none;
}

.lede {
  margin: 0;
  color: var(--muted);
}

.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.field {
  min-width: 0;
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.label-row label {
  margin-bottom: 0;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-sunken);
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.input-wrap:focus-within {
  transform: translateY(-1px);
}

.input-wrap.is-done::after {
  content: "\2713";
  color: var(--accent);
  font-weight: 800;
  animation: pop 0.28s cubic-bezier(0.3, 1.8, 0.5, 1);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
}

.input-wrap:focus-within {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.input-wrap.has-error {
  border-color: var(--error);
}

input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.15rem; /* Above 16px so iOS doesn't zoom on focus. */
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

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

.affix {
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-sunken);
}

.segmented button {
  min-width: 44px;
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

.segmented button:active,
.reset:active {
  transform: scale(0.95);
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.error {
  margin: 6px 0 0;
  color: var(--error);
  font-size: 0.85rem;
  font-weight: 600;
}

.error:empty {
  display: none;
}

.group {
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.group legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.group .field {
  margin-bottom: 8px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.ingredients {
  display: grid;
  gap: 12px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.ingredients:empty {
  display: none;
}

.ingredient {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ingredient-head {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ingredient-head .field {
  flex: 1;
}

.ingredient select {
  width: 100%;
  min-height: 50px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-sunken);
  color: inherit;
  font: inherit;
  font-weight: 400;
}

.remove-ingredient {
  width: 44px;
  height: 50px;
  margin-bottom: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.4rem;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.12s ease;
}

.remove-ingredient:hover {
  color: var(--error);
}

.remove-ingredient:active,
.add-ingredient:active {
  transform: scale(0.95);
}

.add-ingredient {
  width: 100%;
  min-height: 48px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.reset {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.result {
  position: relative;
  overflow: hidden;
  border-color: var(--result-bg);
  background: var(--result-bg);
  color: var(--result-text);
}

.result-label {
  margin: 0;
  color: var(--result-muted);
  font-weight: 600;
}

.result-price {
  margin: 0;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.ember {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 6px var(--ember);
  pointer-events: none;
}

.result-note {
  margin: 4px 0 0;
  color: var(--result-muted);
}

.weight-chart {
  margin-top: 16px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.chart-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.segments {
  display: flex;
  gap: 2px;
  height: 14px;
  overflow: hidden;
  border-radius: 4px;
}

.segment {
  flex: 0 1 0;
  min-width: 0;
  transition: flex-grow 0.45s cubic-bezier(0.3, 1, 0.5, 1);
}

.segment-cooked {
  background: var(--chart-cooked);
}

.segment-smoke {
  background: var(--chart-smoke);
}

.segment-trim {
  background: var(--chart-trim);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
}

.chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.breakdown {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--result-line);
}

.breakdown dt {
  color: var(--result-muted);
}

.breakdown dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Keeps the price in view on phones while the result card is off screen. */
.price-bar {
  position: fixed;
  right: var(--gutter-right);
  bottom: calc(12px + env(safe-area-inset-bottom) + var(--keyboard, 0px));
  left: var(--gutter-left);
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--result-bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 30%);
  color: var(--result-text);
  pointer-events: none;
  transform: translateY(calc(100% + 40px));
  transition: transform 0.3s cubic-bezier(0.3, 1.2, 0.5, 1);
}

.price-bar.is-active:not(.is-covered) {
  transform: translateY(0);
}

.price-bar-label {
  color: var(--result-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.price-bar-value {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.coming-soon {
  justify-items: center;
  padding: 48px 0;
  text-align: center;
}

.flame-large {
  width: 96px;
  height: 96px;
  transform: none;
}

.foot {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 340px) {
  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* Small screens: the tabs move into a menu behind the hamburger button. */
@media (max-width: 859.98px) {
  .menu-toggle {
    display: grid;
    flex: none;
    gap: 5px;
    align-content: center;
    justify-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
  }

  .menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.22s ease, opacity 0.22s ease;
  }

  .menu-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  .is-open .menu-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .is-open .menu-toggle span:nth-child(2) {
    opacity: 0;
  }

  .is-open .menu-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .tabs {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: grid;
    gap: 4px;
    max-height: calc(100dvh - var(--header-height));
    padding: 8px var(--gutter-right) 12px var(--gutter-left);
    overflow-y: auto;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    box-shadow: 0 10px 20px rgb(0 0 0 / 15%);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  }

  .is-open .tabs {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .tab {
    min-height: 48px;
    border-radius: 10px;
  }

  .tab[aria-current="page"] {
    background: var(--accent);
  }

  .tab-indicator {
    display: none;
  }
}

@media (min-width: 760px) {
  .page {
    padding-bottom: 32px;
  }

  .layout {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  .result {
    position: sticky;
    top: calc(var(--header-height) + 16px);
  }

  .price-bar {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
