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

:root {
  --charcoal: #171e19;
  --sage: #b7c6c2;
  --red: #ca0013;
  --paper: #eeebe3;
  --white: #ffffff;

  --ink-2: rgba(23, 30, 25, 0.62);
  --line: rgba(183, 198, 194, 0.3);
  --line-soft: rgba(183, 198, 194, 0.2);
  --sage-wash: rgba(183, 198, 194, 0.2);
  --red-wash: rgba(202, 0, 19, 0.1);

  --shadow: 0 20px 50px -12px rgba(23, 30, 25, 0.08);
  --shadow-red: 0 12px 24px -6px rgba(202, 0, 19, 0.3);

  --r-card: 40px;
  --r-item: 24px;
  --r-small: 16px;

  --gutter: 20px;
  --column: 430px;
  --dock-h: 64px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;

  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  /* keep focused or scrolled-to items clear of the floating dock */
  scroll-padding-bottom: calc(var(--dock-h) + 48px);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--charcoal);
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--charcoal);
  outline-offset: 3px;
}

/* ---------- Type scale ---------- */

.heading {
  font-size: 32px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.subheading {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
}

.label {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.muted { color: var(--ink-2); }

/* ---------- App column ---------- */

.app {
  max-width: var(--column);
  margin: 0 auto;
  padding: 56px var(--gutter) calc(var(--dock-h) + 8px + 56px + env(safe-area-inset-bottom));
}

#view { outline: none; }

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.greet-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage);
}

.greet-name {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
}

.avatar {
  position: relative;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--sage);
  box-shadow: var(--shadow);
  flex: none;
}

.avatar svg {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.avatar-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--paper);
}

.avatar-badge[hidden] { display: none; }

/* ---------- Day selector ---------- */

.days {
  display: flex;
  gap: 10px;
  margin: 28px calc(var(--gutter) * -1) 0;
  padding: 4px var(--gutter) 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
  list-style: none;
}

.days::-webkit-scrollbar { display: none; }

.day {
  position: relative;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1px;
  flex: 0 0 56px;
  height: 56px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-small);
  background: var(--white);
  scroll-snap-align: center;
  transition: border-color 0.2s;
}

.day:hover { border-color: var(--sage); }

.day-wd { color: var(--sage); }

.day-num {
  font-size: 17px;
  font-weight: 900;
  line-height: 1.1;
}

.day-dot {
  width: 4px;
  height: 4px;
  margin-top: 2px;
  border-radius: 50%;
  background: transparent;
}

.day[data-mark="logged"] .day-dot { background: var(--sage); }
.day[data-mark="reaction"] .day-dot { background: var(--red); }

.day.is-active {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-basis: 160px;
  padding: 0 14px 0 7px;
  border-color: var(--charcoal);
  border-radius: 999px;
  background: var(--charcoal);
  color: var(--white);
  text-align: left;
}

.day-value {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-size: 16px;
  font-weight: 900;
  flex: none;
}

.day-text { display: grid; min-width: 0; }

.day-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.day-status {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.66);
  white-space: nowrap;
}

/* ---------- Cards ---------- */

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  background: var(--white);
  box-shadow: var(--shadow);
}

.hero {
  margin-top: 20px;
  padding: 26px 22px 22px;
}

.blob {
  position: absolute;
  top: -64px;
  right: -64px;
  width: 210px;
  height: 210px;
  color: var(--sage-wash);
  pointer-events: none;
}

.hero > :not(.blob) { position: relative; }

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--sage-wash);
  color: var(--charcoal);
}

.hero-title { margin-top: 12px; }

.hero-text {
  margin-top: 8px;
  max-width: 30ch;
  color: var(--ink-2);
  font-weight: 600;
}

.emoji-box {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--white);
  box-shadow: var(--shadow);
  font-family: var(--emoji);
  font-size: 32px;
  line-height: 1;
  flex: none;
}

/* Bento metric cards */
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.metric {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-small);
  background: rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--red-wash);
  color: var(--red);
  flex: none;
}

.metric-icon .icon { width: 17px; height: 17px; }

.metric-body { display: grid; min-width: 0; }
.metric-label { color: var(--sage); }

.metric-value {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

/* Alert / info box */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
  padding: 14px 16px 14px 14px;
  border-radius: var(--r-item);
  background: var(--sage-wash);
}

.notice-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--white);
  color: var(--charcoal);
  flex: none;
}

.notice-icon .icon { width: 18px; height: 18px; }
.notice.is-critical .notice-icon { color: var(--red); }

.notice-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}

.notice-text {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

/* ---------- Sections & feed ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 32px 0 14px;
}

.section-head .label { color: var(--ink-2); }

.feed {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--white);
}

.row-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--r-small);
  background: color-mix(in srgb, var(--tint, var(--charcoal)) 10%, transparent);
  font-family: var(--emoji);
  font-size: 26px;
  line-height: 1;
  flex: none;
}

.row-icon .icon { width: 22px; height: 22px; }
.row-icon.is-critical { color: var(--red); }

.row-body {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.row-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.row-sub .tag { min-height: 20px; padding: 0 8px; }

.row-note {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--charcoal);
}

.row-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  color: var(--red);
}

.row-flag .icon { width: 14px; height: 14px; }

.check {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1.5px solid var(--sage);
  border-radius: 50%;
  background: var(--white);
  color: transparent;
  flex: none;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}

.check .icon { width: 20px; height: 20px; stroke-width: 2.6; }

.check:hover {
  border-color: var(--red);
  color: var(--red);
}

.check[aria-pressed="true"] {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
}

.check:active { transform: scale(0.92); }

.status {
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex: none;
}

.status-done { background: var(--charcoal); color: var(--white); }
.status-live { background: var(--sage-wash); color: var(--charcoal); }
.status-next { color: var(--ink-2); }

/* Tried-foods grid */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 16px 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--white);
  text-align: center;
}

