:root {
  --bg: #f8f3ea;
  --surface: #fffdf9;
  --surface-2: #f2eadd;
  --text: #2b211a;
  --muted: #7d6f63;
  --border: #e8dccb;
  --accent: #d1432a;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3da;
  --basil: #3c7a4b;
  --warn: #9a5b00;
  --warn-soft: #fcefd6;
  --info: #3f6386;
  --info-soft: #e5eef7;
  --shadow: 0 1px 2px rgb(60 40 20 / .05), 0 10px 30px rgb(60 40 20 / .06);
  --radius: 20px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120f;
    --surface: #211b17;
    --surface-2: #2c241e;
    --text: #f4ece3;
    --muted: #a99b8e;
    --border: #3a3029;
    --accent: #ff6a4d;
    --accent-ink: #1b0e0a;
    --accent-soft: #3d221b;
    --basil: #7cc48e;
    --warn: #f2b552;
    --warn-soft: #3a2b13;
    --info: #9cc3ea;
    --info-soft: #1d2a37;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

button { font: inherit; color: inherit; }

/* ---------- Header ---------- */

.top {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { display: block; filter: drop-shadow(0 4px 10px rgb(209 67 42 / .25)); }
.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
  letter-spacing: -.01em;
}
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.seg-style { flex: 1 1 280px; max-width: 420px; }

/* ---------- Layout ---------- */

.layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
}
.inputs { display: grid; gap: 16px; min-width: 0; }

@media (min-width: 960px) {
  .top { padding: 32px 24px 24px; }
  .layout {
    max-width: 1120px;
    padding: 0 24px 48px;
    gap: 20px 24px;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-areas:
      "inputs results"
      "schedule results"
      "steps results";
    align-items: start;
  }
  .inputs { grid-area: inputs; gap: 20px; }
  .results { grid-area: results; position: sticky; top: 20px; }
  .schedule-card { grid-area: schedule; }
  .steps-card { grid-area: steps; }
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  min-width: 0;
}
@media (min-width: 480px) { .card { padding: 20px; } }

.card h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.note + .grid { margin-top: 14px; }
.sub { margin-top: 14px; }

/* ---------- Segmented control ---------- */

.seg {
  display: flex;
  padding: 4px;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 14px;
}
.seg button {
  flex: 1 1 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
@media (hover: hover) { .seg button:hover { color: var(--text); } }
.seg button[aria-checked="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgb(0 0 0 / .1);
}
.seg-style { background: var(--surface); border: 1px solid var(--border); }
.seg-style button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px rgb(209 67 42 / .3); }

/* ---------- Fields / steppers ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
}
.field { min-width: 0; }
.field.wide { grid-column: 1 / -1; }

.field label {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stepper {
  display: flex;
  align-items: stretch;
  height: 52px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.step {
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .step:hover { background: var(--accent-soft); } }
.step:active { background: var(--accent-soft); transform: scale(.94); }
.step:disabled { color: var(--border); background: transparent; cursor: default; transform: none; }
.step svg { width: 18px; height: 18px; }

.value {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: text;
}
.value input {
  min-width: 1ch;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 600 18px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
  outline: none;
}
.value .unit { color: var(--muted); font-weight: 600; font-size: 15px; }

/* ---------- Results ---------- */

.results { border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.results-head h2 { margin: 0; }
.total { color: var(--muted); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.total strong { color: var(--text); font-family: var(--serif); font-size: 22px; font-weight: 700; margin-left: 2px; }

.group + .group { margin-top: 18px; }
.group h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
}
.group h3 small {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ing { list-style: none; margin: 0; padding: 0; }
.ing li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  font-variant-numeric: tabular-nums;
}
.ing .name { flex: 0 0 auto; }
.ing .dots { flex: 1 1 auto; border-bottom: 2px dotted var(--border); transform: translateY(-4px); min-width: 12px; }
.ing .amt { flex: 0 0 auto; font-weight: 700; font-size: 18px; }
.ing .pct { flex: 0 0 52px; text-align: right; color: var(--muted); font-size: 13px; }

.group.summary {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.group.summary .amt { font-size: 15px; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  background: var(--warn-soft);
  color: var(--warn);
}
.alert.info { background: var(--info-soft); color: var(--info); }
.alert svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }

/* ---------- Schedule ---------- */

.bake-at {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-weight: 600;
  font-size: 14px;
}
.bake-at input {
  flex: 1 1 200px;
  max-width: 260px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 600 16px var(--sans);
}
.bake-at input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.schedule-warn:not(:empty) { margin-top: 16px; }
.schedule-warn .alert { margin: 0; }

.timeline {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  position: relative;
}
.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px 14px;
  padding: 0 0 16px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 99px;
  top: 6px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--surface);
  z-index: 1;
}
.timeline li::after {
  content: "";
  position: absolute;
  left: 104px;
  top: 12px;
  bottom: -6px;
  width: 2px;
  background: var(--border);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline li:last-child::before { background: var(--basil); }
.timeline time { text-align: right; font-variant-numeric: tabular-nums; line-height: 1.25; }
.timeline time b { display: block; font-size: 17px; }
.timeline time span { color: var(--muted); font-size: 13px; }
.timeline .what { padding-left: 14px; }
.timeline .what strong { display: block; }
.timeline .what span { color: var(--muted); font-size: 14px; }
.timeline li.past { opacity: .45; }

/* ---------- Steps ---------- */

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 14px 40px;
}
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
}
.steps b { font-weight: 700; }

.footer-actions {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.ghost {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }

/* ---------- Peek bar (mobile) ---------- */

.peek {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  color: var(--text);
  box-shadow: 0 8px 28px rgb(0 0 0 / .18);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
  transition: transform .25s ease, opacity .25s ease;
}
.peek .items { flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; }
.peek .row { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.peek .t { font-weight: 700; color: var(--accent); }
.peek b { font-weight: 700; }
.peek .go { flex: 0 0 auto; color: var(--muted); }
.peek.hide { transform: translateY(140%); opacity: 0; pointer-events: none; }
@media (min-width: 960px) { .peek { display: none; } }

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