/* ============================================================
   LAR Recovery Tracker — mobile-first one-handed design system
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a1322;
  --bg-2:      #0f1b30;
  --surf:      #15233b;
  --surf-hi:   #1c2e4c;
  --line:      #233655;
  --ink:       #eaf2ff;
  --ink-dim:   #9fb1ce;
  --ink-mute:  #6b7e9e;
  --pri:       #4c8cff;
  --pri-soft:  #4c8cff22;
  --pri-ring:  #4c8cff66;
  --warn:      #f4c542;
  --bad:       #ff6b6b;
  --good:      #34d27a;
  --bm:        #4c8cff;
  --food:      #34d27a;
  --ost:       #d27a4c;
  --hp:        #c084fc;

  --radius:    16px;
  --radius-sm: 12px;
  --tab-h:     74px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-t:    env(safe-area-inset-top, 0px);

  /* legacy compatibility */
  --surface:   #15233b;
  --surface2:  #1c2e4c;
  --border:    #233655;
  --text:      #eaf2ff;
  --text2:     #9fb1ce;
  --text3:     #6b7e9e;
  --accent:    #4c8cff;
  --accent-dark: #3a78ea;
  --green:     #34d27a;
  --red:       #ff6b6b;
  --yellow:    #f4c542;
  --nav-h:     calc(74px + env(safe-area-inset-bottom, 0px));
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--pri); text-decoration: none; }
ol, ul { list-style: none; margin: 0; padding: 0; }

/* ===== Page shell ===== */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 20px calc(var(--tab-h) + 36px + var(--safe-b));
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===== Top bar ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  margin-bottom: 14px;
}
.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.page-header .back {
  width: 44px; height: 44px; border-radius: 14px;
  display: inline-grid; place-items: center;
  background: var(--surf); color: var(--ink);
  transition: transform .12s ease, background .12s ease;
  flex: none;
}
.page-header .back:active { transform: scale(.94); background: var(--surf-hi); }
.page-header .back svg { width: 20px; height: 20px; }

