:root {
  --bg: #e6e0d4;
  --paper: #fbf8f3;
  --ink: #1c1915;
  --muted: #6f675e;
  --line: #ddd4c6;
  --food: #9a3412;
  --food-bar: #ea580c;
  --move: #115e59;
  --move-bar: #0f766e;
  --danger: #9f1239;
  --done: #ccfbf1;
  --over: #ffe4e6;
  --shadow: 0 10px 30px rgba(28, 25, 21, 0.06);
  --glow: #f3e6d0;
  --input: #fff;
  --input-readonly: #f3efe7;
  --chip: #efe8dc;
  --banner: #fff7ed;
  --hint: #f4f0e8;
  --water: #0369a1;
  --water-bar: #38bdf8;
  --nav: rgba(251, 248, 243, 0.94);
  color-scheme: light;
  font-family: "Segoe UI", "Manrope", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

:root[data-theme="dark"] {
  --bg: #14110e;
  --paper: #221c17;
  --ink: #f6f1e8;
  --muted: #b7ab9d;
  --line: #3c332b;
  --food: #fdba74;
  --food-bar: #f97316;
  --move: #5eead4;
  --move-bar: #2dd4bf;
  --danger: #fb7185;
  --done: #134e4a;
  --over: #4c1d2a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --glow: #2a2118;
  --input: #1a1612;
  --input-readonly: #2a241e;
  --chip: #3a3128;
  --banner: #3a2a1c;
  --hint: #2c261f;
  --water: #7dd3fc;
  --water-bar: #38bdf8;
  --nav: rgba(20, 17, 14, 0.94);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 400px at 10% -10%, var(--glow), transparent 50%),
    var(--bg);
  color: var(--ink);
}

