:root {
  --bg: #f7f3ea;
  --fg: #1f1d1a;
  --accent: #6f8b6a;

  --card: color-mix(in oklab, var(--bg) 80%, var(--fg) 4%);
  --card-2: color-mix(in oklab, var(--bg) 90%, var(--fg) 2%);
  --border: color-mix(in oklab, var(--fg) 12%, transparent);
  --border-soft: color-mix(in oklab, var(--fg) 7%, transparent);
  --muted: color-mix(in oklab, var(--fg) 55%, var(--bg) 45%);
  --muted-2: color-mix(in oklab, var(--fg) 40%, var(--bg) 60%);

  --font-display: "Instrument Serif", ui-serif, Georgia, serif;
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* Center the mobile-friendly app on wider screens */
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#root { width: 100%; }

.app {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 0 32px;
  position: relative;
  background: var(--bg);
}

@media (min-width: 481px) {
  body {
    background: color-mix(in oklab, var(--bg) 70%, var(--fg) 8%);
    align-items: flex-start;
    padding: 24px 0;
  }
  .app {
    border-radius: 28px;
    box-shadow: 0 24px 80px -32px color-mix(in oklab, var(--fg) 40%, transparent),
                0 2px 8px -2px color-mix(in oklab, var(--fg) 20%, transparent);
    overflow: hidden;
    min-height: calc(100vh - 48px);
  }
}

/* ——————————————————————————————————————————————————————————————
   Header
   —————————————————————————————————————————————————————————————— */

.hdr {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.hdr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.iconbtn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  width: 36px; height: 36px;
  border-radius: 999px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 120ms ease, transform 120ms ease;
}
.iconbtn:hover { background: var(--card); }
.iconbtn:active { transform: scale(0.96); }

.hdr-date {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--fg);
  text-align: center;
  cursor: pointer;
  padding: 4px 8px;
}
.hdr-date-main {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.01em;
  font-style: italic;
}
.hdr-date-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.01em;
}

.hdr-meta {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  gap: 0;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
}
.meta-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  justify-self: center;
}
.meta-cell {
  text-align: center;
}
.meta-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-style: italic;
  line-height: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
}
.meta-num em { font-style: italic; }
.meta-num span {
  font-family: var(--font-mono);
  font-size: 11px;
  font-style: normal;
  color: var(--muted);
  margin: 0 4px 0 1px;
  letter-spacing: 0.02em;
}
.meta-lbl {
  margin-top: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ——————————————————————————————————————————————————————————————
   Highlights
   —————————————————————————————————————————————————————————————— */
.hl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 20px 0;
}
.hl-card {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--card-2);
}
.hl-behind {
  background: color-mix(in oklab, var(--accent) 14%, var(--bg));
  border-color: color-mix(in oklab, var(--accent) 30%, transparent);
}
.hl-limit.near {
  background: color-mix(in oklab, oklch(70% 0.12 50) 14%, var(--bg));
  border-color: color-mix(in oklab, oklch(70% 0.12 50) 32%, transparent);
}
.hl-limit.over {
  background: color-mix(in oklab, oklch(56% 0.18 25) 14%, var(--bg));
  border-color: color-mix(in oklab, oklch(56% 0.18 25) 40%, transparent);
}
.hl-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.hl-val {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  line-height: 1.1;
  margin-top: 2px;
}
.hl-pct {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted-2);
}

/* ——————————————————————————————————————————————————————————————
   Section heading
   —————————————————————————————————————————————————————————————— */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 24px 20px 12px;
}
.section-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.section-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ——————————————————————————————————————————————————————————————
   Nutrient grid
   —————————————————————————————————————————————————————————————— */
