@font-face {
  font-family: "Nunito";
  src: url("../fonts/nunito.woff") format("woff");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6efe6;
  --bg-elev: #fffbf6;
  --bg-tint: #efe4d6;
  --ink: #2a2118;
  --ink-soft: #6b5e52;
  --ink-faint: #9a8c80;
  --line: #e8dcce;
  --accent: #c05621;
  --accent-hover: #a34718;
  --accent-text: #fff8f3;
  --accent-soft: #f6d9c6;
  --sage: #2f6a54;
  --sage-soft: #d7e8de;
  --info: #3d6a8a;
  --info-soft: #d7e3ec;
  --warn: #8a4b16;
  --danger: #8b3030;
  --danger-soft: #f3d6d4;
  --band-firm: #b56a2a;
  --band-ok: #3e8a68;
  --band-loose: #4a7ea0;
  --tab-bg: rgba(255, 251, 246, 0.92);
  --shadow: 0 10px 30px rgba(42, 33, 24, 0.08);
  --shadow-sheet: 0 -8px 32px rgba(42, 33, 24, 0.16);
  --swatch-line: rgba(42, 33, 24, 0.2);
  --dairy-bg: #b9d4ef;
  --dairy-line: #4d72a0;
  --dairy-num: #1558c0;
  --dairy-today-bg: #1558c0;
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Nunito", ui-rounded, "Hiragino Maru Gothic ProN", "Avenir Next", system-ui, sans-serif;
  --header-h: 3.5rem;
  --tab-h: 4rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Netlify Free plan injects a 192x64 "Powered by Netlify" badge in the
     bottom-right. The setting is locked on this plan, so we reserve space. */
  --netlify-badge-clearance: 4.5rem;
  color-scheme: light dark;
}

html[data-resolved-theme="light"] {
  color-scheme: light;
}
html[data-resolved-theme="dark"] {
  color-scheme: dark;
  --bg: #16120e;
    --bg-elev: #221c16;
    --bg-tint: #2c241c;
    --ink: #f4ede4;
    --ink-soft: #c2b4a6;
    --ink-faint: #8f8276;
    --line: #3a3128;
    --accent: #e08a54;
    --accent-hover: #f0a06e;
    --accent-text: #1a120c;
    --accent-soft: #3c2618;
    --sage: #7dba9c;
    --sage-soft: #1d3329;
    --info: #8eb4cc;
    --info-soft: #1c2a33;
    --warn: #e0b07a;
    --danger: #e07a7a;
    --danger-soft: #3a1c1c;
    --band-firm: #e0924c;
    --band-ok: #7dba9c;
    --band-loose: #8eb4cc;
    --tab-bg: rgba(34, 28, 22, 0.94);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.45);
    --swatch-line: rgba(244, 237, 228, 0.28);
    --dairy-bg: #2c4664;
    --dairy-line: #8eb4cc;
    --dairy-num: #6ec1ff;
    --dairy-today-bg: #2d7fd4;
}
@media (prefers-color-scheme: dark) {
  html:not([data-resolved-theme="light"]) {
    color-scheme: dark;
  --bg: #16120e;
    --bg-elev: #221c16;
    --bg-tint: #2c241c;
    --ink: #f4ede4;
    --ink-soft: #c2b4a6;
    --ink-faint: #8f8276;
    --line: #3a3128;
    --accent: #e08a54;
    --accent-hover: #f0a06e;
    --accent-text: #1a120c;
    --accent-soft: #3c2618;
    --sage: #7dba9c;
    --sage-soft: #1d3329;
    --info: #8eb4cc;
    --info-soft: #1c2a33;
    --warn: #e0b07a;
    --danger: #e07a7a;
    --danger-soft: #3a1c1c;
    --band-firm: #e0924c;
    --band-ok: #7dba9c;
    --band-loose: #8eb4cc;
    --tab-bg: rgba(34, 28, 22, 0.94);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.45);
    --swatch-line: rgba(244, 237, 228, 0.28);
    --dairy-bg: #2c4664;
    --dairy-line: #8eb4cc;
    --dairy-num: #6ec1ff;
    --dairy-today-bg: #2d7fd4;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
}

