:root {
  --bg: #f3eee6;
  --bg-2: #ebe4d8;
  --paper: #fffaf3;
  --ink: #1a2a22;
  --ink-soft: #4b5c53;
  --muted: #7a877f;
  --line: rgba(26, 42, 34, 0.08);
  --sage: #2f6b54;
  --sage-2: #3d8b6e;
  --sage-soft: #dcece4;
  --peach: #e8a87c;
  --peach-deep: #c56a43;
  --gold: #d4a574;
  --rose: #c45c4a;
  --sky: #6a9bb3;
  --shadow: 0 18px 40px rgba(26, 42, 34, 0.08);
  --radius: 22px;
  --side: 260px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; min-height: 100dvh; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select, textarea {
  font: inherit;
  color: #1a1a1a;
  -webkit-text-fill-color: #1a1a1a;
  background: #fff;
  color-scheme: light;
}
select, textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder {
  color: #6f7c74;
  -webkit-text-fill-color: #6f7c74;
  opacity: 1;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}
img { max-width: 100%; display: block; }

.icon { display: inline-block; vertical-align: -3px; flex: none; }

/* Public */
.is-public { background: #15221c; color: #f6efe4; }
.public-main { position: relative; z-index: 1; min-height: 100vh; }

.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  min-height: 100vh;
}
.hero-copy {
  padding: 48px 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    radial-gradient(900px 500px at -10% 110%, rgba(232,168,124,.18), transparent 55%),
    radial-gradient(600px 400px at 90% -10%, rgba(61,139,110,.25), transparent 50%),
    #15221c;
}
.hero-copy h1 {
  font-family: var(--display);
  font-size: clamp(2.6rem, 4.5vw, 4.4rem);
  font-weight: 640;
  line-height: 1.05;
  margin: 12px 0 18px;
  max-width: 11ch;
}
.hero-copy p.lead {
  color: #d7cfc3;
  font-size: 1.08rem;
  max-width: 38ch;
  line-height: 1.55;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .02em;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: #e8c9a0;
  color: #15221c;
}
.hero-points {
  display: grid;
  gap: 10px;
  margin: 28px 0 36px;
  padding: 0;
  list-style: none;
  color: #c9d4ce;
}
.hero-points li { display: flex; gap: 10px; align-items: flex-start; }
.hero-points i {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(61,139,110,.3); color: #b7e0cc;
  display: grid; place-items: center; font-style: normal; font-size: 12px;
}
.hero-form {
  background: #f3eee6;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--paper);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.auth-card h2 {
  font-family: var(--display);
  margin: 0 0 6px;
  font-size: 1.85rem;
}
.auth-card .sub { color: var(--muted); margin: 0 0 22px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: #1a1a1a;
  -webkit-text-fill-color: #1a1a1a;
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231a2a22' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--sage-2);
  box-shadow: 0 0 0 4px rgba(61,139,110,.14);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 18px;
  background: var(--ink); color: #f6efe4; font-weight: 650;
  cursor: pointer; transition: transform .15s ease, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-sage { background: var(--sage); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.muted-link { color: var(--muted); font-size: .92rem; text-align: center; display: block; margin-top: 14px; }
.muted-link a { color: var(--sage); font-weight: 700; }
.alert {
  background: #f8e4de; color: #8a3a2e; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: .92rem;
}

/* App chrome */
.is-app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  background:
    radial-gradient(420px 220px at 0% 0%, rgba(232,201,160,.12), transparent 55%),
    #13201a;
  color: #efe7db;
  display: flex; flex-direction: column;
  padding: 20px 14px 16px;
  z-index: 2;
  view-transition-name: nav-side;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 18px;
}
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 1.02rem; font-weight: 750; letter-spacing: -.02em; }
.brand-copy small { color: #9aada3; font-size: .72rem; font-weight: 500; }
.sidebar .brand-mark {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
}
.side-label {
  margin: 8px 10px 6px;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: #7d9188;
}
.side-nav, .side-foot { display: grid; gap: 4px; }
.side-nav { margin-bottom: 6px; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 42px;
  padding: 6px 8px;
  border-radius: 12px;
  color: #c5d2cb;
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.nav-ico {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: rgba(255,255,255,.05);
  color: #d7e4dd;
}
.nav-ico .icon { width: 18px; height: 18px; vertical-align: 0; display: block; }
.nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-link:hover .nav-ico { background: rgba(255,255,255,.08); }
.nav-link.is-active {
  background: rgba(232,201,160,.12);
  color: #fff;
}
.nav-link.is-active .nav-ico {
  background: #e8c9a0;
  color: #13201a;
}
.nav-link-quiet { color: #8ea097; }
.side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 12px;
}
.side-avatar {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: #3d8b6e; color: #f6efe4;
  font-size: .85rem; font-weight: 750;
}
.side-user-copy { display: grid; line-height: 1.2; min-width: 0; }
.side-user-copy b { font-size: .88rem; font-weight: 700; }
.side-user-copy small { color: #9aada3; font-size: .72rem; }
.app-shell { min-width: 0; position: relative; z-index: 1; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 28px 48px 10px; gap: 16px;
  width: 100%; max-width: 1180px;
  view-transition-name: topbar;
}
.eyebrow { margin: 0; color: var(--muted); font-size: .82rem; font-weight: 600; }
.topbar-title { margin: 2px 0 0; font-family: var(--display); font-size: 2rem; font-weight: 640; }
.topbar-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: .82rem; font-weight: 650;
}
.pill.muted { color: var(--muted); }
.app-main {
  padding: 10px 48px 56px;
  width: 100%; max-width: 1180px;
  view-transition-name: content;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1.4fr .9fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 0 var(--line);
  border: 1px solid rgba(255,255,255,.6);
}
.install-card { margin-bottom: 16px; }
.install-card .btn { margin-top: 4px; }
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .install-card { display: none !important; }
}
.card h3 { margin: 0 0 12px; font-size: 1rem; }
.stat {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  border: 1px solid rgba(255,255,255,.6);
}
.stat .k { color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-family: var(--display); font-size: 1.85rem; margin-top: 4px; }
.stat .h { font-size: .85rem; color: var(--ink-soft); margin-top: 4px; }
.stat.good .v { color: var(--sage); }
.stat.warn .v { color: var(--peach-deep); }

.hero-dash {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: center;
  background:
    linear-gradient(135deg, #1d3128 0%, #243d32 55%, #3a4d2e 100%);
  color: #f6efe4;
  border-radius: 28px;
  padding: 28px 32px;
}
.ring-wrap { position: relative; width: 168px; height: 168px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 10; }
.ring-value { fill: none; stroke: #e8c9a0; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring.is-over .ring-value { stroke: #e08a74; }
.ring-copy {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  transform: none;
}
.ring-copy strong { font-family: var(--display); font-size: 2rem; line-height: 1; }
.ring-kicker { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: #c9d4ce; }
.dash-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric { background: rgba(255,255,255,.07); border-radius: 16px; padding: 12px 14px; }
.metric b { display: block; font-family: var(--display); font-size: 1.35rem; }
.metric span { color: #c9d4ce; font-size: .8rem; }

.macros { display: grid; gap: 12px; }
.macro { display: grid; gap: 6px; }
.macro-row { display: flex; justify-content: space-between; font-size: .88rem; }
.bar { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; }
.bar.p > i { background: #c45c4a; }
.bar.c > i { background: #3d8b6e; }
.bar.f > i { background: #d4a574; }
.bar.fi > i { background: #6a9bb3; }

.date-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--paper); border-radius: 999px; padding: 8px 10px;
  max-width: 360px; margin-bottom: 16px;
}
.date-nav-label { text-align: center; }
.date-nav-label span { display: block; font-size: .78rem; color: var(--muted); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: 0; cursor: pointer;
}
.icon-btn.is-disabled { opacity: .35; pointer-events: none; }

.meal-list { display: grid; gap: 10px; }
.meal-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  padding: 8px; background: #fff; border-radius: 16px; border: 1px solid var(--line);
}
.meal-item img, .meal-ph {
  width: 64px; height: 64px; border-radius: 14px; object-fit: cover; background: var(--sage-soft);
}
.meal-ph { display: grid; place-items: center; color: var(--sage); }
.meal-item h4 { margin: 0; font-size: .95rem; }
.meal-item p { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.kcal { font-weight: 700; font-variant-numeric: tabular-nums; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--sage-soft); color: var(--sage); border-radius: 999px;
  padding: 3px 8px; font-size: .72rem; font-weight: 700; text-transform: capitalize;
}

.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick a, .quick button {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; font-weight: 650; font-size: .88rem; cursor: pointer;
}

.drop {
  border: 1.5px dashed rgba(47,107,84,.35);
  background: #f7faf7;
  border-radius: 24px;
  padding: 28px 18px;
  text-align: center;
  cursor: pointer;
  position: relative;
}
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop strong { display: block; margin-top: 8px; }
.drop span { color: var(--muted); font-size: .88rem; }
.preview-shot {
  width: 100%; max-height: 280px; object-fit: cover; border-radius: 18px; margin-top: 12px;
}
.meal-types { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.meal-types label {
  padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  cursor: pointer; font-weight: 650; font-size: .88rem;
}
.meal-types input { display: none; }
.meal-types input:checked + span, .meal-types label:has(input:checked) {
  background: var(--ink); color: #f6efe4; border-color: var(--ink);
}

.ai-box { display: none; margin-top: 18px; }
.ai-box.is-open { display: block; }
.item-row {
  display: grid; grid-template-columns: 1.4fr .8fr repeat(4, .7fr); gap: 8px;
  font-size: .85rem; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.item-row.hd { color: var(--muted); font-weight: 700; font-size: .75rem; text-transform: uppercase; }
.note { background: var(--sage-soft); color: #21513f; border-radius: 14px; padding: 12px 14px; font-size: .9rem; }

.water { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.water-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.water-dots i {
  width: 16px; height: 16px; border-radius: 50%; background: #d5e4ee; display: block;
}
.water-dots i.on { background: var(--sky); }

.coach-card {
  background: linear-gradient(180deg, #fff 0%, #f6efe4 100%);
}
.lags { display: grid; gap: 8px; }
.lag {
  background: #fff; border-radius: 14px; padding: 12px; border: 1px solid var(--line);
}
.lag b { display: block; text-transform: capitalize; }

.chart-box { height: 240px; }
.toast {
  position: fixed; top: 18px; right: 18px; z-index: 20;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px;
  box-shadow: var(--shadow);
}
.toast-err { background: var(--rose); }

.empty {
  text-align: center; padding: 28px 12px; color: var(--muted);
}
.empty h3 { color: var(--ink); font-family: var(--display); margin-bottom: 6px; }

.bottom-nav { display: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
.help { font-size: .82rem; color: var(--muted); margin-top: -8px; margin-bottom: 14px; }
.switch {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.loader {
  width: 22px; height: 22px; border: 2px solid #fff; border-right-color: transparent;
  border-radius: 50%; display: none; animation: spin .7s linear infinite;
}
.btn.is-loading .loader { display: inline-block; }
.btn.is-loading .btn-txt { opacity: .0; position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }

.setup-wrap { max-width: 680px; margin: 4vh auto; padding: 0 16px 48px; }
.setup-section {
  margin: 20px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.setup-section h3 { margin: 0 0 4px; font-size: 1.05rem; }
.setup-checks { padding-left: 18px; color: var(--ink-soft); font-size: .9rem; }
.onboard { max-width: 640px; margin: 0 auto; }
.steps { display: flex; gap: 8px; margin-bottom: 22px; }
.steps i { flex: 1; height: 4px; border-radius: 99px; background: var(--bg-2); }
.steps i.on { background: var(--sage); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.choice {
  border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 14px;
  cursor: pointer; text-align: left;
}
.choice:has(input:checked), .choice.is-on { border-color: var(--sage); background: var(--sage-soft); }
.choice input { display: none; }
.choice b { display: block; }
.choice span { color: var(--muted); font-size: .8rem; }

.plan-preview {
  background: var(--ink); color: #f6efe4; border-radius: 22px; padding: 20px; margin-top: 16px;
}
.plan-preview .nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.plan-preview b { font-family: var(--display); font-size: 1.3rem; display: block; }

table.simple { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.simple th { text-align: left; color: var(--muted); font-size: .75rem; text-transform: uppercase; padding: 8px 6px; }
table.simple td { padding: 10px 6px; border-top: 1px solid var(--line); }
.danger { color: var(--rose); background: none; border: 0; cursor: pointer; font-weight: 650; }

@media (max-width: 980px) {
  .is-app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero-copy { min-height: auto; padding: 36px 24px 16px; }
  .hero-form { padding: 16px 16px 40px; }
  .grid-2, .grid-3, .grid-4, .form-grid, .dash-metrics, .choice-grid, .plan-preview .nums, .item-row {
    grid-template-columns: 1fr 1fr;
  }
  .item-row.hd { display: none; }
  .app-main, .topbar { padding-left: 16px; padding-right: 16px; }
  .hero-dash { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .topbar-title { font-size: 1.45rem; }
  .app-main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(21, 34, 28, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: #d7cfc3;
    padding: 8px 6px calc(10px + env(safe-area-inset-bottom));
    z-index: 10;
    border-top: 1px solid rgba(255,255,255,.07);
    view-transition-name: nav-tabs;
  }
  .bottom-nav a { display: grid; place-items: center; gap: 2px; font-size: .68rem; font-weight: 650; min-height: 44px; transition: transform .12s ease, color .12s ease; }
  .bottom-nav a:active { transform: scale(.94); }
  .bottom-nav .fab-link { color: #e8c9a0; }
  .card, .stat, .hero-dash { border-radius: 18px; }
}

@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4, .choice-grid, .plan-preview .nums { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

@view-transition {
  navigation: auto;
}

::view-transition-image-pair(topbar),
::view-transition-image-pair(content) {
  isolation: isolate;
}

::view-transition-old(topbar) {
  animation: none;
  opacity: 0;
  mix-blend-mode: normal;
}
::view-transition-new(topbar) {
  animation: title-in .22s ease both;
  mix-blend-mode: normal;
}

::view-transition-old(content) {
  animation: content-out .18s ease-out both;
  mix-blend-mode: normal;
}
::view-transition-new(content) {
  animation: content-in .28s cubic-bezier(.22, 1, .36, 1) both;
  mix-blend-mode: normal;
}
::view-transition-old(nav-side),
::view-transition-new(nav-side),
::view-transition-old(nav-tabs),
::view-transition-new(nav-tabs) {
  animation: none;
}

@keyframes title-in {
  from { opacity: 0; }
}
@keyframes content-out {
  to { opacity: 0; transform: translateY(-6px); }
}
@keyframes content-in {
  from { opacity: 0; transform: translateY(10px); }
}

.is-app .app-main { animation: content-in .28s cubic-bezier(.22, 1, .36, 1) both; }
body.is-leaving .app-main { animation: content-out .16s ease-out both; }

@supports (view-transition-name: content) {
  .is-app .app-main { animation: none; }
  body.is-leaving .app-main { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .is-app .app-main, body.is-leaving .app-main { animation: none !important; }
  ::view-transition-old(content),
  ::view-transition-new(content),
  ::view-transition-old(topbar),
  ::view-transition-new(topbar) { animation: none; }
}