.ngrid-wrap { padding: 0; }
.ngrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 20px;
}
.ngrid.compact {
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.ncard {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  transition: background 180ms ease, border-color 180ms ease;
}
.ncard.met {
  background: color-mix(in oklab, var(--accent) 10%, var(--card));
  border-color: color-mix(in oklab, var(--accent) 24%, transparent);
}
.ncard.near {
  background: color-mix(in oklab, oklch(70% 0.12 50) 10%, var(--card));
  border-color: color-mix(in oklab, oklch(70% 0.12 50) 30%, transparent);
}
.ncard.over {
  background: color-mix(in oklab, oklch(56% 0.18 25) 12%, var(--card));
  border-color: color-mix(in oklab, oklch(56% 0.18 25) 40%, transparent);
}
.ncard-cap {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 400;
}
.ngrid.compact .ncard {
  flex-direction: column;
  text-align: center;
  gap: 8px;
  padding: 10px 6px;
}

.ring-wrap { position: relative; flex-shrink: 0; }
.ring-inner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.ring-pct {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  display: flex;
  align-items: baseline;
}
.ring-pct-pc {
  font-size: 9px;
  margin-left: 1px;
  color: var(--muted);
}

.ncard-body {
  min-width: 0;
  flex: 1;
}
.ngrid.compact .ncard-body { width: 100%; }
.ncard-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.005em;
}
.ngrid.compact .ncard-label { font-size: 12px; }
.ncard-vals {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ncard-val { color: var(--fg); font-weight: 500; }
.ncard-target { }
.ncard-unit { color: var(--muted); }

/* ——————————————————————————————————————————————————————————————
   Primary log CTA (top of screen)
   —————————————————————————————————————————————————————————————— */
.primary-cta {
  padding: 16px 20px 0;
}
.log-cta {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  box-shadow:
    0 14px 32px -16px color-mix(in oklab, var(--fg) 60%, transparent),
    0 2px 4px -1px color-mix(in oklab, var(--fg) 24%, transparent);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.log-cta:hover { transform: translateY(-1px); }
.log-cta:active { transform: scale(0.985); }
.log-cta-plus {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 14%, transparent);
  display: grid;
  place-items: center;
  margin-top: -2px;
}
.log-cta-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.log-cta-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.log-cta-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: color-mix(in oklab, var(--bg) 70%, var(--fg));
}

/* ——————————————————————————————————————————————————————————————
   Time picker (shared by portion & symptom)
   —————————————————————————————————————————————————————————————— */
.tp {
  margin: 4px 20px 14px;
  padding: 12px 14px 10px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tp-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 2px;
}
.tp-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.tp-time {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  line-height: 1;
  color: var(--fg);
}
.tp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.tp-slots { border-top: 1px solid var(--border-soft); padding-top: 8px; margin-top: 2px; }
.tp-pill {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 120ms ease;
  white-space: nowrap;
}
.tp-pill:hover { border-color: var(--border); }
.tp-pill.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* Symptom picker action row & confirm */
.sym-pop-actions {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.sym-pop-cancel {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 10px;
}
.sym-pop-cancel:hover { background: var(--card); color: var(--fg); }
.sym-pop-confirm {
  appearance: none;
  border: none;
  background: var(--fg);
  color: var(--bg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 120ms ease;
}
.sym-pop-confirm.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.sym-pop-btn.selected {
  outline: 2px solid var(--fg);
  outline-offset: -2px;
}

/* ——————————————————————————————————————————————————————————————
   Symptoms (how you're feeling)
   —————————————————————————————————————————————————————————————— */
.symptoms { padding: 18px 0 0; }
.symptom-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 20px;
}
.sym-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px 7px 9px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--fg);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 100ms ease;
}
.sym-chip:hover { background: color-mix(in oklab, var(--fg) 5%, var(--card)); }
.sym-chip:active { transform: scale(0.97); }
.sym-chip-dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: color-mix(in oklab, var(--fg) 35%, transparent);
  flex-shrink: 0;
}
.sym-chip.sym-negative .sym-chip-dot { background: oklch(62% 0.12 25); }
.sym-chip.sym-positive .sym-chip-dot { background: oklch(60% 0.12 150); }
.sym-chip.sym-neutral  .sym-chip-dot { background: oklch(65% 0.08 80); }
.sym-chip-label { line-height: 1; }
.sym-chip-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--fg);
  color: var(--bg);
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 2px;
  line-height: 1.2;
}
.sym-chip.has-count {
  border-color: color-mix(in oklab, var(--fg) 28%, transparent);
  background: color-mix(in oklab, var(--fg) 4%, var(--card));
}