body {
  min-height: 100dvh;
  overscroll-behavior: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 40rem;
  margin: 0 auto;
  position: relative;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 0.7rem) 1.25rem 0.75rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.7rem;
  flex: none;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-text p {
  margin: 0.05rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 600;
}

#view {
  flex: 1;
  padding: 0.25rem 1.25rem calc(var(--tab-h) + var(--safe-bottom) + var(--netlify-badge-clearance) + 1.25rem);
}

.tab-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--netlify-badge-clearance);
  width: 100%;
  max-width: 40rem;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.1rem;
  padding: 0.35rem 0.5rem calc(var(--safe-bottom) + 0.35rem);
  background: var(--tab-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 3.15rem;
  border-radius: 0.9rem;
  color: var(--ink-faint);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tab-btn svg {
  width: 1.4rem;
  height: 1.4rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-btn[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Cards & type */
.hero {
  margin: 0.4rem 0 1.1rem;
}

.kicker {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero h2 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.hero p {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-weight: 600;
}

.log-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 3.7rem;
  padding: 0.85rem 1.1rem;
  border-radius: 1.15rem;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.log-btn:active {
  transform: scale(0.98);
  filter: brightness(0.97);
}

.log-btn .emoji {
  font-size: 1.35rem;
  line-height: 1;
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.6rem;
  margin: 1rem 0 1.25rem;
}

.mini-stat,
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.mini-stat {
  padding: 0.75rem 0.6rem 0.7rem;
  text-align: center;
  min-width: 0;
}

.mini-stat .value {
  display: block;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-stat .label {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.35rem 0 0.65rem;
}

.section-title h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--ink-soft);
  font-weight: 600;
}

.faint {
  color: var(--ink-faint);
}

.empty {
  padding: 1.1rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.empty p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.entry-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem 0.95rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: start;
}


.entry-card .type-badges {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  flex: none;
}
.entry-card .type-badges.multi .type-badge {
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 0.7rem;
}
.entry-card .type-badges.multi .type-badge svg {
  width: 1.15rem;
  height: 1.15rem;
}

.entry-card .type-badge {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.8rem;
  display: grid;
  place-items: center;
  background: var(--bg-tint);
  color: var(--ink);
  flex: none;
}
.entry-card .type-badge.t-ok {
  background: var(--sage-soft);
  color: var(--sage);
}
.entry-card .type-badge.t-firm {
  background: #f3e1cc;
  color: #8a4b16;
}
.entry-card .type-badge.t-loose {
  background: var(--info-soft);
  color: var(--info);
}
html[data-resolved-theme="dark"] .entry-card .type-badge.t-firm {
  background: #3a2a18;
  color: #e0b07a;
}
@media (prefers-color-scheme: dark) {
  html:not([data-resolved-theme="light"]) .entry-card .type-badge.t-firm {
    background: #3a2a18;
    color: #e0b07a;
  }
}

.entry-card .type-badge svg {
  width: 1.45rem;
  height: 1.45rem;
}

.entry-body {
  min-width: 0;
}

.entry-body .time {
  font-weight: 800;
  font-size: 0.95rem;
}

.entry-body .type-name {
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.entry-body .notes {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-tint);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.chip.blood {
  background: var(--danger-soft);
  color: var(--danger);
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 750;
  vertical-align: middle;
}

.color-chip .swatch,
.color-opt .swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  flex: none;
  border: 1px solid var(--swatch-line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.color-line {
  margin-top: 0.15rem;
}
.color-line .color-chip {
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.stat-card .value .color-chip {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.entry-actions {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.icon-btn {
  width: 2.15rem;
  height: 2.15rem;
  display: grid;
  place-items: center;
  border-radius: 0.7rem;
  color: var(--ink-soft);
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--bg-tint);
  color: var(--ink);
}

.icon-btn.danger:hover,
.icon-btn.danger:focus-visible {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Calendar */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.2rem 0 0.8rem;
}

.cal-nav h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.8rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem 0.1rem;
}

.cal-dow {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0.15rem 0 0.4rem;
}

.cal-day {
  aspect-ratio: 1 / 1.15;
  min-height: 2.7rem;
  border-radius: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  color: var(--ink);
  font-weight: 750;
  font-size: 0.92rem;
  position: relative;
}

.cal-day.out {
  color: var(--ink-faint);
  opacity: 0.5;
}

.cal-day.today .num {
  background: var(--accent);
  color: var(--accent-text);
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
}

.cal-day[aria-pressed="true"] {
  background: var(--accent-soft);
}

.cal-day.today[aria-pressed="true"] .num {
  background: var(--accent);
}

.dots {
  display: flex;
  gap: 0.12rem;
  min-height: 0.35rem;
  align-items: center;
}

.dot {
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 50%;
  background: var(--accent);
}

.dot.t-firm { background: var(--band-firm); }
.dot.t-ok { background: var(--band-ok); }
.dot.t-loose { background: var(--band-loose); }
.dot.food { background: var(--sage); }

.cal-day.has-dairy .num {
  color: var(--dairy-num);
  font-weight: 800;
}
.cal-day.today.has-dairy .num {
  background: var(--dairy-today-bg);
  color: var(--accent-text);
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 1rem;
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  font-weight: 750;
  color: var(--ink-soft);
}

.cal-legend .legend-swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0.25rem;
  margin-right: 0.35rem;
  vertical-align: -0.1rem;
  border: 1px solid var(--line);
}

.cal-legend .legend-num {
  display: inline-block;
  min-width: 1.1rem;
  margin-right: 0.28rem;
  text-align: center;
  font-weight: 800;
  font-size: 0.88rem;
  line-height: 1;
  color: var(--dairy-num);
  vertical-align: -0.05rem;
}

.cal-legend .dot {
  display: inline-block;
  vertical-align: 0.05rem;
  margin-right: 0.3rem;
}

.cal-food-empty {
  margin: 0;
}

.day-panel {
  margin-top: 0.9rem;
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin: 0.3rem 0 1.2rem;
}

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.95rem 0.95rem 0.85rem;
  min-width: 0;
}

.stat-card .value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.stat-card .label {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.stat-card .sub {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--ink-faint);
  font-weight: 600;
}

.bars {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.9rem 1rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 7.2rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.bar-row .name {
  font-size: 0.78rem;
  font-weight: 750;
  color: var(--ink-soft);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 0.55rem;
  background: var(--bg-tint);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  width: 0;
}

.bar-row .count {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink);
  min-width: 1.2rem;
  text-align: right;
}

.note {
  margin: 1rem 0;
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

.note.loose {
  background: var(--info-soft);
}

.note.color-red {
  background: var(--danger-soft);
}

.note.color-diet {
  background: var(--info-soft);
}

.note .note-kicker {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
  color: var(--warn);
}

.note.loose .note-kicker {
  color: var(--info);
}

.note.color-red .note-kicker {
  color: var(--danger);
}

.note.color-diet .note-kicker {
  color: var(--info);
}

.disclaimer {
  margin: 0.4rem 0 1rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-weight: 600;
}

.data-box {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.data-box h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 800;
}

.data-box p {
  margin: 0 0 0.8rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  min-height: 2.6rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  background: var(--bg-tint);
  font-weight: 750;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

/* Sheet */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 10, 0.45);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 110%);
  width: 100%;
  max-width: 40rem;
  max-height: min(92dvh, 46rem);
  overflow: auto;
  background: var(--bg-elev);
  border-radius: 1.4rem 1.4rem 0 0;
  box-shadow: var(--shadow-sheet);
  z-index: 50;
  padding: 0.5rem 1.15rem calc(var(--safe-bottom) + var(--netlify-badge-clearance) + 1.1rem);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet.open {
  transform: translate(-50%, 0);
}

.sheet-handle {
  width: 2.6rem;
  height: 0.3rem;
  border-radius: 99px;
  background: var(--line);
  margin: 0.4rem auto 0.7rem;
}

.sheet h2 {
  margin: 0 0 0.9rem;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.field {
  margin: 0 0 1rem;
}

.field label,
.field .lbl {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}

.field input[type="datetime-local"],
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 0.85rem;
  padding: 0.7rem 0.8rem;
  min-height: 2.8rem;
}

.field textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
}

.type-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem 0.1rem 0.4rem;
  border-radius: 0.85rem;
  border: 1.5px solid var(--line);
  background: var(--bg);
  min-width: 0;
  min-height: 4.2rem;
}

.type-opt .n {
  font-weight: 800;
  font-size: 0.95rem;
}

.type-opt svg {
  width: 1.25rem;
  height: 1.25rem;
}

.type-opt .s {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.1;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.type-opt[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.type-hint {
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  min-height: 1.2em;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.color-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-height: 3.4rem;
  padding: 0.45rem 0.25rem 0.4rem;
  border-radius: 0.85rem;
  border: 1.5px solid var(--line);
  background: var(--bg);
  min-width: 0;
}

.color-opt .swatch {
  width: 1.15rem;
  height: 1.15rem;
}

.color-opt .s {
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  color: var(--ink-soft);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.color-opt[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tag-opt {
  min-height: 2.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-weight: 750;
  font-size: 0.88rem;
}

.tag-opt[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tag-opt.blood[aria-pressed="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.sheet-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.3rem;
}

.sheet-actions .btn {
  flex: 1;
}

.sheet-actions .btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Modal */
.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: calc(100% - 2.4rem);
  max-width: 22rem;
  background: var(--bg-elev);
  border-radius: 1.15rem;
  padding: 1.15rem 1.1rem 1rem;
  z-index: 60;
  box-shadow: var(--shadow-sheet);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.modal h2 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 800;
}

.modal p {
  margin: 0 0 0.95rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.install-banner {
  margin: 0 0 1rem;
  padding: 0.8rem 0.9rem;
  border-radius: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}

.install-banner p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--ink-soft);
  flex: 1;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + var(--netlify-badge-clearance) + 0.7rem);
  transform: translateX(-50%) translateY(1rem);
  background: var(--ink);
  color: var(--bg);
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  font-weight: 750;
  font-size: 0.88rem;
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100% - 2rem);
  text-align: center;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.day-group {
  margin: 0 0 1.15rem;
}

.day-group h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}


.food-search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 0.9rem;
  padding: 0.75rem 0.9rem;
  min-height: 2.9rem;
  margin: 0.2rem 0 0.7rem;
}

.food-results {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  max-height: 16.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.food-result {
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.75rem 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: flex-start;
  min-height: 3.2rem;
}

.food-result .food-name {
  font-weight: 800;
  font-size: 0.92rem;
}

.food-result .food-meta {
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--ink-soft);
  margin-top: 0.15rem;
}

.food-result .food-cals {
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
  flex: none;
}

.food-item {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.8rem 0.9rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.7rem;
  align-items: start;
}

.food-item .food-name {
  font-weight: 800;
}

.food-item .food-meta,
.food-item .food-macros {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--ink-soft);
}

.totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  margin: 0.85rem 0 1rem;
}