body.has-nav { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

a { color: var(--move); }

h1, h2, h3 { font-weight: 650; letter-spacing: -0.03em; margin: 0; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

p { margin: 0; }

.wrap {
  width: min(40rem, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.top {
  display: grid;
  grid-template-columns: 2.75rem 1fr 2.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.04em;
  font-size: 1.15rem;
}
.logo { width: 1.9rem; height: 1.9rem; display: block; flex: none; }
.menu-link {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
}
.menu-link svg { width: 1.45rem; height: 1.45rem; }
.menu-link.is-active { background: var(--chip); }

.dayhead {
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.dayhead h1 { text-align: center; }
.eyebrow {
  margin: 0;
  text-align: center;
  text-transform: capitalize;
  color: var(--muted);
  font-size: 0.85rem;
}

.iconbtn {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  font-size: 1.6rem;
  box-shadow: var(--shadow);
}

.center { text-align: center; margin: 0.25rem 0 1rem; }
.help { color: var(--muted); font-size: 0.92rem; }
.lede { color: var(--muted); margin: 0.25rem 0 1rem; }
.foot { margin: 1rem 0; }
.empty { color: var(--muted); padding: 0.5rem 0 1rem; }

.card, .row, .stat, .week-day {
  background: var(--paper);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card { padding: 1rem; margin: 0 0 1rem; }
.auth h1 { margin-bottom: 1rem; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.stat.protein, .stat.water { grid-column: 1 / -1; }
.stat.water {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.water-main { flex: 1; min-width: 0; }
.figure .unit { font-size: 1rem; font-weight: 650; }
.water-undo {
  margin-top: 0.35rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.water-undo:disabled { cursor: default; }
.cups {
  display: flex;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}
.cup-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  width: auto;
  height: auto;
  padding: 0.15rem 0.1rem 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--water);
  cursor: pointer;
}
.cup-button span {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  line-height: 1;
}
.cup-button[data-ml="200"] svg { width: 1.85rem; height: 2.45rem; }
.cup-button[data-ml="250"] svg { width: 2.25rem; height: 2.95rem; }
.cup-button[data-ml="300"] svg { width: 2.7rem; height: 3.5rem; }
.cup-button svg { display: block; }
.cup-fill { fill: var(--water-bar); }
.cup-button:active { transform: translateY(1px); }
.cup-button:disabled { opacity: 0.45; cursor: default; }

.stat { padding: 0.9rem; }
.stat.is-over { background: var(--over); }
.stat.is-done { background: var(--done); }
.figure {
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  margin: 0.15rem 0;
}
.delta { margin-top: 0.45rem; font-size: 0.92rem; }

.meter {
  height: 8px;
  border-radius: 99px;
  background: var(--chip);
  overflow: hidden;
  margin-top: 0.45rem;
}
.meter > span {
  display: block;
  height: 100%;
  background: var(--food-bar);
}
.meter.move > span { background: var(--move-bar); }
.meter.water > span { background: var(--water-bar); }
.meter.is-over > span { background: var(--danger); }
.meter.is-done > span { background: var(--move-bar); }

.block { margin-top: 1.4rem; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.row {
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.75rem;
}
.row p { color: var(--muted); font-size: 0.92rem; }
.kcal {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin: 0;
}
.kcal.food { color: var(--food); }
.macros { color: var(--muted); font-size: 0.88rem; margin: 0.15rem 0 0; }
.day-macros { margin-top: 0.8rem; }
.kcal.move { color: var(--move); }
.row-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.8rem;
  align-items: center;
}
.row-actions form { margin: 0; }
.row-actions button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--danger);
  font: inherit;
  cursor: pointer;
}
.session { display: block; }
.session h3 { font-size: 1.45rem; margin-bottom: 0.35rem; }
.session-songs {
  list-style: none;
  margin: 0;
  padding: 0;
}
.session-songs li,
.session-detail {
  margin: 0.12rem 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.session-songs li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.65rem;
}
.session-song-name { flex: 1; }
.session-song-time,
.session-song-kcal { white-space: nowrap; }
.total-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-right: 0.2rem;
}
.session-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0.75rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}
.session-total .kcal { font-size: 1.2rem; }

.week-summary { margin-bottom: 1rem; }
.week-summary h2 { margin-bottom: 0.7rem; }
.week-summary .help { margin: 0.55rem 0 0; }
.deficit {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.deficit h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.deficit .figure { font-size: 1.7rem; }
.deficit .unit { font-size: 1rem; font-weight: 650; }
.week { display: grid; gap: 0.55rem; }
.week-day {
  display: grid;
  grid-template-columns: 4.4rem 1fr;
  gap: 0.75rem;
  padding: 0.75rem;
  text-decoration: none;
  color: inherit;
}
.week-day.is-today { outline: 2px solid var(--ink); }
.week-label { display: grid; align-content: center; text-transform: capitalize; }
.week-label span { color: var(--muted); font-size: 0.8rem; }
.week-bars { display: grid; gap: 0.35rem; }
.week-bars p { color: var(--muted); font-size: 0.82rem; }
.goal-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.15rem 0 0;
}
.mark {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  flex: none;
}
.mark svg { width: 0.72rem; height: 0.72rem; display: block; }
.mark.is-done { background: var(--done); color: var(--move); }
.mark.is-miss { background: var(--over); color: var(--danger); }
.weight { color: var(--ink) !important; }

.weight-chart { margin: 0.6rem 0 0.9rem; }
.weight-chart svg {
  width: 100%;
  height: auto;
  display: block;
  color: var(--move);
  overflow: visible;
}
.weight-chart text {
  fill: var(--muted);
  font-size: 11px;
  font-family: inherit;
}
.weight-axis { stroke: var(--line); stroke-width: 1; }
.weight-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.weight-area { fill: currentColor; opacity: 0.16; }
.weight-dot { fill: var(--paper); stroke: currentColor; stroke-width: 2; }
.weight-summary { margin: 0.35rem 0 0; font-weight: 650; }
.weight-log-title { margin: 1rem 0 0.35rem; font-size: 0.95rem; }

.field { margin-bottom: 0.9rem; }
.field label, .field legend {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 650;
}
.field label.segment-item { display: flex; margin-bottom: 0; }
fieldset.field { border: 0; padding: 0; }

input:not([type="radio"]):not([type="checkbox"]):not([type="hidden"]):not([type="submit"]),
select {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--ink);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
input[readonly] { background: var(--input-readonly); }

.segment { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.segment-grid { display: grid; grid-template-columns: 1fr 1fr; }
.segment-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--input);
}
.segment-item input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  flex: none;
}
.segment-item span { line-height: 1; }
.segment-item:has(input:checked) {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.song-pack {
  margin: 0.55rem 0 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--input);
}
.song-pack summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.2rem 0.35rem 0.2rem 0.8rem;
  cursor: pointer;
  list-style: none;
}
.song-pack summary::-webkit-details-marker { display: none; }
.pack-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
}
.pack-title::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-top: -0.15rem;
}
.song-pack[open] .pack-title::before { transform: rotate(45deg); margin-top: 0; }
.pack-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
}
.pack-count[hidden] { display: none; }
.song-list { display: grid; gap: 0.35rem; padding: 0 0.55rem 0.7rem; }
.song-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.7rem;
  min-height: 44px;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.song-item:has(input[type="checkbox"]:checked) {
  border-color: var(--ink);
  background: var(--chip);
}
.song-check {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1 1 12rem;
  min-height: 44px;
}
.song-check input { width: 1.15rem; height: 1.15rem; margin: 0; flex: none; }
.song-item .segment-item { height: 36px; min-height: 36px; padding: 0 0.65rem; }
.text-button {
  min-height: 36px;
  padding: 0 0.7rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--move);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1rem;
  border-radius: 999px;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.button:disabled { opacity: 0.6; cursor: default; }
