:root {
  color-scheme: light;
  --paper: #f8f5ec;
  --surface: #fffdf8;
  --ink: #242721;
  --muted: #615f56;
  --line: #e1dace;
  --on-accent: #fff;
  --accent: #a83f24;
  --accent-dark: #82301c;
  --accent-soft: #fae9df;
  --olive: #e8eade;
  --input: #fffefa;
  --field-line: #cfc7b9;
  --input-muted: #f2eee4;
  --warning: #8a2816;
  --header: var(--surface);
  --header-text: var(--ink);
  --header-muted: var(--muted);
  --heading-font: Georgia, serif;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; }
.frame { width: min(1160px, calc(100% - 64px)); margin-inline: auto; }
.header { background: var(--header); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 72px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--header-text); font-weight: 800; font-size: 1.2rem; letter-spacing: -.045em; line-height: .93; }
.brand-sub { display: block; font-size: .77rem; letter-spacing: .01em; margin-top: 5px; }
.mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font: 700 1.7rem/1 var(--heading-font); }
nav a:hover { color: var(--header-hover); text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
h1 { font: 600 clamp(2rem, 6vw, 4.35rem)/1.09 var(--heading-font); letter-spacing: -.045em; text-wrap: balance; }
.presets { margin: 24px 0; }
.section-line { display: flex; align-items: start; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; }
.section-line > span { color: var(--muted); font-size: .87rem; }
h2 { font-size: 1.24rem; letter-spacing: -.033em; }
.preset-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.preset { display: flex; flex-direction: column; gap: 6px; text-align: left; justify-content: space-between; min-height: 77px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
.preset strong { font-size: .91rem; line-height: 1.18; }
.preset span { color: var(--muted); font-size: .79rem; }
.preset[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.preset:hover { border-color: var(--accent); }
.workspace { display: grid; grid-template-columns: .9fr 1.1fr; gap: 18px; align-items: start; scroll-margin-top: 16px; }
.panel { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 22px; min-width: 0; }
.mode-group { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 10px; background: var(--paper); margin: 15px 0; }
.mode-group button { min-height: 44px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font-size: .88rem; font-weight: 650; padding: 5px; line-height: 1.25; }
.mode-group button[aria-pressed="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
label { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: .88rem; font-weight: 700; }
input, select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--field-line); border-radius: 8px; background: var(--input); color: var(--ink); padding: 9px 10px; font-size: 1rem; }
select { appearance: none; padding-right: 31px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) center, calc(100% - 11px) center; background-size: 5px 5px; background-repeat: no-repeat; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
details { margin: 15px 0; border-block: 1px solid var(--line); }
summary { cursor: pointer; padding: 12px 0; font-size: .89rem; font-weight: 750; }
.details-fields { padding-bottom: 14px; }
.primary { width: 100%; margin-top: 3px; min-height: 44px; border: 0; border-radius: 9px; color: var(--on-accent); background: var(--accent); font-weight: 800; }
.primary:hover { background: var(--accent-dark); }
.pill { padding: 5px 9px; background: var(--olive); border-radius: 999px; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 15px 0 14px; margin-bottom: 3px; border-bottom: 1px solid var(--line); }
.metric small { display: block; color: var(--muted); font-size: .79rem; font-weight: 700; }
.metric strong { display: block; font-size: clamp(1.08rem, 2.4vw, 1.75rem); letter-spacing: -.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ingredients { width: 100%; border-collapse: collapse; font-size: .91rem; font-variant-numeric: tabular-nums; }
.ingredients th, .ingredients td { padding: 8px 0 8px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.ingredients th:first-child, .ingredients td:first-child { padding-left: 0; text-align: left; }
.ingredients thead th { color: var(--muted); font-size: .78rem; }
.ingredients tbody tr:last-child td { border-bottom: 0; }
.ingredients td:last-child { font-weight: 750; }
.note, .planner .section-line p { font-size: .89rem; color: var(--muted); line-height: 1.5; }
.result .note { margin-top: 10px; }
.error { font-size: .9rem; color: var(--warning); padding: 8px 0; }
.planner { margin-top: 18px; scroll-margin-top: 16px; }
.planner .section-line p { margin-top: 3px; }
.duration { color: var(--accent-dark); font-weight: 750; }
.planner-fields { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr) minmax(0, 1.2fr); gap: 13px; margin: 14px 0 8px; }
.check { min-height: 44px; flex-direction: row; align-items: center; grid-column: 1 / -1; font-weight: 650; }
.check input { width: 18px; height: 18px; flex: none; min-height: auto; accent-color: var(--accent); }
.timeline { margin: 12px 0 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline time { font-size: .85rem; color: var(--muted); }
.timeline .phase-meta { grid-column: 2; grid-row: 1; font-size: .88rem; color: var(--muted); }
.footer { display: flex; justify-content: space-between; gap: 10px; padding-block: 23px; color: var(--muted); font-size: .83rem; }
@media (max-width: 890px) { .preset-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 720px) {
  .frame { width: calc(100% - 32px); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .planner-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .planner-fields label:nth-child(3) { grid-column: 1 / -1; }
  .panel { padding: 16px; }
}
@media (max-width: 440px) {
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .mode-group { grid-template-columns: repeat(2, 1fr); }
  .footer { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
input[readonly], input:disabled { background: var(--input-muted); color: var(--muted); }
.fields .check { grid-column: 1 / -1; }
.save-recipe { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.save-recipe label { flex: 1 1 175px; }
.secondary { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 12px; border: 1px solid var(--field-line); background: var(--surface); color: var(--ink); border-radius: 8px; font-size: .89rem; font-weight: 750; cursor: pointer; }
.secondary:hover { border-color: var(--accent); color: var(--accent-dark); }
.library { margin-top: 18px; scroll-margin-top: 16px; }
.library .section-line { flex-wrap: wrap; }
.library h2 { margin-bottom: 3px; }
.file-button { position: relative; flex-direction: row; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-button:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }
.recipe-status:not(:empty) { margin-top: 8px; }
.recipe-status[data-error="true"] { color: var(--warning); }
.saved-list { list-style: none; padding: 0; margin: 12px 0 0; }
.saved-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 10px 0; border-top: 1px solid var(--line); }
.saved-name { flex: 1 1 150px; overflow-wrap: anywhere; }
.saved-name span { display: block; }
.library-empty { margin-top: 12px; }
.water-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 12px; align-items: start; }
.water-card h3 { font-size: 1.06rem; margin-bottom: 10px; }
.water-card form > .note { margin-top: 8px; }
#ice-form { margin-top: 10px; }
.water-readout { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 15px; margin-top: 12px; padding: 12px; background: var(--olive); border-radius: 9px; }
.water-readout:empty { display: none; }
.water-readout .metric { flex: 1 1 auto; }
.water-card > form + .note { margin-top: 9px; }
.water-card .water-warning { color: var(--warning); width: 100%; }
#ice-staging { margin-top: 5px; }
@media (max-width: 720px) { .water-grid { grid-template-columns: 1fr; } }

.header-preferences { display: flex; gap: 8px; }
.preference-control { min-width: 0; }
.preference-control label { color: var(--header-muted); font-size: .875rem; line-height: 1.2; margin-bottom: 4px; }
.preference-control select { width: auto; min-width: 124px; font-size: 1rem; }
.ingredients { table-layout: fixed; }
.ingredients th, .ingredients td { overflow-wrap: anywhere; }
.ingredients th:first-child { width: 39%; text-wrap: pretty; }
.ingredients thead th { font-size: .86rem; }
label { line-height: 1.3; }
input[type="datetime-local"] { display: block; max-width: 100%; }
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: start; }
.metric { min-width: 0; }
.saved-list button { max-width: 100%; }
#planner-recipe, .recipe-status { overflow-wrap: anywhere; }
@media (max-width: 1000px) {
  .header-inner { flex-wrap: wrap; gap: 8px 16px; padding-block: 10px; }
}
@media (max-width: 540px) {
  .frame { width: calc(100% - 28px); }
  .header-inner { display: grid; grid-template-columns: minmax(0, 1fr); }
  .header-preferences { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preference-control select { width: 100%; min-width: 0; }
  .planner-fields { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: minmax(0, 1fr); }
  .timeline .phase-meta { grid-column: auto; grid-row: auto; }
  .metrics { gap: 8px; }
  .metric small, .preset span { font-size: .85rem; }
  .ingredients th, .ingredients td { padding-inline-start: 5px; }
}
@media (max-width: 360px) {
  .panel { padding: 12px; }
  .ingredients { font-size: .84rem; }
  .ingredients thead th { font-size: .8rem; }
  .ingredients th:first-child { width: 36%; }
  .fields { gap: 10px; }
}

/* Each tab keeps its form state while another screen is active. */
[hidden] { display: none !important; }
body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
.frame {
  width: min(1140px, calc(100% - max(28px, env(safe-area-inset-left) + env(safe-area-inset-right) + 18px)));
}
.screen { padding-top: clamp(18px, 4vw, 38px); }
.screen > h1 { font-size: clamp(2rem, 5vw, 3.65rem); }
.screen-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block: 16px; }
.screen-actions a, .hero-action { text-decoration: none; }
.bottom-nav {
  position: fixed;
  inset: auto 0 0;
  z-index: 2;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.nav-inner {
  max-width: 640px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 4px 1px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 10px;
  font-size: clamp(.7rem, 2.8vw, .85rem);
  font-weight: 700;
}
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav a:hover, .bottom-nav a[aria-current] { color: var(--accent-dark); background: var(--accent-soft); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  overflow: hidden;
  min-height: 280px;
  border-radius: 24px;
  background: #29211d;
  color: #fff9ed;
}
.hero-copy { padding: clamp(22px, 4.7vw, 52px); }
.hero-brand { color: #ffbc98; font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.hero h1 { margin-top: 9px; text-wrap: unset; }
.hero-copy p + h1 + p { margin-top: 12px; color: #e7d9ce; max-width: 35ch; }
.hero-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 8px 18px;
  margin-top: 20px;
  background: #ffad79;
  color: #2b1c15;
}
.hero-action:hover { background: #ffd0b2; }
.hero :focus-visible { outline-color: #ffbc98; }
.hero-art {
  background: url('./dough-pattern.svg') center / min(34vw, 420px) no-repeat;
}
.dashboard-section { margin-top: 26px; }
.dashboard-section .section-line { align-items: center; }
.text-link { color: var(--accent-dark); min-height: 44px; display: inline-flex; align-items: center; font-weight: 700; }
.quick-grid, .tools-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.quick-grid > .note { grid-column: 1 / -1; }
.recipe-link, .tool-link {
  display: flex;
  gap: 6px;
  min-height: 65px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.recipe-link:hover, .tool-link:hover { border-color: var(--accent); }
.recipe-link { flex-direction: column; justify-content: center; }
.recipe-link span, .tool-link div span { color: var(--muted); font-size: .86rem; }
.tool-link { align-items: center; gap: 11px; }
.tool-link div { flex: 1; }
.tool-link div span { display: block; }
.tool-icon {
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 1.25rem;
}
.arrow { color: var(--muted); }
.settings-panel, .utility-form { max-width: 630px; margin-top: 18px; }
.inline-action { margin-top: 12px; }
button:disabled { opacity: .55; cursor: default; }
@media (max-width: 800px) {
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .hero { grid-template-columns: minmax(0, 1fr); position: relative; min-height: auto; }
  .hero-copy { z-index: 1; width: min(100%, 340px); }
  .hero-art {
    position: absolute;
    inset: 0;
    background-position: calc(100% + 92px) calc(50% + 24px);
    background-size: 230px;
    opacity: .22;
  }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools-grid { grid-template-columns: 1fr; }
  .header-inner { min-height: 62px; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #191614;
  --surface: #25211e;
  --ink: #fff7ee;
  --muted: #c9bbb0;
  --line: #4d4038;
  --accent: #ffa979;
  --accent-dark: #ffbb96;
  --accent-soft: #473026;
  --on-accent: #261712;
  --olive: #383831;
  --input: #201c19;
  --field-line: #766458;
  --input-muted: #322b25;
  --warning: #ffb29c;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --paper: #191614;
    --surface: #25211e;
    --ink: #fff7ee;
    --muted: #c9bbb0;
    --line: #4d4038;
    --accent: #ffa979;
    --accent-dark: #ffbb96;
    --accent-soft: #473026;
    --on-accent: #261712;
    --olive: #383831;
    --input: #201c19;
    --field-line: #766458;
    --input-muted: #322b25;
    --warning: #ffb29c;
  }
}

.mixer-help { max-width: 630px; margin-top: 14px; }
.mixer-help h2 { margin-top: 14px; }
.mixer-help ol { margin: 6px 0 10px; padding-inline-start: 1.4em; }
.mixer-help li + li { margin-top: 6px; }
.mixer-help p:last-child { color: var(--muted); font-size: .9rem; }

.mixer-example { max-width: 630px; margin-top: 16px; }
.mixer-example dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 8px 12px;
  margin: 8px 0 12px;
}
.mixer-example dt { color: var(--muted); font-size: .88rem; }
.mixer-example dd { margin: 0; font-weight: 750; }
.mixer-equation { margin-top: 8px; color: var(--accent-dark); }

.batch-checklist { margin-bottom: 18px; }
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  margin-top: 12px;
  overflow-wrap: anywhere;
}
.checklist-grid h3 { font-size: .92rem; }
.checklist-grid ul { margin: 5px 0 0; padding-inline-start: 1.2em; }
.checklist-grid li + li { margin-top: 3px; }

.recipe-guide { margin: 0 0 18px; }
.recipe-guide > summary { font-size: 1.04rem; padding: 0; }
.recipe-guide ol { margin-block: 14px 4px; padding-inline-start: 1.4em; }
.recipe-guide li { padding-inline-start: 4px; margin-bottom: 12px; }
.recipe-guide li::marker { color: var(--accent-dark); font-weight: 750; }
.recipe-guide li p { margin-top: 3px; color: var(--muted); }

.hero-actions, .calculator-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.hero-actions { margin-top: 20px; }
.hero-actions .hero-action { margin: 0; }
.hero-actions .secondary, .calculator-heading .secondary { text-decoration: none; }
.calculator-heading { justify-content: space-between; }
.calculator-heading h1 { font-size: clamp(2rem, 5vw, 3.65rem); }
.recipe-guide { scroll-margin-top: max(12px, env(safe-area-inset-top)); }
.recipe-guide > summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.recipe-guide > summary::-webkit-details-marker { display: none; }
.recipe-guide > summary::after { content: ''; flex: none; width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-inline-end: 4px; }
.recipe-guide[open] > summary::after { transform: rotate(225deg); }
.guide-change { font-size: .88rem; }
.recipe-guide ol { margin-top: 2px; }

.module-label { color: var(--accent-dark); font-weight: 750; margin-bottom: 5px; }