.totals.compact {
  margin: 0.15rem 0 0.2rem;
}

.totals.compact .n {
  font-size: 0.82rem;
}

.totals.compact .l {
  font-size: 0.58rem;
}

.totals div {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.55rem 0.25rem 0.5rem;
  text-align: center;
  min-width: 0;
}

.totals .n {
  display: block;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
}

.totals .l {
  display: block;
  font-size: 0.62rem;
  font-weight: 750;
  color: var(--ink-soft);
  margin-top: 0.1rem;
}

.portion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.portion-opt {
  min-height: 2.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-weight: 750;
  font-size: 0.85rem;
}

.portion-opt[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.stepper input {
  width: 5.5rem;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 0.75rem;
  padding: 0.55rem 0.5rem;
  text-align: center;
  min-height: 2.6rem;
}

.stepper .icon-btn,
.stepper button.nav-btn {
  flex: none;
}

.credit {
  margin: 1rem 0 0.4rem;
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-weight: 650;
  text-align: center;
}

.note.fiber-firm,
.note.fiber-low {
  background: var(--accent-soft);
}

.note.fiber-loose {
  background: var(--info-soft);
}

@media (max-width: 360px) {
  .totals {
    grid-template-columns: repeat(3, 1fr);
  }
}


.header-actions {
  position: relative;
  flex: none;
}

.theme-btn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.8rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  place-items: center;
}