.share-row { margin: 0 0 1rem; }
.share-row .button { width: 100%; }
form .button { width: 100%; margin-top: 0.4rem; }
.section-head .button { width: auto; margin: 0; }

.banner, .messages li {
  background: var(--banner);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.8rem;
}
.messages { list-style: none; padding: 0; }
.error { color: var(--danger); margin-top: 0.25rem; }
.hint {
  background: var(--hint);
  border-radius: 12px;
  padding: 0.8rem;
  margin-bottom: 0.8rem;
}
.plain { padding-left: 1.1rem; color: var(--muted); }
.plain li { margin: 0.25rem 0; }

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.25rem;
  padding: 0.4rem 0.6rem calc(0.45rem + env(safe-area-inset-bottom));
  background: var(--nav);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 2;
}
.nav a {
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.55rem 0.1rem;
  border-radius: 12px;
}
.nav a.is-active { color: var(--ink); background: var(--chip); }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.tabs a {
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
  padding: 0.55rem 0.4rem;
  border-radius: 12px;
  background: var(--chip);
}
.tabs a.is-active { color: var(--paper); background: var(--ink); }

.field label.check,
.check {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  margin-bottom: 0.3rem;
  font-weight: 650;
}
.check input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  flex: none;
}

@media (min-width: 800px) {
  body.has-nav { padding-bottom: 0; }
  .nav {
    position: static;
    margin: 0 0 1rem;
    padding: 0.2rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
  }
}

.recipe-row {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}
.recipe-row .linkish {
  justify-self: start;
  background: none;
  border: 0;
  padding: 0;
  color: var(--danger);
  font: inherit;
  cursor: pointer;
}
.recipe-summary { display: grid; gap: 0.35rem; }
.recipe-summary strong { font-size: 1.05rem; }

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
  .figure { font-size: 2rem; }
}

@media (max-width: 380px) {
  .segment-grid { grid-template-columns: 1fr; }
}

@media (min-width: 800px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat.protein { grid-column: auto; }
  .stat.water { grid-column: 1 / -1; }
  .segment-grid { display: flex; flex-wrap: wrap; }
}
