:root {
  --ground: #FFFFFF;
  --ink: #16211B;
  --ink-soft: #56615A;
  --line: #E6EAE3;
  --wash: #F2F5EF;
  --track: #EEF2EA;
  --beet: #B0205E;
  --beet-deep: #8C1449;
  --beet-wash: #FBEAF1;
  --kiwi: #7DBB2E;
  --kiwi-deep: #3F6E0E;
  --yolk: #F6C53C;
  --yolk-wash: #FFF6DA;
  --carrot: #F08A24;

  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "DM Sans", system-ui, -apple-system, sans-serif;
  --bar: 64px;
  --dock: 160px;
  --lift: 0 18px 40px rgba(22, 33, 27, 0.10), 0 2px 6px rgba(22, 33, 27, 0.05);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  margin: 0;
  min-height: 100svh;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
svg { display: block; }

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

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Screens */

main > section { display: none; }
body[data-screen="welcome"] .welcome,
body[data-screen="goals"] .goals,
body[data-screen="day"] .day { display: grid; }
body[data-screen="loading"] .credit { visibility: hidden; }

/* Header */

.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--bar);
  padding: 0 max(20px, calc((100vw - 1160px) / 2));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand {
  display: flex; align-items: center; gap: 9px;
  color: var(--ink); text-decoration: none;
  border-radius: 12px;
}
.brand-mark { width: 30px; height: 30px; color: var(--beet); }
.brand-name {
  font: 800 25px/1 var(--display);
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 96;
  padding-bottom: 3px;
}

.bar-actions { position: relative; display: flex; align-items: center; gap: 6px; }

.goal-pill {
  height: 40px; padding: 0 16px;
  border-radius: 999px;
  background: var(--wash);
  font-size: 14px; font-weight: 600;
}
.goal-pill:hover { background: var(--track); }

.menu-button {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
}
.menu-button svg { width: 24px; height: 24px; }
.menu-button:hover, .menu-button[aria-expanded="true"] { background: var(--wash); }

.menu {
  position: absolute; top: 52px; right: 0;
  min-width: 232px; padding: 8px;
  background: var(--ground);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(22, 33, 27, 0.18), 0 0 0 1px var(--line);
  transform-origin: top right;
  animation: menu-open 0.18s var(--ease);
}
.menu button {
  display: block; width: 100%;
  min-height: 48px; padding: 0 14px;
  border-radius: 12px;
  text-align: left; font-weight: 500;
}
.menu button:hover { background: var(--wash); }
.menu button[data-action="start-over"] { color: var(--beet); }

@keyframes menu-open { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }

