/* Shared look with caboose-ai.io: GitHub-dark palette, light-mode variant. */
:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #f0883e;
  --green: #3fb950;
  --red: #f85149;
  --link: #58a6ff;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --panel: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #656d76;
    --accent: #bc4c00;
    --green: #1a7f37;
    --red: #cf222e;
    --link: #0969da;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  padding: 1.5rem 1rem 3rem;
}
body.centered { display: flex; flex-direction: column; align-items: center; justify-content: center; }
main { max-width: 46rem; margin: 0 auto; width: 100%; }
header {
  max-width: 46rem;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
h1 { font-size: 1.6rem; }
h1 .dot, .accent { color: var(--accent); }
h2 { font-size: 1.05rem; margin-bottom: .5rem; }
p { margin-bottom: .8rem; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); font-size: .92rem; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.3rem;
  margin-bottom: .8rem;
}
.banner { border-radius: 8px; padding: .6rem .9rem; margin-bottom: .9rem; }
.banner.error { color: var(--red); border: 1px solid var(--red); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .7rem;
  font: inherit;
  margin-bottom: .9rem;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: 8px;
  padding: .55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.link {
  background: none;
  color: var(--muted);
  font-weight: 400;
  padding: 0;
  font-size: .9rem;
}
button.link:hover { color: var(--text); text-decoration: underline; }
footer {
  max-width: 46rem;
  margin: 2rem auto 0;
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  color: var(--muted);
  font-size: .78rem;
}
.ver { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------------------------------------------------------------------- */
/* App shell: bottom tab bar, phone-first spacing, 44px tap targets.       */
/* ---------------------------------------------------------------------- */

body { padding-bottom: 4.75rem; }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 10;
}
.tabs a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .5rem 0 .45rem;
  min-height: 44px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a[aria-current="page"] { color: var(--accent); }
.tab-ic { font-size: 1.25rem; line-height: 1; }

.day-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1rem;
}
.day-head h1 { flex: 1; }

h2 { margin-top: 1.4rem; }
section + section, section + p, p + section { margin-top: .2rem; }

/* Pills: status labels, not decoration. */
.pill {
  display: inline-block;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .72rem;
  font-weight: 600;
}
.pill-warn { border-color: var(--red); color: var(--red); }

/* --------------------------- Meters -------------------------------------
   Pct arrives from Go as a plain 0-100 int; CSS does the drawing. */

.meters { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; }
.meter-protein { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.meter-water { flex: 1; min-width: 10rem; }

.ring {
  --pct: 0;
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring-hole {
  width: 5.6rem;
  height: 5.6rem;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.ring-hole strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.ring-hole .muted { font-size: .72rem; }

.bar {
  --pct: 0;
  height: 1.1rem;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: calc(var(--pct) * 1%);
  background: var(--link);
  border-radius: 999px;
  transition: width .3s ease;
}
.meter-caption { font-size: .85rem; color: var(--muted); margin-top: .4rem; margin-bottom: 0; text-align: center; }
.meter-water .meter-caption { text-align: left; }

/* ------------------------ Quick-add tiles -------------------------------
   One tap logs. Grid of equal tiles, 44px+ tall, thumb-sized. */

.quick-grid, .vessel-row, .photo-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr));
  gap: .6rem;
  margin: 1rem 0;
}
.tile-form { margin: 0; }
.water-custom {
  display: flex; align-items: flex-end; gap: .5rem; margin: -.4rem 0 1rem;
}
.water-custom label { margin: 0; }
.water-custom input { width: auto; flex: 1; }
.water-custom button { width: auto; flex-shrink: 0; }
.tile {
  width: 100%;
  height: 100%;
  min-height: 5.2rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .6rem .4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  font-weight: 600;
  cursor: pointer;
}
.tile:hover, .tile:active { border-color: var(--accent); }
.tile-emoji { font-size: 1.6rem; line-height: 1; }
.tile-name { font-size: .82rem; text-align: center; line-height: 1.2; }
.tile-grams { font-size: .74rem; color: var(--muted); font-weight: 500; }
.tile-vessel:hover, .tile-vessel:active { border-color: var(--link); }
a.tile.tile-more {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); border-style: dashed;
}
.tile-photo { cursor: pointer; }
.photo-form { margin: 0; }
/* htmx already ships this pair (includeIndicatorStyles, on by default), but
   it's declared here too so a request's "Reading the photo..." line stays
   hidden if that default ever gets turned off. */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { opacity: 1; }

/* ---------------------------- Plans -------------------------------------
   Absurd option is always visible; the real plans are one tap away. */

.absurd-card {
  background: var(--panel);
  border: 1px solid var(--red);
  border-radius: 12px;
  padding: .9rem 1rem;
  margin-bottom: .8rem;
}
.absurd-line { font-weight: 600; margin: .5rem 0 .3rem; }