.iconbtn {
  width: 44px; height: 44px; border-radius: 14px;
  display: inline-grid; place-items: center;
  background: var(--surf); color: var(--ink);
  transition: transform .12s ease, background .12s ease;
  flex: none;
}
.iconbtn:active { transform: scale(.94); background: var(--surf-hi); }
.iconbtn--pri { background: var(--pri); color: #fff; }
.iconbtn--pri:active { background: var(--accent-dark); }

/* ===== Day strip (timeline) ===== */
.daystrip {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: 4px; margin: 4px 0 18px;
}
.daycell {
  display: grid; place-items: center; gap: 2px;
  padding: 8px 0; border-radius: 12px;
  color: var(--ink-dim);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  transition: background .12s ease, color .12s ease;
  text-decoration: none;
}
.daycell b { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: 0; text-transform: none; }
.daycell.is-on { background: var(--pri); color: #fff; }
.daycell.is-on b { color: #fff; }
.daycell .ddot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .4; }
.daycell .ddot.has { opacity: 1; }
.daycell:not(.is-on):active { background: var(--surf); }

/* ===== Glance card ===== */
.glance {
  background: linear-gradient(135deg, #1a2c4d 0%, #142441 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.glance__eyebrow { font-size: 11px; color: var(--ink-mute); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.glance__big { margin-top: 6px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.glance__num { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.glance__unit { font-size: 14px; color: var(--ink-dim); margin-right: 8px; }
.glance__dot { color: var(--ink-mute); margin: 0 4px; }
.glance__chips { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.metric {
  display: inline-flex; flex-direction: column; gap: 1px;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(255,255,255,.04);
}
.metric__label { font-size: 11px; color: var(--ink-mute); }
.metric__val { font-size: 15px; font-weight: 700; }

/* ===== Cards ===== */
.card {
  background: var(--surf);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card-sm { background: var(--surf); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; }
.card__title { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card__head .card__title, .card__head h2 { margin: 0; font-size: 16px; font-weight: 700; }

/* ===== Timeline entries ===== */
.bucket {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-mute); padding: 14px 4px 6px;
}
.timeline-entry,
.entry {
  position: relative;
  background: var(--surf);
  border-radius: var(--radius);
  padding: 14px 16px 14px 18px;
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 10px;
  overflow: hidden;
}
.timeline-entry::before,
.entry::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent-bar, var(--pri));
}
.entry-bm,   .entry--bm   { --accent-bar: var(--bm); }
.entry-food, .entry--food { --accent-bar: var(--food); }
.entry-ostomy, .entry--ost { --accent-bar: var(--ost); }
.entry-hydration { --accent-bar: #06b6d4; }
.entry-medication { --accent-bar: var(--hp); }
.entry-stress { --accent-bar: var(--bad); }
.entry-sleep { --accent-bar: #6366f1; }

.entry__row { display: flex; align-items: center; gap: 12px; }
.entry__ico {
  width: 36px; height: 36px; flex: none;
  border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in oklab, var(--accent-bar) 18%, transparent);
  font-size: 18px;
}
.entry__body { flex: 1; min-width: 0; }
.entry__title, .entry-title {
  font-weight: 700; font-size: 16px; line-height: 1.2;
}
.entry__meta, .entry-detail {
  font-size: 13px; color: var(--ink-dim); margin-top: 2px;
}
.entry__time, .entry-time {
  font-size: 12px; color: var(--ink-mute); font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.entry-alert {
  color: var(--bad); font-size: 12px; font-weight: 700; margin-top: 6px;
}
.entry__tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.06); color: var(--ink-dim);
}
.tag-bm { background: color-mix(in oklab, var(--bm) 18%, transparent); color: #b8d0ff; }
.tag-urg { background: color-mix(in oklab, var(--warn) 18%, transparent); color: #ffe28a; }
.tag-meal { background: color-mix(in oklab, var(--food) 18%, transparent); color: #b8efc7; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 18px;
  border-radius: 12px;
  font-weight: 700; font-size: 15px;
  background: var(--surf-hi); color: var(--ink);
  transition: transform .1s ease, background .12s ease, opacity .12s ease;
  border: none;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--pri); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--accent-dark); }
.btn-secondary { background: var(--surf-hi); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--line); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-full { width: 100%; }
.btn-lg { height: 54px; font-size: 17px; border-radius: 14px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-ghost { background: rgba(255,255,255,.06); color: var(--ink); }

/* ===== Inputs ===== */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  font-size: 16px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--pri); box-shadow: 0 0 0 4px var(--pri-soft);
}
.textarea { resize: vertical; min-height: 72px; }

.label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-dim); margin-bottom: 8px;
  letter-spacing: .01em;
}
.field { margin-bottom: 18px; }
.field-help { font-size: 12px; color: var(--ink-mute); margin-top: 6px; }
.input-row { display: flex; gap: 8px; }
.input-row .input, .input-row .select { flex: 1; }

/* ===== Log picker grid ===== */
.log-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.log-btn {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surf);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform .12s ease, background .12s ease;
  min-height: 140px;
  justify-content: flex-end;
}
.log-btn:active { transform: scale(.97); background: var(--surf-hi); }
.log-btn::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent-bar, var(--pri));
}
.log-btn[data-kind="bm"]   { --accent-bar: var(--bm); }
.log-btn[data-kind="ost"]  { --accent-bar: var(--ost); }
.log-btn[data-kind="food"] { --accent-bar: var(--food); }
.log-btn[data-kind="hp"]   { --accent-bar: var(--hp); }
.log-btn-icon {
  font-size: 28px; line-height: 1;
  width: 48px; height: 48px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--accent-bar) 18%, transparent);
}
.log-btn-label { font-weight: 700; font-size: 17px; color: var(--ink); }
.log-btn-sub   { font-size: 12px; color: var(--ink-mute); }