/* Buttons */

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 24px;
  border-radius: 999px;
  font-weight: 600; font-size: 16px;
  transition: background 0.15s, transform 0.15s var(--ease);
}
.button:active { transform: scale(0.97); }
.button-primary { background: var(--beet); color: #fff; }
.button-primary:hover { background: var(--beet-deep); }
.button-quiet { background: var(--wash); }
.button-quiet:hover { background: var(--track); }

.link-button {
  min-height: 44px; padding: 0 4px;
  font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}

/* Welcome */

.welcome {
  max-width: 1160px; min-height: calc(100svh - var(--bar) - 80px);
  margin: 0 auto; padding: 24px 20px 40px;
  gap: 40px; align-content: center;
}

.welcome h1 {
  font: 800 clamp(52px, 13vw, 104px)/0.9 var(--display);
  letter-spacing: -0.045em;
  font-variation-settings: "opsz" 96;
  max-width: 8ch;
}
.welcome-copy > p:first-of-type {
  max-width: 34em; margin-top: 24px;
  font-size: 18px; line-height: 1.55; color: var(--ink-soft);
}
.welcome-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.welcome-note { margin-top: 20px; font-size: 14px; color: var(--ink-soft); }

.welcome-demo {
  position: relative; margin: 0;
  display: grid; justify-items: center;
  padding: 44px 0 60px;
}
.welcome-demo .plate-stage { width: min(78vw, 400px); }
.demo-you, .demo-coach {
  position: absolute; z-index: 2;
  max-width: 250px; padding: 12px 16px;
  font-size: 15px; line-height: 1.4;
  box-shadow: var(--lift);
}
.demo-you {
  top: 8px; right: 4%;
  background: var(--ink); color: #fff; font-weight: 500;
  border-radius: 20px 20px 6px 20px;
}
.demo-coach {
  bottom: 0; left: 0;
  background: var(--ground);
  border-radius: 6px 20px 20px 20px;
}

/* Plate */

.plate-stage {
  position: relative;
  width: min(72vw, 300px);
  aspect-ratio: 1;
  container-type: inline-size;
}
.plate {
  width: 100%; height: 100%; overflow: visible;
  filter: drop-shadow(0 22px 28px rgba(22, 33, 27, 0.10)) drop-shadow(0 3px 5px rgba(22, 33, 27, 0.06));
}
.plate-rim { fill: #fff; stroke: var(--line); stroke-width: 1; }
.plate-well { fill: #FAFBF8; stroke: var(--line); stroke-width: 1.5; }
.plate-track { fill: none; stroke: var(--track); stroke-width: 24; }
.bite-arc {
  fill: none; stroke-width: 24; stroke-linecap: round;
  transition: stroke-dasharray 0.8s var(--ease), stroke-dashoffset 0.8s var(--ease), opacity 0.3s;
}

.plate-readout {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center;
  text-align: center; pointer-events: none;
}
.plate-readout strong {
  font: 800 19cqi/1 var(--display);
  letter-spacing: -0.04em;
  font-variation-settings: "opsz" 96;
  font-variant-numeric: tabular-nums;
}
.plate-readout span {
  margin-top: 2cqi;
  font-size: max(13px, 4.6cqi); font-weight: 600;
  color: var(--kiwi-deep);
}
.plate-stage.over .plate-readout strong,
.plate-stage.over .plate-readout span { color: var(--beet); }

.plate-delta {
  position: absolute; top: 24%; left: 50%;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--yolk);
  font: 700 15px/1.4 var(--display);
  opacity: 0; pointer-events: none;
  translate: -50% 0;
}
.plate-delta.pop { animation: delta 1.5s var(--ease); }
.plate-live.bump .plate { animation: bump 0.6s var(--ease); }

@keyframes delta {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 1; transform: translateY(-8px); }
  100% { opacity: 0; transform: translateY(-20px); }
}
@keyframes bump {
  30% { transform: scale(1.035) rotate(-2deg); }
  60% { transform: scale(0.995) rotate(0.6deg); }
}

/* Goals */

.goals {
  max-width: 620px; margin: 0 auto;
  padding: 32px 20px 48px;
  gap: 20px; align-content: start;
}
.goals h2 {
  margin-top: 16px;
  font: 800 clamp(34px, 8vw, 50px)/1 var(--display);
  letter-spacing: -0.035em;
}
.goal-options { display: grid; gap: 12px; }
.goal-option {
  display: grid; gap: 4px;
  padding: 20px 24px;
  border: 2px solid var(--line); border-radius: 26px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.15s var(--ease);
}
.goal-option strong { font: 700 24px/1.15 var(--display); letter-spacing: -0.02em; }
.goal-option span { color: var(--ink-soft); }
.goal-option:hover { border-color: var(--ink); }
.goal-option:active { transform: scale(0.985); }
.goal-option.current { border-color: var(--beet); background: var(--beet-wash); }
.goals-cancel { justify-self: start; }
body:not(.has-goal) .goals-cancel { display: none; }

/* Coach and the person talking to her */

.coach {
  position: relative;
  display: grid; grid-template-columns: 40px 1fr; gap: 10px;
  align-items: start;
}
.coach-mark { width: 40px; height: 40px; color: var(--beet); transition: transform 0.3s var(--ease); }
.coach-text {
  padding: 13px 18px;
  border-radius: 6px 22px 22px 22px;
  background: var(--wash);
  font-size: 17px; line-height: 1.45;
  min-height: 50px;
}
.coach-voice {
  position: absolute; top: 28px; left: 24px;
  display: flex; align-items: center; gap: 2px;
  height: 20px; padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(22, 33, 27, 0.16);
  opacity: 0; transform: scale(0.6);
  transition: opacity 0.2s, transform 0.2s var(--ease);
}
.coach-voice i { width: 3px; height: 10px; border-radius: 2px; background: var(--beet); }
body.speaking .coach-voice { opacity: 1; transform: none; }
body.speaking .coach-voice i { animation: voice 0.9s ease-in-out infinite; }
body.speaking .coach-voice i:nth-child(2) { animation-delay: -0.3s; }
body.speaking .coach-voice i:nth-child(3) { animation-delay: -0.6s; }

@keyframes voice {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1.2); }
}

.exchange { display: grid; gap: 14px; }

.you {
  justify-self: end;
  max-width: 88%;
  padding: 12px 18px;
  border-radius: 22px 22px 6px 22px;
  background: var(--ink); color: #fff;
  font-size: 17px; font-weight: 500; line-height: 1.4;
}
.you mark {
  padding: 0 4px; margin: 0 -1px;
  border-radius: 7px;
  background: var(--yolk); color: var(--ink);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  animation: mark-in 0.4s var(--ease) both;
}
.you.live::after {
  content: ""; display: inline-block;
  width: 2px; height: 1.05em; margin-left: 3px;
  vertical-align: -0.15em;
  background: var(--yolk);
  animation: caret 0.9s steps(1) infinite;
}
.you.waiting { color: rgba(255, 255, 255, 0.7); }

