:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --ink: #25231f;
  --muted: #69645b;
  --line: #d9d2c8;
  --accent: #a5472a;
  --accent-dark: #7e321d;
  --accent-soft: #f4e5dd;
  --sage: #466851;
  --sage-soft: #e8f0e9;
  --warning: #77551b;
  --warning-soft: #fbf2dd;
  --error: #a12c2c;
  --shadow: 0 18px 50px rgba(62, 48, 35, 0.09);
  --radius-lg: 24px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.skip-link {
  position: absolute;
  top: auto;
  left: -10000px;
  z-index: 100;
  width: 1px;
  height: 1px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 10px 16px;
}

.skip-link:focus {
  position: fixed;
  top: 10px;
  left: 10px;
  width: auto;
  height: auto;
  overflow: visible;
}

:focus-visible {
  outline: 3px solid #266db3;
  outline-offset: 3px;
}

.site-header {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--accent-dark);
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand svg { flex: 0 0 auto; }

nav { display: flex; gap: 24px; }
nav a { color: var(--muted); font-weight: 650; text-decoration: none; }
nav a:hover { color: var(--accent-dark); }

main { overflow: hidden; }

.intro {
  max-width: 900px;
  margin: 50px auto 28px;
  padding: 0 28px;
  text-align: center;
}

.eyebrow,
.step-label {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.095em;
  line-height: 1.3;
  text-transform: uppercase;
}

h1, h2, h3 { line-height: 1.14; letter-spacing: -0.035em; }
h1 { margin: 0; font-size: clamp(2.35rem, 6vw, 4.65rem); }
h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.2rem); }
h3 { font-size: 1.35rem; }

.lede {
  max-width: 700px;
  margin: 18px auto 22px;
  color: var(--muted);
  font-size: clamp(1.06rem, 2vw, 1.25rem);
}

.privacy-note {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #cbdacc;
  border-radius: 999px;
  background: var(--sage-soft);
  color: #304d3a;
  padding: 9px 16px;
  font-size: 0.92rem;
}

.privacy-note svg { width: 22px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; }

.calculator-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 28px 90px;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.8fr);
  gap: 22px;
  align-items: start;
}

