/* Today: the blue model of the suite (../design/base.css holds the chassis: tokens, type
   widths, keys, the transport bar). Its signature is the sky line: the day is the layout,
   and each stretch of the line is the colour of the sky at that hour, from real sunrise and
   sunset (js/sky.js). "Now" is the one hard orange line. Water and protein are segmented
   level meters on the transport bar; the orange key logs a meal. */

:root {
  --water: #236bb8;
  --food: #8f5f12;
  --water-on-body: #8fc3f2;   /* the same, where it sits on the blue body */
  --food-on-body: #f0b558;
  --gutter: 16px;
  --dock-h: 150px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --water: #5aa2ec; --food: #d9a14a; }
}
:root[data-theme="dark"] { --water: #5aa2ec; --food: #d9a14a; }

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ground); color: var(--ink);
  font-family: var(--font); font-stretch: var(--w-body);
  font-size: 16px; line-height: 1.4;
  font-variant-numeric: tabular-nums;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--hotline); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* The band runs up under the status bar of an installed app. */
.top-band { position: sticky; top: 0; z-index: 4; }

.page {
  max-width: 520px; margin: 0 auto;
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) calc(var(--dock-h) + 40px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.plate { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 28px; }
.plate .ui-label { font-size: 12px; }
.status { font-size: 13px; color: var(--ink-soft); text-align: right; }

.day { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 10px; }
.day h1 { font-size: 40px; }
.date { font-size: 15px; color: var(--ink-soft); }
.all-day { margin-top: 8px; color: var(--ink-soft); font-size: 15px; }
.all-day b { color: var(--ink); font-weight: 600; }
.problems { margin-top: 12px; display: grid; gap: 6px; }
.problem {
  font-size: 13.5px; color: var(--ink-soft);
  padding: 8px 10px; border-radius: var(--r-key);
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--danger);
  overflow-wrap: anywhere;
}
.problem b { color: var(--ink); font-weight: 650; }

/* -- the sky line ------------------------------------------------------------------- */

.dayline { list-style: none; padding: 0; margin-top: 22px; }
.row { display: grid; grid-template-columns: 54px 8px minmax(0, 1fr); column-gap: 14px; }
.t {
  text-align: right; padding-top: 1px; white-space: nowrap;
  font-stretch: var(--w-readout); font-weight: 650; font-size: 17px; color: var(--ink-soft);
}
.t small { font-size: 11px; font-weight: 600; margin-left: 1px; font-stretch: var(--w-body); }
.spine { position: relative; }
.body { padding-bottom: var(--gap, 18px); min-width: 0; }
.what { font-weight: 600; font-size: 16.5px; line-height: 1.25; overflow-wrap: anywhere; }
.sub { font-size: 14px; color: var(--ink-soft); margin-top: 2px; overflow-wrap: anywhere; }
.past .what { color: var(--ink-soft); }
.quiet .what { font-weight: 450; color: var(--ink-soft); font-size: 15px; }
.water-mark { color: var(--water); }
.food-mark { color: var(--food); }
.stats { display: flex; gap: 18px; margin-top: 4px; flex-wrap: wrap; }
.stats span { font-size: 13.5px; color: var(--ink-soft); }
.stats b { font-stretch: var(--w-readout); font-size: 21px; font-weight: 800; color: var(--ink); margin-right: 3px; }
.stages { display: flex; gap: 2px; height: 6px; margin-top: 8px; max-width: 260px; }
.stages i { display: block; height: 100%; }
.stage-key { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 5px; font-size: 12.5px; color: var(--ink-soft); }
.stage-key span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; background: var(--c); }
.row-link { display: inline-block; margin-top: 6px; font-size: 14px; font-weight: 650; color: var(--ink); text-decoration-color: var(--hotline); text-underline-offset: 3px; }

/* Now: a hard orange line across the spine and the row, under a readout clock. */
.now .spine::after { content: ""; position: absolute; left: -5px; right: -5px; top: 21px; height: 4px; background: var(--hotline); }
.now .body { position: relative; }
.now .body::before { content: ""; position: absolute; left: -14px; right: 0; top: 21px; height: 4px; background: var(--hotline); }
.clock { position: relative; display: inline-block; background: var(--ground); margin-left: 6px; padding: 0 8px 0 6px; font-size: 52px; }
.clock small { font-size: 17px; font-weight: 700; margin-left: 3px; letter-spacing: 0; }
.next { margin-top: 8px; font-size: 16.5px; font-weight: 520; }
.next b { font-weight: 700; }

