:root {
  color-scheme: light;
  --paper: #f8f5ec;
  --surface: #fffdf8;
  --ink: #242721;
  --muted: #615f56;
  --line: #e1dace;
  --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);
  --header-hover: var(--accent);
  --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: white; font: 700 1.7rem/1 var(--heading-font); }
nav { display: flex; gap: 24px; }
nav a { display: flex; align-items: center; min-height: 44px; color: var(--header-muted); font-size: .9rem; font-weight: 650; text-decoration: none; line-height: 1.25; }
nav a:hover { color: var(--header-hover); text-decoration: underline; }
.intro { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 14px 30px; padding: 37px 0 28px; border-bottom: 1px solid var(--line); }
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; }
.intro p { margin-top: 12px; color: var(--muted); }
.edition { font-size: .75rem; font-weight: 800; letter-spacing: .12em; color: var(--accent); padding-bottom: 4px; }
.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: white; 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); }
  .intro { padding-top: 24px; }
  .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-tools { margin-top: 24px; scroll-margin-top: 16px; }
.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; } }

:root[data-theme="classic"] {
  --paper: #f4f4f2;
  --surface: #fff;
  --ink: #181818;
  --muted: #53514f;
  --line: #dad8d4;
  --accent: #b33e08;
  --accent-dark: #852900;
  --accent-soft: #fff0e4;
  --olive: #f0eeeb;
  --input: #fff;
  --field-line: #c9c5c0;
  --input-muted: #f1f0ee;
  --warning: #972b00;
  --header: #171717;
  --header-text: #fff;
  --header-muted: #eee;
  --header-hover: #ff9a53;
  --heading-font: system-ui, sans-serif;
}
[data-theme="classic"] .mark { background: #f07824; color: #171717; }
[data-theme="classic"] .header :focus-visible { outline-color: #ff9a53; }

.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; }
  .header-inner nav { order: 3; flex-basis: 100%; flex-wrap: wrap; gap: 0 20px; }
}
@media (max-width: 540px) {
  .frame { width: calc(100% - 28px); }
  .header-inner { display: grid; grid-template-columns: minmax(0, 1fr); }
  .header-inner nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; border-top: 1px solid var(--line); }
  .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; }
}