/* Severity picker */
.sym-scrim {
  position: fixed; inset: 0;
  background: color-mix(in oklab, var(--fg) 40%, transparent);
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadein 160ms ease;
}
.sym-pop {
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: slideup 240ms cubic-bezier(.2,.7,.2,1);
  text-align: center;
}
.sym-pop-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 30px;
  line-height: 1.1;
}
.sym-pop-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.sym-pop-row {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.sym-pop-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  padding: 14px 6px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 120ms ease;
}
.sym-pop-btn:hover { transform: translateY(-1px); }
.sym-pop-btn.kind-negative.lvl-1 { background: color-mix(in oklab, oklch(62% 0.10 25) 14%, var(--card)); border-color: color-mix(in oklab, oklch(62% 0.10 25) 22%, transparent); }
.sym-pop-btn.kind-negative.lvl-2 { background: color-mix(in oklab, oklch(62% 0.10 25) 22%, var(--card)); border-color: color-mix(in oklab, oklch(62% 0.10 25) 34%, transparent); }
.sym-pop-btn.kind-negative.lvl-3 { background: color-mix(in oklab, oklch(62% 0.10 25) 30%, var(--card)); border-color: color-mix(in oklab, oklch(62% 0.10 25) 46%, transparent); }
.sym-pop-btn.kind-positive.lvl-1 { background: color-mix(in oklab, oklch(62% 0.10 150) 14%, var(--card)); border-color: color-mix(in oklab, oklch(62% 0.10 150) 22%, transparent); }
.sym-pop-btn.kind-positive.lvl-2 { background: color-mix(in oklab, oklch(62% 0.10 150) 22%, var(--card)); border-color: color-mix(in oklab, oklch(62% 0.10 150) 34%, transparent); }
.sym-pop-btn.kind-positive.lvl-3 { background: color-mix(in oklab, oklch(62% 0.10 150) 30%, var(--card)); border-color: color-mix(in oklab, oklch(62% 0.10 150) 46%, transparent); }
.sym-pop-btn.kind-neutral.lvl-1 { background: color-mix(in oklab, oklch(65% 0.08 80) 14%, var(--card)); }
.sym-pop-btn.kind-neutral.lvl-2 { background: color-mix(in oklab, oklch(65% 0.08 80) 22%, var(--card)); }
.sym-pop-btn.kind-neutral.lvl-3 { background: color-mix(in oklab, oklch(65% 0.08 80) 30%, var(--card)); }
.sym-pop-cancel {
  margin-top: 14px;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 12px;
}