/* ===== Bristol picker (new visual) ===== */
.bristol-pick {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  margin-top: 8px;
}
.bristol-pick__btn {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--surf);
  display: grid; place-items: center; gap: 2px;
  font-size: 13px; font-weight: 800; color: var(--ink-dim);
  position: relative;
  transition: transform .1s ease, background .12s ease;
  border: 0; cursor: pointer;
}
.bristol-pick__btn:active { transform: scale(.94); }
.bristol-pick__btn.is-on { background: var(--pri); color: #fff; box-shadow: 0 0 0 3px var(--pri-ring); }
.bristol-pick__shape { width: 26px; height: 14px; display: block; }
.bristol-pick__num { font-size: 11px; opacity: .85; line-height: 1; }
.bristol-pick__hint { font-size: 12px; color: var(--ink-mute); text-align: center; margin-top: 10px; min-height: 18px; }

/* ===== Legacy bristol-grid (kept for fallback) ===== */
.bristol-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 8px; }
.bristol-item {
  aspect-ratio: 1; border-radius: 12px;
  background: var(--surf);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer;
  transition: background .12s ease, transform .1s ease;
  border: 0;
}
.bristol-item:active { transform: scale(.94); }
.bristol-item.selected { background: var(--pri); box-shadow: 0 0 0 3px var(--pri-ring); }
.bristol-item.selected .bristol-num { color: #fff; }
.bristol-num { font-size: 14px; font-weight: 800; color: var(--ink); }
.bristol-emoji { font-size: 14px; }

/* ===== Dot scales ===== */
.dots {
  display: flex; gap: 6px; margin-top: 8px;
}
.dots .d {
  flex: 1; height: 44px;
  border-radius: 10px;
  background: var(--surf);
  position: relative;
  transition: background .12s ease, transform .1s ease;
  border: 0; cursor: pointer;
}
.dots .d:active { transform: scale(.96); }
.dots .d.is-on { background: var(--pri); }
.dots--ten .d { height: 36px; border-radius: 8px; }
.scale-label { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.scale-label__val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.scale-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-mute); margin-top: 6px; }

/* ===== Legacy slider (kept for /log-more.html etc) ===== */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 6px; background: var(--surf); border-radius: 999px;
  outline: none; accent-color: var(--pri);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px;
  border-radius: 50%; background: var(--pri);
  border: 4px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: var(--pri);
  border: 3px solid #fff;
}
.slider-val { min-width: 28px; text-align: center; font-weight: 800; color: var(--pri); }

/* ===== Toggle / checkbox row ===== */
.checkbox-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surf);
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 8px;
  font-weight: 600;
}
.checkbox-row input[type=checkbox] {
  width: 22px; height: 22px;
  accent-color: var(--pri); cursor: pointer;
  flex: none;
}
.checkbox-label { font-size: 15px; }