/* -- reminders -------------------------------------------------------------------------- */

.anytime { margin-top: 22px; }
.anytime h2 { color: var(--ink-soft); }
.todo { list-style: none; padding: 0; margin-top: 8px; }
.todo li {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 8px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--rule);
}
.todo li:last-child { border-bottom: 1px solid var(--rule); }
.todo .done-btn { width: 44px; height: 44px; margin: -11px 0 -11px -11px; display: grid; place-items: center; }
.todo .name { font-size: 16px; font-weight: 520; overflow-wrap: anywhere; }
.todo .late { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.todo .high .name { font-weight: 680; }
.todo .high .late { color: var(--hotline-text); font-weight: 650; }
.todo li.leaving { opacity: 0.4; }

/* -- the transport bar: meters and keys ---------------------------------------------------- */

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  --water: var(--water-on-body); --food: var(--food-on-body);
}
.dock-in { max-width: 520px; margin: 0 auto; display: grid; gap: 12px; }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 5px; }
.meter-top .ui-label { color: var(--on-body-soft); }
.meter b { font-stretch: var(--w-readout); font-size: 19px; font-weight: 800; color: var(--on-body); }
.meter .of { font-size: 12px; color: var(--on-body-soft); }
/* Inline style attributes are blocked by the CSP, so the meter colours live here. */
#water-segs { --seg: var(--water); }
#protein-segs { --seg: var(--food); }
.keys { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.keys .ui-key { height: 46px; }

.toast {
  position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--ground);
  font-size: 14px; font-weight: 600;
  padding: 9px 14px; border-radius: var(--r-key);
  box-shadow: var(--shadow);
}
.toast-undo { color: var(--hotline); font-weight: 750; padding: 4px 2px; }

/* -- the meal sheet ------------------------------------------------------------------------ */

.sheet { position: fixed; inset: 0; z-index: 20; display: grid; align-items: end; }
.scrim { position: absolute; inset: 0; background: var(--scrim); }
.sheet-panel {
  position: relative; width: 100%; max-width: 520px; margin: 0 auto;
  background: var(--ground); border-radius: var(--r-sheet) var(--r-sheet) 0 0; overflow: hidden;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  display: grid; gap: 14px;
}
.sheet-panel > .ui-band { height: 6px; margin: 0 calc(-1 * max(var(--gutter), env(safe-area-inset-right))) 0 calc(-1 * max(var(--gutter), env(safe-area-inset-left))); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font-size: 12px; }
.close { width: 44px; height: 44px; margin-right: -10px; display: grid; place-items: center; color: var(--ink-soft); }
.field { display: grid; gap: 6px; border: 0; padding: 0; min-width: 0; }
.field-name { font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 0; }
.field input[type="text"], .field input[type="number"] {
  width: 100%; min-height: 46px; padding: 8px 12px;
  font: inherit; font-size: 17px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-key);
}
.field input[type="number"] { font-stretch: var(--w-readout); font-weight: 700; font-size: 20px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 3px; background: var(--fill); border-radius: var(--r-key); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 8px 2px; font-size: 14px; font-weight: 600; color: var(--ink-soft); border-radius: 3px; cursor: pointer; }
.segmented input:checked + span { background: var(--ink); color: var(--ground); }
.segmented input:focus-visible + span { outline: 2px solid var(--hotline); outline-offset: 1px; }
.form-error { color: var(--danger); font-size: 14px; }
.submit { width: 100%; height: 50px; font-size: 12px; }

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

.signin { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--ground); padding: var(--gutter); }
.signin-card { text-align: center; display: grid; justify-items: center; gap: 8px; }
.signin-card img { border-radius: 22%; }
.signin-card h1 { font-size: 40px; margin-top: 10px; }
.signin-card p { color: var(--ink-soft); margin-bottom: 16px; }

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