:root {
  --bg: #f3f0ea;
  --card: #fffcf8;
  --ink: #1f1a17;
  --muted: #6f675f;
  --line: #e3dbd1;
  --accent: #1f6b4a;
  --accent-soft: #e7f2ec;
  --warn: #8a4b12;
  --warn-bg: #f8efe4;
  --info-bg: #eef3f1;
  --shadow: none;
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body {
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(243, 240, 234, 0.94);
  backdrop-filter: blur(8px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.date-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.date-line strong { font-size: 22px; font-weight: 650; letter-spacing: -0.03em; }
.icon-btn, .text-btn, .primary, .ghost, .danger {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 12px;
}
.icon-btn { width: 40px; padding: 0; display: grid; place-items: center; }
.primary { background: var(--accent); color: #f4fbf7; border-color: var(--accent); }
.primary:disabled, .ghost:disabled { opacity: 0.45; }
.ghost { background: transparent; }
.danger { color: var(--warn); }
.switch { display: flex; background: #e7e1d8; border-radius: 999px; padding: 3px; }
.switch button { border: 0; background: transparent; border-radius: 999px; min-height: 34px; padding: 0 14px; color: var(--muted); }
.switch button.on { background: var(--card); color: var(--ink); font-weight: 650; }

#view { width: min(560px, 100%); margin: 0 auto; padding: 14px 14px 24px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.card.split { border-color: #e2c39a; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.4; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
h2 { font-size: 18px; margin: 0; letter-spacing: -0.02em; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.quiet { background: #eeeae4; color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; }
.track { height: 8px; background: #ece6de; border-radius: 99px; overflow: hidden; }
.track span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.track.warn span { background: var(--warn); }

.note { border-radius: 14px; padding: 12px 14px; font-size: 14.5px; line-height: 1.45; }
.note.warning { background: var(--warn-bg); color: #6d3b0e; }
.note.info { background: var(--info-bg); }

.meal-head { width: 100%; text-align: left; background: none; border: 0; padding: 0; display: flex; justify-content: space-between; gap: 8px; }
.when { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.macros { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.cook { background: #f6f1e8; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cook h3 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.cook-line { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: baseline; }
.cook-line b { font-size: 22px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.cook-line span { font-size: 15px; }
.parts { grid-column: 2; color: var(--muted); font-size: 13px; }

.ing { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.ing .row { gap: 6px; }
.ing .name { font-size: 15px; }
.ing input[type="number"] {
  width: 76px; min-height: 40px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 8px; background: #fff; font-variant-numeric: tabular-nums; font-size: 16px;
}
.ai, .x {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center;
}
.steps { font-size: 14.5px; line-height: 1.45; margin: 8px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.wide { width: 100%; border-radius: 14px; min-height: 48px; }
.add { display: grid; grid-template-columns: 1fr 80px auto; gap: 8px; margin-top: 8px; }
.add select, .field input, .field textarea, .field select {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 8px 10px; font-size: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
textarea { min-height: 88px; resize: vertical; }

#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fffcf8; border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
#nav button { border: 0; background: transparent; color: var(--muted); min-height: 48px; border-radius: 12px; font-size: 13px; }
#nav button.on { color: var(--accent); font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px); opacity: 0; pointer-events: none;
  background: #1f1a17; color: #f6f3ee; border-radius: 14px; padding: 12px 14px;
  width: min(440px, calc(100% - 28px)); font-size: 14px; line-height: 1.4;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast button { margin-top: 8px; }

dialog { border: 0; border-radius: 18px; padding: 16px; width: min(480px, calc(100% - 24px)); background: var(--card); }
dialog::backdrop { background: rgba(31, 26, 23, 0.4); }
.chart { width: 100%; height: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week button { border: 1px solid var(--line); background: #fff; border-radius: 10px; min-height: 48px; padding: 4px; font-size: 12px; }
.week button.on { background: var(--accent); color: white; border-color: var(--accent); }
.check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--accent); display: inline-grid; place-items: center; }
.done .check { background: var(--accent); }