.calculator-card,
.results-card {
  border: 1px solid rgba(96, 78, 60, 0.16);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.calculator-card { padding: clamp(22px, 4vw, 38px); }
.results-card { position: sticky; top: 18px; padding: 28px; }

.section-heading,
.result-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.factor-badge {
  border: 1px solid #c9bdaf;
  border-radius: 999px;
  background: #faf8f4;
  color: var(--muted);
  padding: 7px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.servings-grid {
  margin-top: 25px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: start;
}

.field-group label,
.quick-scale legend {
  display: block;
  margin-bottom: 7px;
  font-weight: 720;
}

.field-group input,
.ingredient-row input,
.ingredient-row select {
  width: 100%;
  min-height: 50px;
  border: 1px solid #bdb5aa;
  border-radius: 11px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
}

input:hover, select:hover { border-color: #8f8579; }
input[aria-invalid="true"] { border-color: var(--error); background: #fff8f8; }

.field-error,
.row-error {
  min-height: 1.35em;
  margin: 5px 0 0;
  color: var(--error);
  font-size: 0.84rem;
  line-height: 1.35;
}

.serving-divider { padding-top: 39px; color: var(--muted); font-weight: 700; }

.quick-scale { margin: 10px 0 0; padding: 0; border: 0; }
.button-row { display: flex; gap: 9px; flex-wrap: wrap; }

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 16px;
  font-weight: 760;
}

.primary-button {
  background: var(--accent);
  color: white;
  box-shadow: 0 7px 18px rgba(165, 71, 42, 0.2);
}
.primary-button:hover { background: var(--accent-dark); }

.secondary-button { border-color: #bdb5aa; background: white; color: var(--ink); }
.secondary-button:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }

.text-button { background: transparent; color: var(--accent-dark); padding-inline: 8px; }
.text-button:hover { background: var(--accent-soft); }

.ingredient-section {
  margin-top: 31px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.ingredient-labels,
.ingredient-row {
  display: grid;
  grid-template-columns: minmax(85px, .65fr) minmax(120px, .9fr) minmax(170px, 1.7fr) 48px;
  gap: 10px;
}

.ingredient-labels {
  margin: 23px 0 7px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 750;
}

.ingredient-row { margin-bottom: 7px; align-items: start; }
.ingredient-row .input-wrap { min-width: 0; }
.ingredient-row .mobile-label { display: none; }
.ingredient-row .row-error { margin-bottom: 0; }

.delete-button {
  width: 48px;
  min-height: 50px;
  border-color: transparent;
  background: #f7f4ef;
  color: #766f65;
  padding: 8px;
  font-size: 1.25rem;
}
.delete-button:hover { background: #f8e7e4; color: var(--error); }

.calculator-actions { margin-top: 26px; display: flex; gap: 10px; }
.calculator-actions .primary-button { flex: 1; }

.result-topline { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.copy-button { background: var(--ink); color: white; white-space: nowrap; }
.copy-button:hover:not(:disabled) { background: var(--accent-dark); }
.copy-button:disabled { cursor: not-allowed; opacity: .45; }

.empty-state { min-height: 365px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state svg { width: 84px; margin: 0 auto 18px; fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.empty-state p { margin: 0; color: var(--ink); font-weight: 750; }
.empty-state span { font-size: .92rem; }

.result-summary { margin: 20px 0 16px; color: var(--muted); }
.result-summary strong { color: var(--ink); }
.scaled-list { list-style: none; margin: 0; padding: 0; }
.scaled-item { padding: 13px 0; border-bottom: 1px solid #e7e1d9; display: flex; gap: 12px; align-items: baseline; }
.scaled-amount { min-width: 94px; color: var(--accent-dark); font-size: 1.08rem; font-weight: 820; }
.scaled-name { font-weight: 650; overflow-wrap: anywhere; }

.warning-list { margin-top: 20px; display: grid; gap: 9px; }
.warning-list h3 { margin: 0 0 2px; font-size: 1rem; letter-spacing: -0.01em; }
.warning-item {
  margin: 0;
  border-left: 4px solid #c29542;
  border-radius: 8px;
  background: var(--warning-soft);
  color: #5f4517;
  padding: 11px 12px;
  font-size: .9rem;
  line-height: 1.45;
}

.math-note { margin-top: 18px; color: var(--muted); font-size: .84rem; }
.copy-status { min-height: 1.5em; margin: 12px 0 0; color: var(--sage); font-size: .9rem; font-weight: 700; }

.content-section,
.faq-section { max-width: 1120px; margin: 0 auto; padding: 85px 28px; }
.content-section { border-top: 1px solid var(--line); display: grid; grid-template-columns: 1.25fr .75fr; gap: clamp(35px, 7vw, 90px); }
.content-main > p:not(.eyebrow, .formula) { color: var(--muted); }
.formula { display: inline-block; margin: 10px 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); padding: 10px 14px; }
.note-box { margin-top: 26px; border-left: 4px solid var(--sage); background: var(--sage-soft); padding: 17px 19px; }
.note-box p { margin: 3px 0 0; color: #45604c; }

.example-card { align-self: center; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-strong); padding: 28px; box-shadow: var(--shadow); }
.example-card h3 { margin: 0 0 16px; }
.example-card ol { margin: 0; padding: 0; list-style: none; counter-reset: example; }
.example-card li { counter-increment: example; display: grid; grid-template-columns: 30px 1fr; gap: 0 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.example-card li::before { content: counter(example); grid-row: 1 / 3; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: .8rem; font-weight: 800; }
.example-card li span { color: var(--muted); font-size: .86rem; }

.faq-section { max-width: 1180px; padding-top: 70px; }
.faq-grid { margin-top: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-strong); padding: 0 18px; }
summary { cursor: pointer; padding: 17px 28px 17px 0; font-weight: 760; line-height: 1.35; }
details p { margin: 0 0 18px; color: var(--muted); }

footer { margin-top: 35px; border-top: 1px solid var(--line); padding: 35px 28px 45px; text-align: center; color: var(--muted); }
footer p { margin: 2px 0; }
footer strong { color: var(--ink); }

@media (max-width: 900px) {
  .calculator-shell { grid-template-columns: 1fr; }
  .results-card { position: static; }
  .empty-state { min-height: 220px; }
}

@media (max-width: 680px) {
  html { scroll-behavior: auto; }
  .site-header { padding: 16px 18px; }
  nav { display: none; }
  .intro { margin-top: 28px; padding: 0 18px; }
  .privacy-note { align-items: flex-start; border-radius: 14px; text-align: left; }
  .calculator-shell { padding: 10px 12px 65px; }
  .calculator-card, .results-card { border-radius: 18px; }
  .calculator-card, .results-card { padding: 20px 16px; }
  .section-heading { align-items: flex-start; }
  .factor-badge { margin-top: 1px; white-space: normal; text-align: right; }
  .servings-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .serving-divider { display: none; }
  .ingredient-heading { display: block; }
  .ingredient-heading .text-button { margin-top: 8px; margin-left: -8px; }
  .ingredient-labels { display: none; }
  .ingredient-row { margin-top: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) 48px; border-top: 1px solid var(--line); padding-top: 15px; }
  .ingredient-row .amount-wrap { grid-column: 1; }
  .ingredient-row .unit-wrap { grid-column: 2; }
  .ingredient-row .name-wrap { grid-column: 1 / 3; }
  .ingredient-row .delete-button { grid-column: 3; grid-row: 1; margin-top: 28px; }
  .ingredient-row .mobile-label { display: block; margin: 0 0 5px; color: var(--muted); font-size: .78rem; font-weight: 750; }
  .calculator-actions { flex-direction: column; }
  .calculator-actions button { width: 100%; }
  .result-topline { align-items: flex-start; }
  .copy-button { padding-inline: 12px; }
  .scaled-item { display: block; }
  .scaled-amount { display: block; min-width: 0; }
  .content-section { grid-template-columns: 1fr; padding: 65px 18px; }
  .faq-section { padding: 60px 18px; }
  .faq-grid { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  h1 { font-size: 2.1rem; }
  .servings-grid { grid-template-columns: 1fr; }
  .result-topline { display: block; }
  .copy-button { margin-top: 14px; width: 100%; }
}

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