/* Tog chips (pill-style multi-select) */
.togs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.tog {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 999px;
  background: var(--surf);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.tog input { position: absolute; opacity: 0; pointer-events: none; }
.tog:has(input:checked) { background: var(--pri); color: #fff; }
.tog.is-on { background: var(--pri); color: #fff; }

/* ===== Volume preset chips ===== */
.vol-presets, .volrow { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.vol-preset, .vol {
  flex: 1; min-width: 60px;
  height: 48px; padding: 0 14px;
  background: var(--surf); border-radius: 12px;
  font-weight: 700; font-size: 15px; color: var(--ink);
  transition: transform .1s ease, background .12s ease;
  border: 0; cursor: pointer;
}
.vol-preset:active, .vol:active { transform: scale(.96); }
.vol-preset.selected, .vol-preset.is-on,
.vol.is-on { background: var(--pri); color: #fff; box-shadow: 0 0 0 3px var(--pri-ring); }

/* ===== Consistency list ===== */
.consist-item, .cons {
  display: block; width: 100%;
  padding: 14px 16px;
  background: var(--surf); border-radius: 12px;
  text-align: left;
  transition: background .12s ease, transform .1s ease;
  border: 0; cursor: pointer;
  margin-bottom: 6px;
}
.consist-item:active, .cons:active { transform: scale(.99); }
.consist-item.selected, .cons.is-on {
  background: var(--pri); color: #fff;
}
.consist-name, .cons b { display: block; font-size: 15px; font-weight: 700; }
.consist-hint, .cons span { display: block; font-size: 12px; opacity: .75; margin-top: 2px; }

/* ===== Color picker ===== */
.color-grid, .colors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.color-item, .cdot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--surf); border-radius: 12px;
  font-weight: 600; font-size: 14px;
  transition: background .12s ease;
  border: 0; cursor: pointer;
  color: var(--ink);
  text-align: left;
}
.color-item .color-swatch,
.cdot span:first-child {
  width: 18px; height: 18px; border-radius: 999px;
  border: 2px solid rgba(255,255,255,.1);
  flex: none;
}
.color-item.selected, .cdot.is-on { background: var(--pri); color: #fff; }
.color-item.alert-color { color: var(--bad); }
.color-item.alert-color.selected { background: rgba(255,107,107,.18); color: var(--bad); box-shadow: inset 0 0 0 2px rgba(255,107,107,.4); }
.cdot.alert-color { color: var(--bad); }
.cdot.alert-color.is-on { background: rgba(255,107,107,.18); color: var(--bad); box-shadow: inset 0 0 0 2px rgba(255,107,107,.4); }

/* ===== Bag toggle ===== */
.bag-toggle {
  width: 100%;
  padding: 14px 16px;
  background: var(--surf); border-radius: 12px;
  font-size: 15px; font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  border: 0;
  transition: background .12s ease;
}
.bag-toggle.selected { background: var(--good); color: #042818; }

/* ===== Skin grid (segmented) ===== */
.skin-grid, .segctl--full {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.skin-item {
  padding: 12px 4px;
  background: var(--surf); border-radius: 10px;
  font-size: 13px; font-weight: 700;
  color: var(--ink-dim);
  cursor: pointer; border: 0;
  transition: background .12s ease, color .12s ease;
}
.skin-item.selected-none { background: var(--good); color: #042818; }
.skin-item.selected-warn { background: var(--warn); color: #1a1100; }

/* ===== Alert boxes ===== */
.alert-box {
  background: color-mix(in oklab, var(--bad) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--bad) 40%, transparent);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px; color: #ffb1b1;
  margin-top: 12px;
}
.high-output-warn {
  background: color-mix(in oklab, var(--warn) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px; color: #ffe28a;
  margin-top: 8px;
}

/* ===== Tabs ===== */
.tab-bar {
  display: flex;
  background: var(--surf);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 14px;
  border-radius: 9px;
  background: none;
  color: var(--ink-dim);
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
  border: 0; cursor: pointer;
}
.tab.active { background: var(--pri); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 640px;
  margin: 0 auto;
  height: calc(74px + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(10, 19, 34, .94);
  backdrop-filter: saturate(140%) blur(20px);
  -webkit-backdrop-filter: saturate(140%) blur(20px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 100;
}
.nav-item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  color: var(--ink-mute);
  font-size: 11px; font-weight: 600;
  text-decoration: none;
  height: 74px;
  transition: color .12s ease;
  position: relative;
}
.nav-item.active { color: var(--pri); }
.nav-item:active:not(.active) { color: var(--ink-dim); }
.nav-icon { font-size: 22px; line-height: 1; display: grid; place-items: center; height: 22px; }
.nav-item--fab {
  color: transparent;
  pointer-events: none;
}
.fab {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(50% - 8px);
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--pri); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 14px 30px -8px rgba(76, 140, 255, .55), 0 0 0 4px var(--bg);
  z-index: 101;
  transition: transform .12s ease;
  border: 0; cursor: pointer;
  pointer-events: auto;
  text-decoration: none;
}
.fab:active { transform: translateX(-50%) scale(.94); }
.fab svg { width: 26px; height: 26px; }

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  bottom: calc(74px + 16px + var(--safe-b));
  left: 50%; transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
  width: calc(min(100vw, 640px) - 32px);
}
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  animation: toast-in .2s ease;
  pointer-events: auto;
  background: #fff; color: #0a1322;
  box-shadow: 0 12px 28px rgba(0,0,0,.4);
}
.toast-success { background: var(--good); color: #042818; }
.toast-error { background: var(--bad); color: #2a0808; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Empty / spinner ===== */
.empty {
  text-align: center; color: var(--ink-mute);
  padding: 48px 20px; font-size: 14px;
}
.empty-icon { font-size: 36px; margin-bottom: 10px; }
.spinner {
  border: 3px solid var(--surf-hi);
  border-top-color: var(--pri);
  border-radius: 50%;
  width: 26px; height: 26px;
  animation: spin .6s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Insights ===== */
.insight-section { margin-bottom: 20px; }
.insight-section h3 {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-mute); margin-bottom: 10px;
}
.insight-card {
  background: var(--surf);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 14px;
}
.impact-high { color: var(--bad); }
.impact-medium { color: var(--warn); }
.impact-low { color: var(--good); }

/* ===== LARS score ===== */
.lars-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; }
.score-display {
  text-align: center; padding: 8px 0 16px;
}
.score-num { font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; color: var(--good); }
.score-label { font-size: 14px; font-weight: 600; color: var(--ink-dim); margin-top: 4px; }
.score-note { font-size: 12px; color: var(--ink-mute); text-align: center; margin-top: 6px; }

/* Nutrition grid (also used by LARS breakdown) */
.nut-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; margin-top: 12px;
}
.nut-item { background: rgba(255,255,255,.04); border-radius: 10px; padding: 10px 4px; text-align: center; }
.nut-val { font-weight: 800; font-size: 16px; }
.nut-label { font-size: 11px; color: var(--ink-mute); margin-top: 2px; }
.nut-grid--5 { grid-template-columns: repeat(5, 1fr); }

/* ===== Settings rows ===== */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: 0; }
.setting-label { font-weight: 600; }
.setting-sub { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.badge-blue   { background: color-mix(in oklab, var(--pri) 22%, transparent); color: #b8d0ff; }
.badge-green  { background: color-mix(in oklab, var(--good) 22%, transparent); color: #b8efc7; }
.badge-red    { background: color-mix(in oklab, var(--bad) 22%, transparent); color: #ffb1b1; }
.badge-yellow { background: color-mix(in oklab, var(--warn) 22%, transparent); color: #ffe28a; }
.badge-gray   { background: rgba(255,255,255,.06); color: var(--ink-dim); }

/* ===== Recipes list ===== */
.recipe-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surf); border-radius: var(--radius);
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}
.recipe-thumb {
  width: 48px; height: 48px; flex: none; border-radius: 12px;
  background: linear-gradient(135deg, #2a3e64, #1b2a47);
  display: grid; place-items: center; font-size: 22px;
}
.recipe-name { font-weight: 700; font-size: 16px; }
.recipe-meta { font-size: 13px; color: var(--ink-dim); margin-top: 2px; }
.recipe-chev { color: var(--ink-mute); margin-left: auto; flex: none; }

/* ===== Modal ===== */
.modal-scrim[hidden] { display: none; }
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .65);
  z-index: 200; padding: 0;
  display: flex; align-items: flex-end; justify-content: center;
  overflow-y: auto;
}
.modal {
  width: 100%; max-width: 640px;
  background: var(--bg-2);
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  padding: 20px 20px calc(20px + var(--safe-b));
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal__grab {
  width: 38px; height: 4px; background: var(--ink-mute); opacity: .5;
  border-radius: 2px; margin: -4px auto 12px;
}
.modal__title {
  font-size: 18px; font-weight: 700; margin: 0 0 12px;
}

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-box { width: 100%; max-width: 360px; }
.login-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--pri) 22%, transparent);
  display: grid; place-items: center;
  font-size: 28px;
  margin: 0 auto 24px;
}
.login-title { font-size: 26px; font-weight: 800; text-align: center; margin-bottom: 6px; letter-spacing: -0.02em; }
.login-sub { font-size: 14px; color: var(--ink-mute); text-align: center; margin-bottom: 28px; }
.pin-input { text-align: center; font-size: 24px; letter-spacing: .4em; padding: 16px; font-weight: 800; }

/* ===== Divider ===== */
.divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ===== Utilities ===== */
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--ink-mute); }
.text-danger { color: var(--bad); }
.text-success { color: var(--good); }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ===== Bars / charts (for insights) ===== */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; }
.bars__bar { background: linear-gradient(to top, var(--pri), #7eafff); border-radius: 6px 6px 2px 2px; min-height: 4px; }
.bars__bar.flag { background: linear-gradient(to top, var(--warn), #ffe28a); }
.bars__legend { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 6px; text-align: center; color: var(--ink-mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.spark { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; align-items: end; height: 80px; }
.spark__b { background: var(--surf-hi); border-radius: 3px; min-height: 4px; }
.spark__b.hot { background: var(--bad); }
.spark__b.warn { background: var(--warn); }

/* ===== Login shake ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.shake { animation: shake .4s ease; }