/* Symptom rows in the timeline */
.sym-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid transparent;
  border-radius: 12px;
}
.sym-row-negative { border-left-color: oklch(62% 0.12 25); }
.sym-row-positive { border-left-color: oklch(60% 0.12 150); }
.sym-row-neutral  { border-left-color: oklch(65% 0.08 80); }
.sym-row-mid { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sym-row-name {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sym-row-dot {
  width: 6px; height: 6px; border-radius: 999px;
}
.sym-row-dot.kind-negative { background: oklch(62% 0.12 25); }
.sym-row-dot.kind-positive { background: oklch(60% 0.12 150); }
.sym-row-dot.kind-neutral  { background: oklch(65% 0.08 80); }
.sym-row-sev {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}

/* ——————————————————————————————————————————————————————————————
   Quick add
   —————————————————————————————————————————————————————————————— */
.quickbar { padding: 16px 0 0; }
.quickbar-label {
  padding: 0 20px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.quickbar-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 20px 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.quickbar-row::-webkit-scrollbar { display: none; }
.quickchip {
  appearance: none;
  flex-shrink: 0;
  scroll-snap-align: start;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  min-width: 130px;
  font-family: inherit;
  color: var(--fg);
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.quickchip:hover {
  background: color-mix(in oklab, var(--accent) 10%, var(--card));
  border-color: color-mix(in oklab, var(--accent) 28%, transparent);
}
.quickchip:active { transform: scale(0.97); }
.quickchip-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}
.quickchip-sub {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

/* ——————————————————————————————————————————————————————————————
   Log
   —————————————————————————————————————————————————————————————— */
.log-wrap { padding: 0 0 24px; }
.log-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 20px;
}
.log-empty {
  padding: 26px 18px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  text-align: center;
  background: var(--card-2);
}
.log-empty-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
}
.log-empty-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.log-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}
.log-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.log-mid { min-width: 0; }
.log-name {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-sub {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.log-sep { color: var(--muted-2); opacity: 0.6; }

.log-ctrls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.log-portion, .log-del {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  color: var(--fg);
  width: 28px; height: 28px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-family: inherit;
}
.log-portion:hover { background: var(--card); }
.log-del {
  color: var(--muted);
  margin-left: 4px;
}
.log-del:hover {
  color: var(--fg);
  background: color-mix(in oklab, var(--fg) 6%, var(--bg));
}

/* ——————————————————————————————————————————————————————————————
   Cloud sync controls (in Tweaks panel)
   —————————————————————————————————————————————————————————————— */
.sync-ctrl {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11.5px;
}
.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--fg);
}
.sync-status.off { color: var(--muted); font-weight: 400; }
.sync-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: oklch(62% 0.13 150);
}
.sync-status.syncing .sync-dot { background: oklch(70% 0.12 60); animation: pulse 1.2s ease infinite; }
.sync-status.error   .sync-dot { background: oklch(60% 0.18 25); }
.sync-ago { color: var(--muted); font-weight: 400; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.sync-err {
  color: oklch(50% 0.16 25);
  background: color-mix(in oklab, oklch(60% 0.18 25) 8%, transparent);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 10.5px;
}
.sync-hint { color: var(--muted); font-size: 10.5px; line-height: 1.4; }
.sync-token-wrap {
  margin-top: 2px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
}
.sync-token-lbl {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
}
.sync-token-val {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--fg);
  word-break: break-all;
}
.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sync-btn {
  appearance: none;
  border: 1px solid rgba(41,38,27,0.18);
  background: rgba(255,255,255,0.6);
  color: var(--fg);
  font-family: inherit;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.sync-btn:hover { background: rgba(255,255,255,0.9); }
.sync-btn.primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.sync-btn.danger { color: oklch(50% 0.16 25); }
.sync-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Sync diagnostic — actionable report shown inside Settings */
.diag-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diag-hint {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}
.diag-hint code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
}
.diag-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.diag-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--fg);
  color: var(--bg);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 100ms ease;
}
.diag-btn:hover { background: color-mix(in oklab, var(--fg) 88%, var(--bg)); }
.diag-btn:active { transform: scale(0.98); }
.diag-btn:disabled { opacity: 0.55; cursor: wait; }
.diag-btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
.diag-btn-ghost:hover { background: var(--card); }
.diag-btn-ghost.ok { color: oklch(50% 0.14 150); border-color: color-mix(in oklab, oklch(60% 0.14 150) 40%, transparent); }

