/* ------------------------------------------------------------------
   Kitchen Ledger
   Palette taken from the subject's own world: pressure-cooker steel,
   spruce, and the amber of a tray of vegetables coming out charred.
   Display face is Georgia, chosen for its oldstyle figures — this is
   an app made almost entirely of numbers, and Georgia's numerals sit
   on the baseline like text rather than shouting like data.
------------------------------------------------------------------- */

:root {
  --ink:      #12211C;
  --ink-soft: #4A5A53;
  --paper:    #F1F4F1;
  --card:     #FFFFFF;
  --spruce:   #1E4D3E;
  --spruce-d: #14382C;
  --sage:     #7E9A8D;
  --amber:    #B26A15;
  --line:     #DBE3DE;

  --display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --r: 10px;
  --pad: clamp(16px, 4vw, 24px);
  --shadow: 0 1px 2px rgba(18, 33, 28, .06), 0 6px 20px rgba(18, 33, 28, .05);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(15px, 1.6vw, 16.5px);
  line-height: 1.45;
  font-feature-settings: "kern" 1, "liga" 1;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.2; hyphens: none; }
h2 { font-size: 1.4rem; margin: 0 0 .1em; }
h3 { font-size: 1.08rem; margin: 0 0 .2em; }
p { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }

.eyebrow {
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sage);
  font-weight: 600;
  margin: 0;
}

button { font: inherit; cursor: pointer; }