.theme-btn:focus-visible,
.theme-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-btn svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 35;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 0.3rem;
  min-width: 10rem;
}

.theme-menu[hidden] {
  display: none;
}

.theme-menu button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 0.75rem;
  font-weight: 750;
  min-height: 2.45rem;
  color: var(--ink);
}

.theme-menu button svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.theme-menu button[aria-checked="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.seg {
  display: inline-flex;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  padding: 0.15rem;
  gap: 0.1rem;
  flex: none;
}

.seg-btn {
  min-height: 2rem;
  min-width: 2.35rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.seg-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.weight-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.weight-row input {
  flex: 1;
  width: auto;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 0.75rem;
  padding: 0.55rem 0.5rem;
  text-align: center;
  min-height: 2.6rem;
}



.dairy-flag {
  margin-top: 0.45rem;
  min-height: 1.85rem;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.dairy-flag[aria-pressed="true"] {
  background: var(--dairy-bg);
  border-color: var(--dairy-line);
  color: var(--dairy-line);
}


.ai-photo {
  margin: 0 0 1rem;
}

.ai-photo .preview {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  background: var(--bg-tint);
  margin: 0 0 0.6rem;
}

.ai-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem 0.9rem 0.9rem;
  margin-top: 0.7rem;
}

.ai-card .ai-kicker {
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ai-card p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  font-weight: 650;
}

.ai-card .ai-suggest {
  font-weight: 800;
  margin-top: 0.45rem;
}

.ai-card ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.ai-card li {
  font-size: 0.88rem;
  font-weight: 650;
  margin: 0.2rem 0 0;
}

.ai-card .ai-flags {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 0.75rem;
  padding: 0.5rem 0.65rem;
  margin-top: 0.55rem;
  list-style: disc;
}

.ai-card .disclaimer {
  margin-top: 0.65rem;
}

.ai-card .ai-actions {
  margin-top: 0.7rem;
}

.entry-body .ai-note {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink-soft);
}


.ai-day-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.95rem 1rem 1rem;
  margin: 0.95rem 0 0;
}

.ai-day-card .ai-day-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}

.ai-day-card .ai-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ai-day-card .ai-day-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}

.ai-day-card .ai-day-updated {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-faint);
  white-space: nowrap;
}

.ai-day-card .ai-day-refresh {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
}

.ai-day-card .ai-day-refresh:disabled {
  opacity: 0.7;
}

.ai-day-card .ai-day-summary {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--ink);
}

.ai-day-card .ai-day-status {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.ai-day-card h4 {
  margin: 0.7rem 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ai-day-card ul {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}

.ai-day-card li {
  font-size: 0.88rem;
  font-weight: 650;
  margin: 0.18rem 0 0;
  color: var(--ink);
}

.ai-day-card .ai-flags {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 0.75rem;
  padding: 0.5rem 0.65rem;
  margin-top: 0.55rem;
  list-style: disc;
}

.ai-day-card .disclaimer {
  margin-top: 0.7rem;
  margin-bottom: 0;
}

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

.ai-day-card.is-local .ai-kicker {
  color: var(--muted);
}