@keyframes mark-in { from { background: transparent; color: #fff; } }
@keyframes caret { 50% { opacity: 0; } }

.coach-note { padding-left: 50px; font-size: 14px; color: var(--ink-soft); }

/* Day */

.day {
  max-width: 1160px; margin: 0 auto;
  padding: 8px 20px calc(var(--dock) + 24px);
  gap: 28px;
}

.sample-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 8px 6px 18px;
  border-radius: 20px;
  background: var(--yolk-wash);
  font-weight: 600;
}
.sample-banner[data-state="playing"] p::before {
  content: ""; display: inline-block;
  width: 8px; height: 8px; margin-right: 10px;
  border-radius: 50%; background: var(--beet);
  vertical-align: 1px;
  animation: caret 1.2s steps(1) infinite;
}

.day-summary { display: grid; gap: 22px; justify-items: center; }
.day-date { justify-self: start; font-weight: 600; color: var(--ink-soft); }

.macros {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px;
  width: 100%;
}
.macro-protein { grid-column: 1 / -1; }
.macro p {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 7px;
  font-size: 14px; color: var(--ink-soft);
}
.macro p > span:first-child { font-weight: 600; color: var(--ink); }
.macro strong {
  font: 700 19px/1 var(--display);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.macro-protein p > span:first-child { font: 700 19px/1 var(--display); }
.macro-protein strong { font-size: 28px; }
.meter { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.macro-protein .meter { height: 14px; }
.meter i {
  display: block; height: 100%;
  border-radius: inherit;
  transform: scaleX(var(--fill, 0)); transform-origin: left;
  transition: transform 0.8s var(--ease);
}
[data-meter="protein"] { background: var(--beet); }
[data-meter="carbs"] { background: var(--yolk); }
[data-meter="fat"] { background: var(--kiwi); }

.day-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.day-actions .button { padding: 0 12px; font-size: 15px; }

.day-talk { display: grid; gap: 28px; align-content: start; }

/* Composer: a dock on phones, inline on desktop */

.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -1px 0 var(--line), 0 -12px 30px rgba(22, 33, 27, 0.06);
}

.chips {
  display: flex; gap: 8px;
  margin: 0 -16px 12px; padding: 0 16px;
  overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 40px; padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--ground);
  font-size: 15px; font-weight: 500; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.15s var(--ease);
}
.chip:hover { border-color: var(--ink); }
.chip:active { transform: scale(0.96); }
.chips.ideas .chip { background: var(--yolk-wash); border-color: transparent; }
.chips.ideas .chip:hover { border-color: var(--ink); }

.composer-row { display: flex; align-items: center; gap: 12px; }
.composer-field { position: relative; flex: 1; min-width: 0; }
.composer-field input {
  width: 100%; height: 56px;
  padding: 0 58px 0 20px;
  border: 2px solid transparent; border-radius: 999px;
  background: var(--wash);
  font-size: 17px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.composer-field input::placeholder { color: var(--ink-soft); }
.composer-field input:focus { border-color: var(--ink); background: #fff; }

.send {
  position: absolute; top: 7px; right: 7px;
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--ink); color: #fff;
  transition: opacity 0.15s, transform 0.2s var(--ease);
}
.send svg { width: 22px; height: 22px; }
.composer-field input:placeholder-shown + .send { opacity: 0; transform: scale(0.6); pointer-events: none; }

.mic {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--beet); color: #fff;
  box-shadow: 0 10px 24px rgba(176, 32, 94, 0.32);
  transition: background 0.2s, transform 0.2s var(--ease);
}
.mic:hover { background: var(--beet-deep); }
.mic:active { transform: scale(0.94); }
.mic svg { width: 28px; height: 28px; }
.mic-stop { display: none; width: 20px; height: 20px; border-radius: 5px; background: #fff; }
.mic::before, .mic::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: 50%; background: var(--beet);
  opacity: 0;
}
body[data-listening] .mic svg { display: none; }
body[data-listening] .mic-stop { display: block; }
body[data-listening] .mic::before { animation: ripple 1.6s ease-out infinite; }
body[data-listening] .mic::after { animation: ripple 1.6s ease-out 0.8s infinite; }
body.no-mic .mic { display: none; }

@keyframes ripple {
  from { opacity: 0.35; transform: scale(1); }
  to { opacity: 0; transform: scale(1.9); }
}

/* Meal log */

.log h2 { font: 800 26px/1.1 var(--display); letter-spacing: -0.03em; margin-bottom: 8px; }

.meal { padding-top: 18px; }
.meal-head {
  display: flex; align-items: baseline; gap: 10px;
  padding-bottom: 8px;
}
.meal-head h3 { font: 700 19px/1.2 var(--display); letter-spacing: -0.015em; }
.meal-head h3::before {
  content: ""; display: inline-block;
  width: 12px; height: 12px; margin-right: 9px;
  border-radius: 50%; background: var(--meal);
}
.meal-time { font-size: 14px; color: var(--ink-soft); }
.meal-cal { margin-left: auto; font: 700 16px/1 var(--display); padding-right: 52px; }

.entry {
  display: grid; grid-template-columns: 1fr auto 44px;
  grid-template-areas: "name cal remove" "detail cal remove";
  align-items: center; column-gap: 8px;
  padding: 10px 0 10px 21px;
  border-top: 1px solid var(--line);
  border-radius: 14px;
  transition: background 0.3s, box-shadow 0.3s;
}
.entry-name { grid-area: name; font-weight: 600; }
.entry-detail { grid-area: detail; font-size: 14px; color: var(--ink-soft); }
.entry-cal { grid-area: cal; font: 600 17px/1 var(--display); font-variant-numeric: tabular-nums; }
.entry-remove {
  grid-area: remove;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--ink-soft);
}
.entry-remove svg { width: 20px; height: 20px; }
.entry-remove:hover { background: var(--beet-wash); color: var(--beet); }