.diag {
  border: 1px solid var(--border-soft);
  background: var(--card-2);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diag-ok           { border-color: color-mix(in oklab, oklch(60% 0.12 150) 40%, transparent);
                     background: color-mix(in oklab, oklch(60% 0.12 150) 8%, var(--card-2)); }
.diag-binding_missing,
.diag-function_missing,
.diag-query_failed,
.diag-write_failed,
.diag-http_error,
.diag-bad_json,
.diag-network_error {
  border-color: color-mix(in oklab, oklch(60% 0.16 28) 38%, transparent);
  background: color-mix(in oklab, oklch(60% 0.16 28) 8%, var(--card-2));
}
.diag-sandboxed,
.diag-unknown { /* neutral */ }

.diag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.diag-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
}
.diag-pill-ok                { background: oklch(56% 0.13 150); }
.diag-pill-binding_missing,
.diag-pill-function_missing  { background: oklch(58% 0.15 60); }
.diag-pill-query_failed,
.diag-pill-write_failed,
.diag-pill-http_error,
.diag-pill-bad_json,
.diag-pill-network_error     { background: oklch(56% 0.18 25); }
.diag-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.diag-headline {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}
.diag-steps {
  margin: 0;
  padding-left: 22px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.diag-steps li::marker { color: var(--muted); }
.diag-steps code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}
.diag-facts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
}
.diag-facts > div {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.diag-facts > div > span {
  color: var(--muted);
  width: 96px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.diag-facts > div > code {
  font-family: var(--font-mono);
  font-size: 11px;
  word-break: break-all;
  color: var(--fg);
}
.diag-raw-toggle {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  text-align: left;
}
.diag-raw-toggle:hover { color: var(--fg); }
.diag-raw {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow-y: auto;
  color: var(--fg);
}
.sync-entry { display: flex; gap: 6px; flex: 1 1 100%; }
.sync-input {
  flex: 1;
  appearance: none;
  border: 1px solid rgba(41,38,27,0.2);
  background: white;
  color: var(--fg);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  outline: none;
  min-width: 0;
}
.sync-input:focus { border-color: var(--fg); }

/* ——————————————————————————————————————————————————————————————
   Settings sheet (user-facing, replaces dev Tweaks in deployed app)
   —————————————————————————————————————————————————————————————— */
.settings-btn { margin-left: 4px; position: relative; }
.settings-btn svg { display: block; }
.settings-btn.has-attention::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: oklch(62% 0.16 35);
  box-shadow: 0 0 0 2px var(--bg);
  animation: sync-pulse 2.4s ease-in-out infinite;
}
@keyframes sync-pulse {
  0%, 100% { transform: scale(1);   opacity: 1;   }
  50%      { transform: scale(1.18); opacity: 0.75; }
}

/* Inline sync banner — surfaces unsupported / error states */
.sync-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 12px 20px 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in oklab, oklch(72% 0.13 60) 18%, var(--bg));
  border: 1px solid color-mix(in oklab, oklch(72% 0.13 60) 40%, transparent);
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background 140ms ease, transform 100ms ease, border-color 140ms ease;
}
.sync-banner:hover {
  background: color-mix(in oklab, oklch(72% 0.13 60) 24%, var(--bg));
  border-color: color-mix(in oklab, oklch(72% 0.13 60) 52%, transparent);
}
.sync-banner:active { transform: scale(0.995); }
.sync-banner:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.sync-banner-error {
  background: color-mix(in oklab, oklch(60% 0.16 28) 14%, var(--bg));
  border-color: color-mix(in oklab, oklch(60% 0.16 28) 36%, transparent);
}
.sync-banner-error:hover {
  background: color-mix(in oklab, oklch(60% 0.16 28) 20%, var(--bg));
  border-color: color-mix(in oklab, oklch(60% 0.16 28) 48%, transparent);
}

.sync-banner-icon {
  width: 32px; height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, oklch(72% 0.13 60) 30%, var(--bg));
  color: color-mix(in oklab, oklch(40% 0.12 60) 80%, var(--fg));
  flex-shrink: 0;
}
.sync-banner-error .sync-banner-icon {
  background: color-mix(in oklab, oklch(60% 0.16 28) 26%, var(--bg));
  color: color-mix(in oklab, oklch(40% 0.16 28) 80%, var(--fg));
}
.sync-banner-icon svg { display: block; }