details.plan-list, details.log-row, details.add-food {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: .6rem;
  overflow: hidden;
}
details.plan-list summary, details.log-row summary, details.add-food summary {
  cursor: pointer;
  list-style: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  font-weight: 600;
}
details.plan-list summary::marker,
details.log-row summary::marker,
details.add-food summary::marker { display: none; }
details.plan-list summary::-webkit-details-marker,
details.log-row summary::-webkit-details-marker,
details.add-food summary::-webkit-details-marker { display: none; }
details.plan-list summary::after { content: "\25be"; margin-left: auto; color: var(--muted); }
details[open].plan-list summary::after,
details[open].log-row summary::after,
details[open].add-food summary::after { content: "\25b4"; }
details.log-row summary::after { margin-left: auto; }

.plan-card { padding: 0 1rem 1rem; }
.plan-card:not(:last-child) { border-bottom: 1px solid var(--border); padding-bottom: 1rem; margin-bottom: .2rem; }
.plan-card h3 { font-size: 1rem; margin-bottom: .2rem; }
.quip { margin-bottom: .5rem; }
.chunk-list { padding-left: 1.2rem; }
.chunk-list li { margin-bottom: .35rem; }
.chunk-time { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: .3rem; }
.water-plan-line { padding: 0 1rem .8rem; margin: 0; }
.water-plan-line:first-of-type { padding-top: .2rem; }
.done-line { font-weight: 600; }

.scan-cta { text-align: center; margin: 1.2rem 0; }

/* ------------------------------ Log --------------------------------------
   Inline edit via <details>; stale-checked delete carries RawGrams/ML. */

.log-row summary {
  display: flex;
  gap: .6rem;
}
.log-row .log-time { color: var(--muted); font-variant-numeric: tabular-nums; width: 4.5rem; flex-shrink: 0; }
.log-row .log-name { flex: 1; font-weight: 600; }
.log-row .log-grams { font-variant-numeric: tabular-nums; }
.log-row.log-row-water, .log-row.log-row-archived {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: .6rem;
}
.log-row.log-row-water .log-time { color: var(--muted); width: 4.5rem; }
.log-row.log-row-water .log-name,
.log-row.log-row-archived .log-name { flex: 1; font-weight: 600; }
.log-row.log-row-water form,
.log-row.log-row-archived form,
.food-list .log-row .log-detail form { margin: 0; }
.log-detail { padding: 0 1rem 1rem; }
.edit-form { display: flex; flex-wrap: wrap; gap: .5rem .6rem; align-items: end; margin-bottom: .6rem; }
.edit-form label { width: 100%; margin-bottom: 0; }
.edit-form input { width: auto; flex: 1; min-width: 8rem; margin-bottom: 0; }
.edit-form button { flex-shrink: 0; }

.stack-form { display: flex; flex-direction: column; gap: 0; }
.stack-form label:not(:first-child) { margin-top: 0; }

button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); font-weight: 600; }
button.danger:hover { background: var(--red); color: #fff; filter: none; }

.check-label { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: .95rem; margin-bottom: .9rem; }
.check-label input { width: auto; min-height: 22px; min-width: 22px; margin: 0; }

.window-fields { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; }
.window-fields input { flex: 1; min-width: 7rem; }

.day-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.4rem 0 .5rem;
  font-size: .9rem;
}

/* Foods page */
.food-list { margin-bottom: .5rem; }

/* Settings */
.vessel-settings { margin-top: 1.5rem; }
.vessel-settings .log-row { margin-bottom: .6rem; }
.install-hint { margin-top: 1.5rem; text-align: center; }

/* Scan */
.scanner-box {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 16rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.scanner-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.manual-upc {
  display: flex;
  gap: .6rem;
  align-items: end;
  margin-bottom: 1rem;
}
.manual-upc label { flex-basis: 100%; }
.manual-upc input { flex: 1; margin-bottom: 0; }
.manual-upc button { flex-shrink: 0; }
[hidden] { display: none !important; }

.confirm { margin-top: 1rem; }
.confirm-meta { margin-bottom: .6rem; }
.confirm-items { padding-left: 1.2rem; margin-bottom: .8rem; }
.confirm-items li { margin-bottom: .3rem; }

@media (min-width: 40rem) {
  .tabs { position: static; border-top: none; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
  body { padding-bottom: 3rem; }
}

/* Coming-soon placeholder */
.card.soon { text-align: center; padding: 2.5rem 1.5rem; }
.card.soon h1 { margin-bottom: .4rem; }
.soon-tag {
  display: inline-block;
  margin-top: .8rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: .15rem .8rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