.entry.fresh { animation: entry-in 0.7s var(--ease) both; }
.entry.speaking { background: var(--yolk-wash); border-top-color: transparent; }
.entry.speaking + .entry { border-top-color: transparent; }

@keyframes entry-in {
  from { opacity: 0; transform: translateY(-8px); background: var(--yolk-wash); }
}

.meals-empty {
  display: grid; justify-items: start; gap: 6px;
  margin-top: 12px; padding: 22px 22px 24px;
  border: 2px dashed var(--line); border-radius: 24px;
  color: var(--ink-soft);
}
.meals-empty strong { color: var(--ink); font: 700 18px/1.3 var(--display); }

/* Toast and credit */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--dock) + 16px + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 6px 6px 6px 20px;
  border-radius: 999px;
  background: var(--ink); color: #fff;
  font-weight: 500;
  translate: -50% 0;
  box-shadow: 0 14px 34px rgba(22, 33, 27, 0.25);
}
.toast.show { animation: toast-in 0.3s var(--ease); }
.toast-undo {
  min-height: 40px; padding: 0 16px;
  border-radius: 999px;
  color: var(--yolk); font-weight: 700;
}
.toast-undo:hover { background: rgba(255, 255, 255, 0.1); }

@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

.credit { padding: 12px 20px 32px; text-align: center; }
body[data-screen="day"] .credit { margin-top: calc(-1 * var(--dock)); padding-bottom: calc(var(--dock) + 20px); }
.credit a {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px;
  border-radius: 999px;
  color: var(--ink-soft); text-decoration: none;
  font-size: 13px; font-weight: 500;
}
.credit a:hover { color: var(--beet); background: var(--wash); }
.credit svg { width: 20px; height: 12px; }

/* Phones: flatten the two columns so the conversation sits right under the plate */

@media (max-width: 959px) {
  .day { gap: 20px; }
  .day-summary, .day-talk { display: contents; }
  .sample-banner { order: 0; }
  .day-date { order: 1; }
  .plate-live { order: 2; justify-self: center; width: min(66vw, 270px); }
  .exchange { order: 3; }
  .macros { order: 4; margin-top: 8px; }
  .day-actions { order: 5; }
  .log { order: 6; margin-top: 8px; }
}

/* Wider screens */

@media (min-width: 720px) {
  .welcome-demo .plate-stage { width: 380px; }
  .day-actions { display: flex; }
}

@media (min-width: 960px) {
  :root { --dock: 0px; }

  .welcome { grid-template-columns: 1fr 1fr; gap: 64px; padding: 24px 32px 48px; }
  .welcome-demo .plate-stage { width: 420px; }
  .demo-you { right: 0; }

  .day {
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
    column-gap: clamp(48px, 7vw, 104px);
    padding: 16px 32px 56px;
  }
  .sample-banner { grid-column: 1 / -1; }
  .day-summary { position: sticky; top: calc(var(--bar) + 16px); align-self: start; gap: 26px; }
  .day-summary .plate-stage { width: 340px; }
  .day-actions { display: grid; }
  .day-talk { padding-top: 34px; }

  .composer {
    position: static; padding: 0;
    background: none; box-shadow: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    display: flex; flex-direction: column-reverse; gap: 14px;
  }
  .chips { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }
  .mic { width: 72px; height: 72px; }
  .mic svg { width: 30px; height: 30px; }
  .composer-field input { height: 60px; }
  .send { top: 9px; }

  .toast { bottom: 32px; }
  body[data-screen="day"] .credit { margin-top: 0; padding-bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .plate-delta.pop { animation: none; }
}