.tile-emoji {
  font-family: var(--emoji);
  font-size: 30px;
  line-height: 1.2;
}

.tile-name {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.tile-count { color: var(--ink-2); }

.view-intro { margin-top: 28px; }
.view-intro .muted { margin-top: 6px; font-weight: 600; }

.empty {
  padding: 22px;
  border: 1px dashed var(--sage);
  border-radius: var(--r-item);
  color: var(--ink-2);
  font-weight: 600;
  text-align: center;
}

/* Switch */
.switch {
  position: relative;
  width: 52px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--sage);
  flex: none;
  transition: background-color 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 2px 6px rgba(23, 30, 25, 0.2);
  transition: transform 0.25s var(--ease);
}

.switch[aria-checked="true"] { background: var(--charcoal); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
  transition: transform 0.15s var(--ease), background-color 0.2s, border-color 0.2s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--red);
  color: var(--white);
  box-shadow: var(--shadow-red);
}

.btn-primary:hover { background: #b30011; }

.btn-secondary {
  border-color: var(--sage);
  background: var(--white);
  color: var(--charcoal);
}

.btn-secondary:hover { border-color: var(--charcoal); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  flex: none;
}

/* ---------- Floating navigation ---------- */

.dock {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr 72px 1fr 1fr;
  align-items: center;
  justify-items: center;
  max-width: calc(var(--column) - 16px);
  height: var(--dock-h);
  margin: 0 auto;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--charcoal);
  box-shadow: 0 20px 40px -14px rgba(23, 30, 25, 0.45);
  view-transition-name: dock;
}

.tab {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--sage);
  transition: color 0.2s;
}

.tab:hover { color: var(--white); }
.tab[aria-current="page"] { color: var(--white); }
.dock :focus-visible { outline-color: var(--white); outline-offset: 0; }

.fab {
  display: grid;
  place-items: center;
  align-self: start;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 4px solid var(--paper);
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  box-shadow: var(--shadow-red);
  transform: translateY(-32px);
  transition: transform 0.2s var(--ease), background-color 0.2s;
}

.fab .icon { width: 26px; height: 26px; stroke-width: 2.4; }
.fab:hover { background: #b30011; }
.fab:active { transform: translateY(-32px) scale(0.94); }
.dock .fab:focus-visible { outline: 2px solid var(--charcoal); outline-offset: 2px; }

/* ---------- Log sheet ---------- */

.sheet {
  width: 100%;
  max-width: var(--column);
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
  transform: translateY(100%);
  transition: transform 0.32s var(--ease), overlay 0.32s allow-discrete, display 0.32s allow-discrete;
}

.sheet[open] { transform: translateY(0); }

@starting-style {
  .sheet[open] { transform: translateY(100%); }
}

.sheet::backdrop {
  background: rgba(23, 30, 25, 0);
  transition: background-color 0.32s, overlay 0.32s allow-discrete, display 0.32s allow-discrete;
}

.sheet[open]::backdrop { background: rgba(23, 30, 25, 0.4); }

@starting-style {
  .sheet[open]::backdrop { background: rgba(23, 30, 25, 0); }
}

.sheet-panel {
  max-height: 92dvh;
  overflow-y: auto;
  padding: 10px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  border-radius: var(--r-card) var(--r-card) 0 0;
  background: var(--white);
  overscroll-behavior: contain;
}

.sheet-grip {
  width: 40px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: var(--sage);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sheet-date {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.field {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field .label {
  margin-bottom: 10px;
  padding: 0;
  color: var(--ink-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.segmented-2 { grid-template-columns: 1fr 1.6fr; }

.chip { position: relative; display: block; }

.chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.chip > span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.segmented .chip > span { padding: 0 6px; }
.chip .chip-emoji { font-family: var(--emoji); font-size: 17px; }
.chip input:hover + span { border-color: var(--sage); }

.chip input:checked + span {
  border-color: var(--charcoal);
  background: var(--charcoal);
  color: var(--white);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--charcoal);
  outline-offset: 2px;
}

.note textarea {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-small);
  background: var(--white);
  font-size: 15px;
  font-weight: 600;
  resize: vertical;
}

.note textarea::placeholder { color: rgba(23, 30, 25, 0.45); }
.note textarea:focus { outline: 2px solid var(--charcoal); outline-offset: 1px; }

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
  margin-top: 26px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 8px + 44px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px 11px 12px;
  border-radius: 999px;
  background: var(--charcoal);
  color: var(--white);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 20px 40px -14px rgba(23, 30, 25, 0.45);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}

.toast .icon { width: 18px; height: 18px; color: var(--sage); stroke-width: 2.6; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- View transitions ---------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.25s;
  animation-timing-function: ease-in-out;
}

::view-transition-group(dock) { animation: none; }

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

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

@media (max-width: 360px) {
  :root { --gutter: 16px; }
  .greet-name { font-size: 26px; }
  .heading { font-size: 28px; }
  .metrics { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .segmented { grid-template-columns: 1fr 1fr; }
}