.sync-banner-body { min-width: 0; }
.sync-banner-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 2px;
}
.sync-banner-sub {
  font-size: 12px;
  color: color-mix(in oklab, var(--fg) 72%, var(--bg) 28%);
  line-height: 1.35;
}
.sync-banner-cta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: color-mix(in oklab, var(--fg) 70%, var(--bg) 30%);
  white-space: nowrap;
  padding-right: 4px;
}
.sync-banner-x {
  position: absolute;
  top: 4px;
  right: 6px;
  appearance: none;
  background: transparent;
  border: none;
  color: color-mix(in oklab, var(--fg) 55%, var(--bg));
  font-family: inherit;
  font-size: 16px;
  line-height: 1;
  width: 22px; height: 22px;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 120ms ease, color 120ms ease;
}
.sync-banner-x:hover {
  background: color-mix(in oklab, var(--fg) 8%, transparent);
  color: var(--fg);
}
@media (max-width: 380px) {
  .sync-banner { grid-template-columns: auto 1fr; }
  .sync-banner-cta { display: none; }
}

.settings-sheet { }
.settings-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.set-section h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.set-section-danger h3 { color: oklch(50% 0.16 25); }
.set-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 8px 0 6px;
}
.set-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.set-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.set-btn {
  appearance: none;
  flex: 1 1 0;
  min-width: 130px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.set-btn:hover { background: var(--bg); border-color: var(--fg); }
.set-btn.danger {
  color: oklch(50% 0.16 25);
  border-color: color-mix(in oklab, oklch(60% 0.18 25) 40%, transparent);
  background: color-mix(in oklab, oklch(60% 0.18 25) 6%, var(--card));
}
.set-btn.danger:hover {
  background: color-mix(in oklab, oklch(60% 0.18 25) 14%, var(--card));
  border-color: oklch(60% 0.18 25);
}

.set-radio-row {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}
.set-radio {
  appearance: none;
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 120ms ease;
}
.set-radio:hover { color: var(--fg); }
.set-radio.active {
  background: var(--fg);
  color: var(--bg);
}

.set-palettes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.set-palette {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: var(--card);
  color: var(--fg);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  font-family: inherit;
  transition: all 120ms ease;
}
.set-palette:hover { border-color: var(--border); }
.set-palette.active {
  border-color: var(--fg);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--fg) inset;
}
.set-swatch {
  width: 14px; height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.set-palette-lbl {
  font-size: 13px;
  font-weight: 500;
  margin-left: 4px;
}

.set-toggle-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.set-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
}
.set-toggle input[type="checkbox"] {
  appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  background: var(--bg);
  flex-shrink: 0;
}
.set-toggle input[type="checkbox"]:checked {
  background: var(--fg);
  border-color: var(--fg);
}
.set-toggle input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 2px; left: 5px;
  width: 4px; height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Sync control: tweak a few things now that it lives in the bigger sheet */
.set-section .sync-ctrl {
  font-size: 13px;
}
.set-section .sync-token-wrap {
  background: var(--card);
  padding: 10px 14px;
}
.set-section .sync-token-lbl { font-size: 11px; }
.set-section .sync-token-val { font-size: 12px; }
.set-section .sync-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 10px;
}
.set-section .sync-btn:hover { background: var(--bg); border-color: var(--fg); }
.set-section .sync-btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.set-section .sync-hint { color: var(--muted); font-size: 11.5px; }
.set-section .sync-input {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 12px;
}

/* ——————————————————————————————————————————————————————————————
   Weekly summary
   —————————————————————————————————————————————————————————————— */
.week-cta-wrap {
  padding: 8px 20px 0;
}
.week-cta {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--fg);
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease, transform 100ms ease;
}
.week-cta:hover {
  background: var(--card);
  border-color: var(--border);
}
.week-cta:active { transform: scale(0.99); }
.week-cta-main { display: flex; flex-direction: column; gap: 3px; }
.week-cta-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  line-height: 1;
}
.week-cta-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.week-cta-arrow {
  font-size: 28px;
  color: var(--muted);
  line-height: 1;
}

