:root {
  --bg: #f2f3f1;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --text: #1a1d1b;
  --muted: #69716c;
  --line: #e0e3de;
  --accent: #2f7d5b;
  --accent-ink: #ffffff;
  --brand: #2f7d5b;
  --brand-ink: #ffffff;
  --protein: #c2582f;
  --carbs: #3b6fb6;
  --fat: #b08a1c;
  --fiber: #6b8f3a;
  --water: #2f8fbf;
  --over: #c2412f;
  --sugar: #b0418a;
  --radius: 14px;
  --nav-h: 64px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1110;
    --surface: #161b19;
    --surface-2: #1f2623;
    --text: #e9ece9;
    --muted: #96a19a;
    --line: #27302c;
    --accent: #5cc496;
    --accent-ink: #08120d;
    --brand: #1d5640;
    --brand-ink: #ffffff;
    --protein: #e8875e;
    --carbs: #78a6e8;
    --fat: #e0be55;
    --fiber: #9ec46a;
    --water: #63bde6;
    --over: #f07a6a;
    --sugar: #e07ab8;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  overscroll-behavior-y: none;
}
h1 { font-size: 17px; margin: 0; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0; }
a { color: var(--accent); }
code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.credit { font-size: 12px; text-align: center; }

/* ---------- header (brand bar, like a native app) ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--brand); color: var(--brand-ink);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 8px;
}
.top-row { display: flex; align-items: center; justify-content: center; min-height: 26px; }
.datebar { display: flex; align-items: center; gap: 6px; margin: 6px auto 0; max-width: 520px; }
.datebar[hidden] { display: none; }
.datebar .icon { background: transparent; border: 0; color: inherit; font-size: 26px; width: 44px; height: 40px; }
.date-pick { flex: 1; position: relative; text-align: center; font-size: 16px; font-weight: 600; color: inherit; cursor: pointer; padding: 8px 0; }
.date-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

main { max-width: 720px; margin: 0 auto; padding: 12px; }
.tab { display: flex; flex-direction: column; gap: 12px; }
.tab[hidden] { display: none; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span2 { grid-column: 1 / -1; }

/* ---------- controls ---------- */
/* 16px+ inputs stop iOS from zooming the page on focus. */
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input[type="search"] { flex: 1; }
button, .button {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap;
  touch-action: manipulation;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost, .button.ghost { background: transparent; }
button.link { background: none; border: 0; color: var(--accent); padding: 8px 0; min-height: 40px; font-weight: 700; letter-spacing: 0.02em; font-size: 14px; }
button.small { padding: 4px 10px; min-height: 34px; font-size: 13px; }
button.danger { color: var(--over); }
button:disabled { opacity: 0.45; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); padding: 2px; gap: 2px; }
.seg button { border: 0; border-radius: 8px; padding: 6px 12px; min-height: 34px; font-size: 13px; background: transparent; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.full { display: flex; }
.seg.full button { flex: 1; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; align-items: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottom-nav { grid-template-columns: 1fr 1fr 76px 1fr 1fr; }
.bottom-nav button {
  background: none; border: 0; border-radius: 0; min-height: 0; height: 100%; padding: 6px 0 4px;
  display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600;
}
.bottom-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button[aria-selected="true"] { color: var(--accent); }
.bottom-nav .fab {
  width: 54px; height: 54px; border-radius: 50%; justify-self: center; margin-top: -22px; padding: 0;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px rgb(0 0 0 / 0.22);
}
.bottom-nav .fab svg { width: 28px; height: 28px; stroke-width: 2.4; }

/* ---------- diary ---------- */
.equation { padding: 12px 10px; }
.eq-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 4px 8px; }
.eq-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 2px; }
.eq-row > div { display: flex; flex-direction: column; align-items: center; min-width: 0; flex: 1; }
.eq-row strong { font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.eq-row span { font-size: 11px; color: var(--muted); }
.eq-row i { font-style: normal; color: var(--muted); font-size: 16px; padding-top: 1px; }
.eq-rem strong { color: var(--accent); font-size: 20px; }
.eq-rem.over strong { color: var(--over); }

.summary { display: flex; gap: 16px; align-items: center; }
.ring-wrap { position: relative; width: 96px; flex: none; }
.ring { width: 96px; height: 96px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73; transition: stroke-dashoffset 0.4s ease; }
.ring-fg.over { stroke: var(--over); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.ring-text span { font-size: 11px; color: var(--muted); }
.macros { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.macro .label { display: flex; justify-content: space-between; font-size: 13px; }
.macro .label b { font-weight: 600; }
.bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; border-radius: 4px; transition: width 0.4s ease; }

.meal { padding: 0; overflow: hidden; }
.meal header { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 14px 8px; }
.meal header .kcal { font-variant-numeric: tabular-nums; font-weight: 700; }
.meal ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.meal li, .list li {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); min-height: 56px;
}
.meal footer { padding: 2px 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.item-main { flex: 1; min-width: 0; cursor: pointer; }
.item-main .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main .sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-kcal { font-variant-numeric: tabular-nums; font-weight: 600; }
.meal li:active, .list li:active { background: var(--surface-2); }

.water-row { display: flex; align-items: center; gap: 12px; padding: 4px 14px 14px; }
.cups { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }
.cup { width: 20px; height: 26px; border: 2px solid var(--water); border-top-width: 1px; border-radius: 3px 3px 6px 6px; position: relative; overflow: hidden; }
.cup.full::after { content: ""; position: absolute; inset: 30% 0 0; background: var(--water); }
.water-row .round { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 22px; }

.nudge { display: flex; align-items: center; gap: 12px; justify-content: space-between; border-color: var(--fat); font-size: 14px; }
.nudge[hidden] { display: none; }
.diary-tools { display: flex; gap: 8px; justify-content: center; }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list:empty { display: none; }
.list li:last-child { border-bottom: 0; }
.empty-state { text-align: center; color: var(--muted); padding: 28px 16px; }

/* ---------- progress ---------- */
.weigh { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.chart-card svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-card .axis { fill: var(--muted); font-size: 11px; }
.chart-card .grid { stroke: var(--line); stroke-width: 1; }
.chart-card .line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart-card .avg { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-card .goal { stroke: var(--fat); stroke-width: 1.5; stroke-dasharray: 2 4; }
.chart-card .dot { fill: var(--accent); }
.chart-card .hit { fill: transparent; }
.chart-card .colbar { fill: var(--accent); }
.chart-card .colbar.over { fill: var(--over); }
.chart-card .vlabel { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart-tip { font-size: 13px; color: var(--muted); min-height: 20px; margin-top: 6px; }

/* ---------- sheets (full screen on phones) ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--bg); color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
#modal-body { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 16px; min-height: 100%; }
.sheet-head {
  position: sticky; top: 0; z-index: 2; margin: 0 -16px; padding: 10px 8px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: var(--brand); color: var(--brand-ink);
}
.sheet-head h2 { margin: 0; font-size: 16px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head button { background: transparent; border: 0; color: inherit; min-height: 40px; padding: 6px 10px; }
.sheet-head .end { justify-self: end; }
.sheet-head .start { justify-self: start; font-weight: 500; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.sheet-actions .left { margin-right: auto; }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 4px 2px -4px; }
.pick-list { border: 1px solid var(--line); border-radius: 12px; list-style: none; margin: 0; padding: 0; background: var(--surface); overflow: hidden; }
.pick-list:empty { display: none; }
.pick-list li { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 56px; }
.pick-list li:last-child { border-bottom: 0; }
.pick-list li:hover, .pick-list li:active { background: var(--surface-2); }
.pick-list .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; margin-left: 6px; }
.pick-list .pl-main { min-width: 0; }
.pick-list .pl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-list .pl-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-list .pl-kcal { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; flex: none; }
.pick-list .pl-kcal small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.pick-list .note { cursor: default; color: var(--muted); font-size: 14px; }
.search-row { display: flex; gap: 8px; position: sticky; top: 60px; z-index: 1; background: var(--bg); padding-top: 12px; margin-top: -12px; }
.search-row button { flex: none; }
.food-detail { display: flex; flex-direction: column; gap: 12px; }
.food-detail .big { display: flex; justify-content: space-around; text-align: center; }
.food-detail .big strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.food-detail .big span { font-size: 12px; color: var(--muted); }
.nut-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.recipe-items { display: flex; flex-direction: column; gap: 6px; }
.recipe-items .ri { display: grid; grid-template-columns: 1fr 84px auto; gap: 8px; align-items: center; }
.preview { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.preview-summary { flex: 1; min-width: 180px; font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* camera scanner */
.scanner { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; align-items: center; justify-content: center; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: relative; width: min(78vw, 340px); aspect-ratio: 1.6; border-radius: 16px; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.45); border: 3px solid #fff; overflow: hidden; }
.scan-frame i { position: absolute; left: 6%; right: 6%; height: 2px; background: #ff5a4a; top: 50%; animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { top: 15%; } to { top: 85%; } }
.scan-hint { position: absolute; top: calc(env(safe-area-inset-top) + 28px); left: 0; right: 0; text-align: center; color: #fff; font-weight: 600; margin: 0; }
.scan-close { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 28px); left: 50%; transform: translateX(-50%); background: rgb(255 255 255 / 0.92); color: #000; border: 0; min-width: 140px; }

/* FDA-style nutrition label (always light, like the real thing) */
.nlabel {
  --ink: #000;
  background: #fff; color: var(--ink); border: 1px solid var(--ink); padding: 6px 8px; width: 270px; max-width: 100%;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12.5px; line-height: 1.25;
}
.nlabel .t { font-size: 30px; font-weight: 900; margin: 0 0 2px; letter-spacing: -0.02em; line-height: 1; }
.nlabel .hr { border-top: 1px solid var(--ink); }
.nlabel .hr.thick { border-top-width: 10px; }
.nlabel .hr.mid { border-top-width: 5px; }
.nlabel .r { display: flex; justify-content: space-between; padding: 2px 0; border-top: 1px solid var(--ink); }
.nlabel .r.first { border-top: 0; }
.nlabel .ind { padding-left: 14px; }
.nlabel .cal { display: flex; justify-content: space-between; align-items: flex-end; font-weight: 900; }
.nlabel .cal .k { font-size: 26px; }
.nlabel .cal .n { font-size: 34px; line-height: 1; }
.nlabel .dv { text-align: right; font-weight: 700; font-size: 11px; padding: 2px 0; }
.nlabel .foot { font-size: 9.5px; padding-top: 4px; }
.nlabel b { font-weight: 800; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20;
  opacity: 0; pointer-events: none; transition: 0.2s ease; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 10px;
}
#toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
#toast button { padding: 2px 10px; min-height: 30px; font-size: 13px; background: transparent; color: inherit; border-color: currentColor; }

@media (max-width: 600px) {
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .sheet-head { padding-top: calc(env(safe-area-inset-top) + 8px); }
  .search-row { top: calc(env(safe-area-inset-top) + 58px); }
  #modal-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .nut-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  main { padding-top: 20px; }
}

/* Photos and pending calories (meals imported from the old diary) */
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; margin-right: 10px; }
.pending { color: var(--over); font-weight: 600; }
.entry-photo { display: block; width: 100%; max-height: 50vh; object-fit: cover; border-radius: 14px; margin-bottom: 12px; }
.entry-note { white-space: pre-line; font-size: 13.5px; }

/* Header buttons: craving swaps and the food coach */
.top-row { position: relative; }
.top-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgb(255 255 255 / 0.16); color: var(--brand-ink); border: 0; border-radius: 999px; padding: 4px 12px; min-height: 34px; font-size: 13px; font-weight: 700; }
.top-btn.left { left: 0; }
.top-btn.right { right: 0; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; min-height: 36px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Mood */
.mood-box summary { font-weight: 700; cursor: pointer; padding: 4px 0; }
.mood-box[open] summary { margin-bottom: 6px; }
.mini-label .muted { text-transform: none; font-weight: 500; }
.mini-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 12px 0 6px; }
.mood-row { display: flex; justify-content: space-between; gap: 6px; }
.mood-row button { flex: 1; min-width: 0; padding: 0; font-size: 26px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); filter: grayscale(0.6); opacity: 0.75; }
.mood-row button[aria-pressed="true"] { filter: none; opacity: 1; border-color: var(--accent); background: var(--surface-2); box-shadow: 0 0 0 2px var(--accent) inset; }
.mood-tag { font-size: 14px; }
.mood-counts { display: flex; justify-content: space-between; margin: 10px 0 14px; }
.mood-counts div { display: flex; flex-direction: column; align-items: center; font-size: 22px; }
.mood-counts b { font-size: 14px; }
.mood-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 10px; }
.mood-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.mood-table td { border-top: 1px solid var(--line); padding: 8px 0; vertical-align: top; }
.mood-table td:not(:first-child), .mood-table th:not(:first-child) { text-align: right; width: 64px; }
.mood-table .muted { font-size: 12.5px; }

/* Food coach chat */
.coach { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: calc(100dvh - 300px); min-height: 160px; padding: 4px 2px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.msg p { margin: 0 0 6px; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ul { margin: 4px 0 6px; padding-left: 20px; }
.msg li { margin: 2px 0; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.user .muted { color: inherit; opacity: 0.8; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.md-table { overflow-x: auto; margin: 6px 0; }
.md-table table { border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
.typing { display: flex; gap: 4px; padding: 14px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-starters .chip { font-size: 13.5px; text-align: left; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.chat-input button { min-height: 44px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; cursor: pointer; }
.photo-preview { display: flex; align-items: center; gap: 12px; }
.photo-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
label.share-row { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; font-size: 14px; color: var(--text); }
.chips[hidden], .photo-preview[hidden] { display: none; }
.share-row input { width: 20px; height: 20px; }
.coach-note { font-size: 12px; margin: 0; }

/* Craving swaps */
.crave { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.swap-list li { align-items: flex-start; gap: 10px; }
.swap-list .sub { white-space: normal; }
.swap-list .why { font-size: 13.5px; margin: 3px 0; }
.fit { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.fit.ok { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.fit.over { background: color-mix(in srgb, var(--over) 14%, transparent); color: var(--over); }
.full-btn { width: 100%; }

/* Photos on entries */
.add-photo { width: 100%; margin-bottom: 12px; border-style: dashed; }
.photo-actions { margin: -4px 0 12px; }
.snap-preview { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.snap-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; flex: none; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
#mode-seg button { padding-left: 4px; padding-right: 4px; }

/* Blood pressure */
.bp-avg { padding: 0 14px 10px; }
.bp-chip { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; flex: none; }
.bp-normal { background: color-mix(in srgb, #2e9e5b 18%, transparent); color: #1f7a44; }
.bp-elevated { background: color-mix(in srgb, #d9a400 22%, transparent); color: #8a6700; }
.bp-high1 { background: color-mix(in srgb, #e8780c 22%, transparent); color: #a14f00; }
.bp-high2, .bp-crisis { background: color-mix(in srgb, var(--over) 20%, transparent); color: var(--over); }
.bp-crisis { outline: 2px solid var(--over); }
@media (prefers-color-scheme: dark) {
  .bp-normal { color: #6fd39a; } .bp-elevated { color: #f0c94a; } .bp-high1 { color: #f5a65b; }
}
.bp-warn { margin: 0 14px 10px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--over) 14%, transparent); font-size: 14px; }
#x-name-wrap[hidden] { display: none; }