:focus-visible { outline: 2px solid var(--spruce); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------ sign in */

.signin {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background:
    radial-gradient(120% 90% at 50% 0%, #26604D 0%, var(--spruce-d) 55%, #0D2820 100%);
}
.signin__card {
  width: min(380px, 100%);
  background: var(--card);
  border-radius: 14px;
  padding: clamp(24px, 6vw, 34px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.signin__title {
  font-size: clamp(1.7rem, 6vw, 2.1rem);
  margin: .25em 0 1em;
  letter-spacing: -.01em;
}
.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field input, .num {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #FBFCFB;
  font: inherit;
  color: var(--ink);
}
.field input:focus, .num:focus { border-color: var(--spruce); background: #fff; }

.btn {
  border: 0;
  border-radius: var(--r);
  padding: 12px 18px;
  font-weight: 600;
  font-size: .95rem;
}
.btn--primary { background: var(--spruce); color: #fff; width: 100%; }
.btn--primary:hover { background: var(--spruce-d); }
.btn--ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn--sm { padding: 8px 13px; font-size: .85rem; }

.linkbtn {
  background: none; border: 0; padding: 0;
  color: var(--sage); font-size: .78rem; font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px;
}
.err { color: #A5342C; font-size: .85rem; margin: 12px 0 0; }

/* --------------------------------------------------------- top ledger */

.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--spruce);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad) 14px;
}
.top__row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.top .eyebrow { color: rgba(255, 255, 255, .62); }
.top .linkbtn { color: rgba(255, 255, 255, .72); }

/* The signature element: two ledger rules that fill as meals are ticked,
   with a hard notch at the target. Not a donut, not a progress bar —
   a line you are trying to reach. */
.ledger { display: grid; gap: 11px; }
.ledger__row { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; align-items: baseline; }
.ledger__label {
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255, 255, 255, .6); font-weight: 600;
}
.ledger__val {
  font-family: var(--display);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.ledger__val small { color: rgba(255, 255, 255, .55); font-size: .78em; }
.ledger__track {
  grid-column: 1 / -1;
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, .16);
  border-radius: 3px;
  overflow: visible;
}
.ledger__fill {
  position: absolute; inset: 0 auto 0 0;
  border-radius: 3px;
  background: #A8D5BF;
  transition: width .45s cubic-bezier(.22, 1, .36, 1);
}
.ledger__fill.is-over { background: var(--amber); }
.ledger__notch {
  position: absolute; top: -3px; bottom: -3px;
  width: 2px; background: #fff; border-radius: 1px;
}

/* --------------------------------------------------------------- view */

.view {
  padding: var(--pad);
  padding-bottom: 96px;
  max-width: 720px;
  margin: 0 auto;
}
.view:focus { outline: none; }

.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }

.section-title { margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }
.muted { color: var(--ink-soft); font-size: .88rem; }
.tiny { font-size: .78rem; color: var(--sage); }

/* -------------------------------------------------------- date strip */

.datebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.datebar h2 { font-size: 1.25rem; }
.datebar .muted { margin: 0; }
.arrow {
  background: var(--card); border: 1px solid var(--line);
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 1.1rem; line-height: 1; color: var(--ink);
  display: grid; place-items: center;
}
.arrow:disabled { opacity: .35; cursor: default; }

/* ------------------------------------------------------------- meals */

.meal {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.meal:last-child { border-bottom: 0; padding-bottom: 0; }
.meal:first-child { padding-top: 0; }

.tick {
  width: 26px; height: 26px; margin-top: 1px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: #fff;
  display: grid; place-items: center;
  color: transparent;
  font-size: .8rem;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.tick:hover { border-color: var(--sage); }
.tick[aria-pressed="true"] {
  background: var(--spruce); border-color: var(--spruce); color: #fff;
  transform: scale(1.04);
}
.meal__time {
  font-family: var(--display); font-size: .8rem; color: var(--sage);
  font-variant-numeric: tabular-nums;
}
.meal__title { font-weight: 600; margin: 1px 0 2px; }
.meal.is-done .meal__title { color: var(--ink-soft); }
.meal__macros {
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  font-size: .9rem;
  text-align: right;
  white-space: nowrap;
}
.meal__macros b { display: block; font-weight: 700; }
.meal__macros span { color: var(--sage); font-size: .82em; }
.meal__note { font-size: .82rem; color: var(--ink-soft); margin: 4px 0 0; }
.meal__ing { margin: 6px 0 0; font-size: .82rem; color: var(--ink-soft); }
.meal__ing summary { cursor: pointer; color: var(--sage); font-weight: 600; }
.meal__ing ul { margin: 6px 0 0; padding-left: 18px; }
.meal__ing li { margin-bottom: 2px; }

/* ------------------------------------------------------------ extras */

.extra { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.extra:last-of-type { border-bottom: 0; }
.extra__x { background: none; border: 0; color: var(--sage); font-size: 1.1rem; padding: 0 4px; }
.row3 { display: grid; grid-template-columns: 1fr 76px 76px auto; gap: 8px; align-items: end; margin-top: 10px; }
.row2 { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 460px) { .row3 { grid-template-columns: 1fr 1fr; } .row3 > :last-child { grid-column: 1 / -1; } }

/* -------------------------------------------------------------- week */

.weekday { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.weekday__name { font-family: var(--display); font-size: 1.05rem; font-weight: 700; }
.weekday__sum { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--ink-soft); }
.weekmeal { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; padding: 4px 0; color: var(--ink-soft); }
.weekmeal span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--sage); }
.is-today { box-shadow: var(--shadow), inset 3px 0 0 var(--spruce); }

/* ----------------------------------------------------------- recipes */

.tag {
  display: inline-block; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 700; color: var(--spruce); background: #E4EFE9;
  padding: 3px 8px; border-radius: 20px;
}
.recipe ol, .recipe ul { padding-left: 20px; margin: 8px 0; }
.recipe li { margin-bottom: 6px; }
.warn {
  border-left: 3px solid var(--amber);
  background: #FDF6EC;
  padding: 10px 12px;
  border-radius: 0 var(--r) var(--r) 0;
  font-size: .86rem;
  margin-top: 10px;
}

/* -------------------------------------------------------------- shop */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 20px; padding: 6px 12px; font-size: .82rem; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--spruce); border-color: var(--spruce); color: #fff; }
.shopitem {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
  font-size: .92rem;
}
.shopitem:last-child { border-bottom: 0; }
.shopitem b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.shopitem.is-got { color: var(--sage); text-decoration: line-through; }

/* ---------------------------------------------------------- progress */

.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat__box { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.stat__num {
  font-family: var(--display); font-size: 1.7rem; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat__num small { font-size: .5em; color: var(--sage); font-weight: 400; }
.chart { width: 100%; height: auto; display: block; }
.chart line.grid { stroke: var(--line); stroke-width: 1; }
.chart .goal { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .raw { fill: var(--line); }
.chart .avg { fill: none; stroke: var(--spruce); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart text { font-family: var(--body); font-size: 10px; fill: var(--sage); }
.bars rect { fill: var(--sage); }
.bars rect.full { fill: var(--spruce); }

/* -------------------------------------------------------------- tabs */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  background: none; border: 0;
  padding: 12px 4px;
  font-size: .74rem; font-weight: 600; letter-spacing: .02em;
  color: var(--sage);
  border-top: 2px solid transparent;
  margin-top: -1px;
}
.tab[aria-selected="true"] { color: var(--spruce); border-top-color: var(--spruce); }

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 20px;
  font-size: .86rem; z-index: 40;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}

.empty { text-align: center; color: var(--ink-soft); padding: 30px 10px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