/* Overlay */
.ws-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 0 calc(80px + env(safe-area-inset-bottom));
  animation: ws-in 280ms cubic-bezier(.2,.7,.2,1);
}
@keyframes ws-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (min-width: 481px) {
  .ws-overlay {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 28px;
    inset: 24px auto 24px auto;
    height: calc(100vh - 48px);
    box-shadow: 0 24px 80px -32px color-mix(in oklab, var(--fg) 50%, transparent);
  }
}

.ws-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 20px 20px;
}
.ws-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ws-range {
  margin-top: 2px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.ws-close {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  width: 38px; height: 38px;
  border-radius: 999px;
  font-size: 22px;
  cursor: pointer;
}
.ws-close:hover { background: var(--card); }

.ws-bigstats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 20px 8px;
}
.ws-stat {
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
}
.ws-stat-val {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.ws-stat-val span {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  margin-left: 1px;
}
.ws-stat-lbl {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.ws-stat-warn {
  background: color-mix(in oklab, oklch(70% 0.10 50) 14%, var(--card));
  border-color: color-mix(in oklab, oklch(70% 0.10 50) 30%, transparent);
}

.ws-section { padding: 24px 20px 4px; }
.ws-section h3 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
}

/* Nutrient bars */
.ws-bars { display: flex; flex-direction: column; gap: 8px; }
.ws-bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 84px;
  align-items: center;
  gap: 10px;
}
.ws-bar-lbl {
  font-size: 12.5px;
  font-weight: 500;
}
.ws-bar-track {
  position: relative;
  height: 8px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}
.ws-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 480ms cubic-bezier(.2,.7,.2,1);
}
.ws-bar-100 {
  position: absolute;
  top: -3px; bottom: -3px;
  left: calc(100% * (100 / 130));
  /* Hide the marker — full bar = 130% range; calculate to 100% mark */
  display: none;
}
.ws-bar-val {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.ws-bar-pct { color: var(--fg); font-weight: 500; }
.ws-bar-num { color: var(--muted); white-space: nowrap; font-size: 10px; }
.ws-bar-num span { margin-left: 1px; }

/* Symptom list */
.ws-sym-list { display: flex; flex-direction: column; gap: 6px; }
.ws-sym {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 6px 12px;
  padding: 10px 14px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}
.ws-sym-name {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  grid-column: 1;
}
.ws-sym-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}
.ws-sym-sev {
  grid-column: 1;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-left: 14px;
}

/* Day-by-day */
.ws-days { display: flex; flex-direction: column; gap: 6px; }
.ws-day {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  align-items: center;
}
.ws-day.empty { opacity: 0.55; }
.ws-day-date { display: flex; flex-direction: column; gap: 0; }
.ws-day-wk {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.ws-day-d {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}
.ws-day-body { min-width: 0; }
.ws-day-empty { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.ws-day-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.ws-day-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 7px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  color: var(--fg);
}
.ws-day-pill-sym {
  border-color: color-mix(in oklab, oklch(62% 0.12 25) 30%, transparent);
  background: color-mix(in oklab, oklch(62% 0.12 25) 8%, var(--bg));
}
.ws-day-pill-met {
  border-color: color-mix(in oklab, var(--accent) 30%, transparent);
  background: color-mix(in oklab, var(--accent) 8%, var(--bg));
}
.ws-day-dots {
  display: flex;
  gap: 4px;
}
.ws-day-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Most logged */
.ws-foods { display: flex; flex-direction: column; gap: 4px; }
.ws-food {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 14px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.ws-food-name { font-size: 13px; font-weight: 500; }
.ws-food-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* Copy section */
.ws-copy-section { padding-top: 24px; }
.ws-copy-hint {
  margin: -6px 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}
.ws-copy-btn {
  appearance: none;
  width: 100%;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 13px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.ws-copy-btn:hover { transform: translateY(-1px); }
.ws-copy-btn.ok {
  background: color-mix(in oklab, var(--accent) 80%, var(--fg));
  border-color: color-mix(in oklab, var(--accent) 80%, var(--fg));
  color: var(--bg);
}
.ws-text {
  margin: 12px 0 0;
  padding: 14px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

.ws-foot {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top,
    var(--bg) 40%,
    color-mix(in oklab, var(--bg) 80%, transparent) 80%,
    transparent);
}
.ws-foot-close {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
}
.ws-foot-close:hover { background: var(--bg); border-color: var(--fg); }

/* ——————————————————————————————————————————————————————————————
   Add sheet
   —————————————————————————————————————————————————————————————— */
.sheet-scrim {
  position: fixed; inset: 0;
  background: color-mix(in oklab, var(--fg) 50%, transparent);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadein 200ms ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 480px;
  height: 85dvh;
  max-height: 85dvh;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 8px 0 24px;
  display: flex;
  flex-direction: column;
  animation: slideup 280ms cubic-bezier(.2,.7,.2,1);
  overflow: hidden;
  position: relative;
}
@keyframes slideup {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-grip {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: 6px auto 12px;
  flex-shrink: 0;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 12px;
  flex-shrink: 0;
}
.sheet-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
}
.sheet-close, .sheet-back, .sheet-confirm {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}
.sheet-close:hover, .sheet-back:hover { background: var(--card); color: var(--fg); }
.sheet-confirm {
  background: var(--fg);
  color: var(--bg);
  font-weight: 500;
  padding: 8px 14px;
}
.sheet-confirm:hover { background: color-mix(in oklab, var(--fg) 85%, var(--accent)); }

.sheet-head-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sheet-link {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in oklab, var(--muted) 50%, transparent);
}
.sheet-link:hover { color: var(--fg); text-decoration-color: var(--fg); }

/* Portion guide popover */
.guide {
  position: absolute;
  inset: 0;
  background: color-mix(in oklab, var(--fg) 30%, transparent);
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  animation: fadein 160ms ease;
  backdrop-filter: blur(2px);
}
.guide-inner {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 380px;
  padding: 16px 18px 18px;
  box-shadow: 0 24px 60px -20px color-mix(in oklab, var(--fg) 50%, transparent);
}
.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.guide-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
}
.guide-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
}
.guide-close:hover { background: var(--card); color: var(--fg); }

.guide-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.guide-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.guide-row:last-child { border-bottom: none; }
.guide-hand {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  color: var(--fg);
  align-self: center;
}
.guide-mid { display: flex; flex-direction: column; gap: 2px; }
.guide-approx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg);
}
.guide-use {
  font-size: 11px;
  color: var(--muted);
}

.search-wrap { padding: 0 20px 12px; flex-shrink: 0; }
.search {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--fg);
  outline: none;
  transition: border-color 120ms ease;
}
.search:focus {
  border-color: var(--fg);
}
.search::placeholder { color: var(--muted-2); }

.cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 20px 12px;
  flex-shrink: 0;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  appearance: none;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 120ms ease;
}
.cat:hover { color: var(--fg); border-color: var(--border); }
.cat.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.results {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.result {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--fg);
  transition: background 120ms ease, border-color 120ms ease;
}
.result:hover {
  background: var(--card);
  border-color: var(--border);
}
.result-main { flex: 1; min-width: 0; }
.result-name { font-size: 14px; font-weight: 500; }
.result-sub {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.result-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 999px;
  flex-shrink: 0;
}
.empty {
  text-align: center;
  padding: 32px 12px;
  color: var(--muted);
  font-style: italic;
}

/* Portion picker */
.portion {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: 8px;
}
.portion-card {
  margin: 0 20px 16px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  text-align: center;
}
.portion-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 26px;
  line-height: 1.1;
}
.portion-portion {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.portion-quick {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pq {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 50px;
}
.pq.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.portion-fine {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.portion-fine button {
  appearance: none;
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 18px;
  cursor: pointer;
}
.portion-num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 32px;
  min-width: 60px;
  text-align: center;
}
.portion-hint {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.portion-nutri {
  margin: 0 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.pn {
  padding: 8px 12px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.pn-lbl {
  font-size: 12px;
  color: var(--muted);
}
.pn-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}
.pn-val span {
  margin-left: 2px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}
