/* dontspillthecalories: glass-lit objects in a black void.
   One hue per object. Light comes from above. Hairlines frame things. */

:root {
  --void: #000;
  --hair: #1f1f1f;
  --hair-2: #2a2a2a;
  --ink: #f2f2f2;
  --ink-2: #b4b4b4;
  --muted: #8c8c8c;
  --faint: #5c5c5c;
  --field: rgba(255, 255, 255, 0.05);
  --field-2: rgba(255, 255, 255, 0.08);

  /* hue recipes: top (pale) / bottom (saturated) / tint (dark glass) */
  --brand-top: #ff9ad5; --brand-bot: #b44dff; --brand-tint: #3f1255; /* dragon fruit */
  --blue-top: #b5ccff;  --blue-bot: #5a8cf0;  --blue-tint: #1c3a8a;
  --orange-top: #ffddb8; --orange-bot: #ff9e4f; --orange-tint: #5a3410;
  --violet-top: #dccfff; --violet-bot: #9b7bff; --violet-tint: #3a2580;
  --silver-top: #ffffff; --silver-bot: #7a7a7a; --silver-tint: #5a5a5a;
  --cyan-top: #bdf4ff; --cyan-bot: #45cde6; --cyan-tint: #0e4a57;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Inter", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro", "Inter", system-ui, sans-serif;

  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 11px;
  --rail-w: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 0px;
  color-scheme: dark;
}

[data-hue="brand"]  { --top: var(--brand-top);  --bot: var(--brand-bot);  --tint: var(--brand-tint); }
[data-hue="blue"]   { --top: var(--blue-top);   --bot: var(--blue-bot);   --tint: var(--blue-tint); }
[data-hue="orange"] { --top: var(--orange-top); --bot: var(--orange-bot); --tint: var(--orange-tint); }
[data-hue="violet"] { --top: var(--violet-top); --bot: var(--violet-bot); --tint: var(--violet-tint); }
[data-hue="silver"] { --top: var(--silver-top); --bot: var(--silver-bot); --tint: var(--silver-tint); }
[data-hue="cyan"]   { --top: var(--cyan-top);   --bot: var(--cyan-bot);   --tint: var(--cyan-tint); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--void); color: var(--ink); }
html { overflow-x: hidden; }
body {
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--top, #fff); outline-offset: 2px; border-radius: 8px; }

/* ---------- glass icon ---------- */
.glass { display: grid; place-items: center; width: 34px; height: 34px; position: relative; }
.glass svg { width: 100%; height: 100%; overflow: visible; }

/* ---------- rail (desktop) ---------- */
.app { min-height: 100dvh; }
.rail {
  position: fixed; left: 20px; top: 50%; transform: translateY(-50%); z-index: 20;
  display: flex; flex-direction: column; gap: 6px; padding: 10px 8px;
  border: 1px solid var(--hair); border-radius: 30px; background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.rail-btn {
  position: relative; display: grid; place-items: center; width: 56px; height: 56px;
  border-radius: 18px; text-decoration: none; color: inherit;
  transition: background .2s ease;
}
/* unselected icons are monochrome; the selected one shows its colour */
.rail-btn .glass { opacity: .5; filter: grayscale(1); transition: opacity .25s ease, filter .25s ease, transform .25s ease; }
.rail-btn:hover .glass { opacity: .85; }
.rail-btn.active .glass { opacity: 1; filter: none; }
.rail-btn.active { background: rgba(255, 255, 255, .025); }
.rail-tip {
  position: absolute; left: calc(100% + 14px); top: 50%; transform: translate(-4px, -50%);
  padding: 6px 10px; border: 1px solid var(--hair-2); border-radius: 9px; background: #000;
  font-size: 13px; color: var(--ink-2); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.rail-btn:hover .rail-tip, .rail-btn:focus-visible .rail-tip { opacity: 1; transform: translate(0, -50%); }

/* ---------- stage ---------- */
.stage { padding-left: calc(var(--rail-w) + 32px); padding-right: 32px; }
.view { max-width: 820px; margin: 0 auto; }
.view-chat { display: flex; flex-direction: column; height: 100dvh; }
.view:not(.view-chat) { padding: 48px 0 120px; }

.view-head { margin-bottom: 24px; }
.view-head h1 { font-size: 34px; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.hint { color: var(--muted); font-size: 13.5px; margin: 10px 4px 20px; }

/* ---------- chat view ---------- */
.thread { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 28px 2px 18px; scrollbar-width: none; }
.thread::-webkit-scrollbar { display: none; }
.topline { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 18px; }
.wordmark { display: block; height: 34px; width: auto; }
.date { color: var(--muted); font-size: 14px; }


.view-chat { position: relative; }

/* cards: flat black with a hairline border, no glow */
.card {
  position: relative; border: 1px solid var(--hair); border-radius: var(--r-lg); padding: 20px;
  background: var(--void);
  overflow: hidden;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { font-size: 15px; font-weight: 600; color: var(--ink); }
.card-foot { margin: 12px 0 0; font-size: 13.5px; color: var(--muted); }
.card-foot b { color: var(--ink); font-weight: 600; }

.dash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 32px; }
.dash .card { height: 178px; padding: 14px 16px; }
.dash .card-time { grid-column: 1 / -1; height: 210px; }
.dash .card-time .time-chart { height: 156px; }
.dash-dots { display: none; }
.card-head { margin-bottom: 6px; }
.card-head h2 { font-size: 13.5px; }
.card-head .sub { font-size: 12px; margin: 0; }

/* today ring: ring left, numbers right */
.card-today { display: flex; align-items: center; gap: 14px; }
.ring-wrap { position: relative; flex: none; width: 128px; height: 128px; }
.ring-wrap svg { width: 100%; height: 100%; overflow: visible; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-num { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.035em; line-height: 1; }
.ring-label { color: var(--muted); font-size: 11px; margin-top: 4px; max-width: 80px; line-height: 1.25; }
.today-stats { display: flex; flex-direction: column; gap: 8px; margin: 0; min-width: 0; }
.today-stats div { display: flex; flex-direction: column-reverse; }
.today-stats dt { color: var(--muted); font-size: 11.5px; }
.today-stats dd { margin: 0; font-weight: 600; font-size: 15px; white-space: nowrap; }
.today-stats dd small { color: var(--muted); font-weight: 400; font-size: 11.5px; }

/* week */
.week-hero { display: flex; align-items: baseline; gap: 6px; margin: 0 0 4px; white-space: nowrap; }
.week-hero .big { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.week-hero .of { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.week-bars { position: relative; height: 98px; }
.week-bars svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ex-bars { height: 132px; }
.axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.axis-label.today { fill: var(--ink); font-weight: 600; }

/* time chart */
.time-chart { height: 128px; }
.time-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }

.empty-chart { display: grid; place-items: center; height: 100%; min-height: 90px; color: var(--muted); font-size: 13px; text-align: center; padding: 0 8px; }

/* messages */
.messages { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; }
.msg { max-width: 82%; animation: rise .28s ease both; }
.msg.user { align-self: flex-end; padding: 10px 14px; border-radius: 18px 18px 6px 18px; background: var(--field-2); border: 1px solid var(--hair); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .photo-tag { display: block; color: var(--muted); font-size: 12.5px; }
.msg.assistant { align-self: flex-start; display: grid; grid-template-columns: 22px 1fr; gap: 10px; max-width: 92%; }
.msg.assistant .dot { width: 22px; height: 22px; margin-top: 1px; }
.msg.assistant .body { min-width: 0; }
.msg.assistant .text { color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant .via { color: var(--muted); font-size: 12px; margin-top: 3px; }
.msg.thinking .text { color: var(--muted); }
.msg.thinking .text::after { content: ""; display: inline-block; width: 1.2em; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.welcome { color: var(--muted); font-size: 14.5px; margin: 0 2px; }
.welcome b { color: var(--ink-2); font-weight: 500; }

/* proposal card */
.pcard {
  margin-top: 10px; border: 1px solid var(--hair-2); border-radius: var(--r-md); padding: 14px;
  background: #000;
}
.pcard-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.pcard-head .kind { font-weight: 600; font-size: 14px; }
.pcard-head .when { display: flex; gap: 6px; }
.pcard select, .pcard input, .inline-form input, .settings input, .settings textarea, .row-edit input {
  background: var(--field); border: 1px solid var(--hair-2); border-radius: 9px; padding: 7px 9px; min-width: 0;
}
.pcard select { padding-right: 6px; }
.pcard input:focus, .inline-form input:focus, .settings input:focus, .settings textarea:focus { outline: none; border-color: var(--bot); }
.items { display: flex; flex-direction: column; gap: 6px; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) 84px 70px 58px 28px; gap: 6px; align-items: center; }
.item input.unparsed { border-color: #6b5a2a; }
.item .src { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); margin: -2px 0 4px 2px; }
.item .src label { display: inline-flex; gap: 5px; align-items: center; color: var(--ink-2); cursor: pointer; }
.item .src input { accent-color: var(--bot); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 84px 70px 58px 28px; gap: 6px; font-size: 11.5px; color: var(--muted); padding: 0 2px 2px; }
.icon-x { width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.icon-x:hover { color: var(--ink); background: var(--field); }
.pcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pcard-total { font-size: 14px; color: var(--muted); }
.pcard-total b { color: var(--ink); font-size: 17px; font-weight: 600; }
.pcard-actions { display: flex; gap: 8px; }
.link-btn { border: 0; background: none; padding: 4px 2px; color: var(--muted); cursor: pointer; font-size: 13.5px; }
.link-btn:hover { color: var(--ink); }
.pcard.done { padding: 10px 14px; }
.pcard.done .done-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); }
.pcard.discarded { opacity: .5; }
.single { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.single.w { grid-template-columns: 1fr; max-width: 200px; }

.btn {
  border: 1px solid var(--hair-2); background: var(--field); border-radius: 12px; padding: 9px 14px; cursor: pointer;
  font-weight: 500; font-size: 14px; transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--field-2); }
.btn.primary {
  border-color: transparent; color: #000; font-weight: 600;
  background: linear-gradient(180deg, var(--top), var(--bot));
}
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; }

/* empty chat: heading + composer centred in the free space, chips under it */
.empty-head { display: none; }
.view-chat.empty .thread { flex: 0 0 auto; overflow: visible; padding-bottom: 0; }
.view-chat.empty .messages { display: none; }
.view-chat.empty .composer-wrap { display: flex; flex-direction: column; margin: auto 0; padding-top: 0; padding-bottom: 56px; background: none; }
.view-chat.empty .empty-head { order: 0; display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; }
.view-chat.empty .empty-head .glass { width: 36px; height: 36px; }
.view-chat.empty .empty-head h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; }
.view-chat.empty .composer-wrap .composer { order: 1; }
.view-chat.empty .under-row { order: 2; padding: 14px 2px 0; }
/* text on top, camera left and send right underneath */
.view-chat.empty .composer {
  display: grid; grid-template-columns: auto auto 1fr auto; grid-template-areas: "text text text text" "photo pill . send";
  align-items: center; gap: 4px 6px; padding: 14px 12px 10px; border-radius: 22px;
}
.view-chat.empty .composer textarea { grid-area: text; min-height: 52px; padding: 4px 6px; }
.view-chat.empty .composer .icon-btn { grid-area: photo; }
.view-chat.empty .composer .photo-pill { grid-area: pill; }
.view-chat.empty .composer .send { grid-area: send; }

/* composer */
.composer-wrap { padding: 14px 0 calc(18px + var(--safe-b)); background: linear-gradient(transparent, #000 30%); }
.under-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 2px 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }

/* today's calories against budget: brand colour under 90%, yellow 90-100%, red over */
.kcal-bar { flex: 0 0 230px; display: flex; flex-direction: column; gap: 7px; --kb-top: var(--brand-top); --kb-bot: var(--brand-bot); }
.kcal-bar[data-state="warn"] { --kb-top: #ffe9a8; --kb-bot: #f5bf45; }
.kcal-bar[data-state="over"] { --kb-top: #ffb9ad; --kb-bot: #ff5f57; }
.kcal-text { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.kcal-text b { color: var(--ink); font-weight: 600; }
.kcal-text #kb-left { color: var(--ink-2); }
.kcal-track { position: relative; height: 4px; border-radius: 2px; background: #1b1b1b; overflow: visible; }
.kcal-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 2px;
  background: linear-gradient(90deg, var(--kb-top), var(--kb-bot));
  transition: width .5s ease, background .3s ease;
}
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--hair-2); background: transparent; border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.chip:hover { color: var(--ink); border-color: #3a3a3a; }
.composer {
  position: relative; display: flex; align-items: flex-end; gap: 6px; padding: 8px; border-radius: 26px;
  border: 1px solid transparent;
  background:
    linear-gradient(#070707, #070707) padding-box,
    linear-gradient(180deg, color-mix(in srgb, var(--brand-top) 70%, transparent), color-mix(in srgb, var(--brand-bot) 28%, transparent) 70%, rgba(255,255,255,.08)) border-box;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .7);
  transition: background .2s ease;
}
.composer:focus-within {
  background:
    linear-gradient(#070707, #070707) padding-box,
    linear-gradient(180deg, var(--brand-top), color-mix(in srgb, var(--brand-bot) 55%, transparent) 70%, rgba(255,255,255,.12)) border-box;
}
.composer textarea {
  flex: 1; resize: none; border: 0; background: transparent; padding: 10px 6px; max-height: 160px; outline: none; font-size: 16px; line-height: 1.4; color: var(--ink);
}
.composer textarea::placeholder { color: #a8a8a8; }
.icon-btn, .send { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; }
.icon-btn { color: #bdbdbd; }
.icon-btn:hover { color: var(--ink); background: var(--field); }
.icon-btn svg, .send svg { width: 22px; height: 22px; }
.send { color: #000; background: linear-gradient(180deg, var(--brand-top), var(--brand-bot)); }
.send:disabled { opacity: .35; cursor: default; }
.photo-pill { position: relative; flex: none; width: 38px; height: 38px; }
.photo-pill img { width: 38px; height: 38px; object-fit: cover; border-radius: 10px; border: 1px solid var(--hair-2); }
.photo-pill button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: #fff; color: #000; font-size: 13px; line-height: 18px; padding: 0; cursor: pointer; }

/* ---------- chats history ---------- */
.messages.history { margin-top: 0; }
.view-chats .messages.history { padding: 0; }
.history .day-sep { align-self: center; color: var(--muted); font-size: 12.5px; margin: 10px 0 2px; }
.chats-actions { margin-top: 26px; }

/* ---------- log ---------- */
.log-list { display: flex; flex-direction: column; gap: 26px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 0 4px 10px; border-bottom: 1px solid var(--hair); margin-bottom: 2px; }
.day-head h3 { font-size: 17px; }
.day-head .nums { color: var(--muted); font-size: 13.5px; text-align: right; }
.day-head .nums b { color: var(--ink); font-weight: 600; }
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 14px; align-items: baseline; padding: 12px 4px; border-bottom: 1px solid var(--hair); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row .t { color: var(--muted); font-size: 13px; }
.row .what { min-width: 0; }
.row .what .meal { color: var(--muted); font-size: 12.5px; }
.row .what .name { overflow-wrap: anywhere; }
.row .k { font-weight: 600; text-align: right; }
.row .k small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.row.ex .k { color: var(--orange-top); }
.row.wt .k { color: var(--blue-top); }
.row-edit { grid-column: 1 / -1; padding: 0 4px 12px; cursor: default; border-bottom: 1px solid var(--hair); }
.row-edit.pcard { padding: 14px; margin: 4px 0 12px; border: 1px solid var(--hair-2); }
.row-edit .items { margin-bottom: 12px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn.danger { color: #ffb4a8; }
.tag { display: inline-block; font-size: 11.5px; color: var(--muted); border: 1px solid var(--hair-2); border-radius: 6px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }

/* ---------- exercise / weight ---------- */
.card-ex, .card-weight { margin-bottom: 14px; padding: 20px; }
.ex-hero, .w-stats { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 8px; }
.stat .v { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.stat .v small { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.stat .l { color: var(--muted); font-size: 13px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 4px; }
.inline-form input { padding: 10px 12px; font-size: 16px; }
.inline-form input[name="activity"] { flex: 1 1 200px; }
.inline-form input[name="duration_min"], .inline-form input[name="calories"] { width: 96px; }
.inline-form input[name="weight_kg"] { flex: 1 1 160px; max-width: 220px; }
.w-chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; border-radius: 2px; vertical-align: middle; margin-right: 6px; background: var(--blue-bot); }
.legend i.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-top); }
.verdict { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 20px; padding: 14px 16px; border: 1px solid var(--hair); border-radius: var(--r-md); color: var(--ink-2); font-size: 14.5px; }
.verdict svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }

/* ---------- brain ---------- */
.tabs, .file-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--hair); border-radius: 14px; width: max-content; max-width: 100%; overflow-x: auto; margin-bottom: 20px; }
.tabs button, .file-tabs button { border: 0; background: transparent; padding: 7px 13px; border-radius: 10px; color: var(--muted); cursor: pointer; font-size: 14px; white-space: nowrap; }
.tabs button[aria-selected="true"], .file-tabs button[aria-selected="true"] { background: var(--field-2); color: var(--ink); }
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 12px; margin-bottom: 28px; }
.settings .actions { margin-top: 4px; }
.settings label { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 6px 5px; font-size: 13px; color: var(--muted); min-width: 0; }
.settings label > input, .settings label > textarea, .settings label > select { grid-column: 1 / -1; width: 100%; min-width: 0; }
.settings .unit { color: var(--faint); }
.settings input, .settings textarea, .settings select { padding: 9px 11px; font-size: 15px; color: var(--ink); }
.settings select { background: var(--field); border: 1px solid var(--hair-2); border-radius: 9px; }
.settings .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.saved { color: var(--muted); font-size: 13px; }
.usage { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 16px; padding: 14px 16px; border: 1px solid var(--hair); border-radius: var(--r-md); }
.usage b { color: var(--ink); font-weight: 600; }
.md {
  white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.55 ui-monospace, "SF Mono", Menlo, monospace; color: var(--ink-2);
  border: 1px solid var(--hair); border-radius: var(--r-md); padding: 16px; margin: 0 0 14px; max-height: 60vh; overflow: auto;
}
.food-row { grid-template-columns: minmax(0, 1fr) auto; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.login-logo { width: 240px; height: auto; margin-bottom: 18px; }
.login-icon { width: 96px; height: 96px; margin-bottom: 10px; }
.login-icon .glass { width: 96px; height: 96px; }
.login-card h1 { font-size: 22px; letter-spacing: -0.02em; }
.login-card p { margin: 0; color: var(--muted); font-size: 14px; }
.login-card input { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--hair-2); background: var(--field); font-size: 16px; text-align: center; margin-top: 8px; }
.login-card .btn { width: 100%; padding: 12px; }
.form-error { color: #ffb4a8 !important; min-height: 1.2em; }
.login-links { display: flex; justify-content: space-between; width: 100%; }
.login-card input#login-code { letter-spacing: 0.4em; font-size: 20px; font-variant-numeric: tabular-nums; }

/* ---------- tooltip / toast ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 240px; padding: 8px 10px; border-radius: 10px;
  background: #0a0a0a; border: 1px solid var(--hair-2); font-size: 12.5px; color: var(--ink-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
}
.tooltip b { color: var(--ink); font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b) + var(--tabbar-h)); transform: translateX(-50%); z-index: 60;
  display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 14px; background: #0c0c0c; border: 1px solid var(--hair-2);
  font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .7); animation: rise .2s ease both;
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  :root { --tabbar-h: 70px; }
  body { font-size: 15.5px; }
  .stage { padding: 0; }
  .view:not(.view-chat) { padding: calc(22px + var(--safe-t)) 16px calc(var(--tabbar-h) + 40px + var(--safe-b)); }
  .view-head h1 { font-size: 30px; }

  .rail {
    top: auto; bottom: calc(10px + var(--safe-b)); left: 50%; transform: translateX(-50%);
    flex-direction: row; gap: 2px; padding: 6px 8px; border-radius: 26px; width: max-content;
    background: rgba(0, 0, 0, .72); backdrop-filter: blur(24px) saturate(1.2); -webkit-backdrop-filter: blur(24px) saturate(1.2);
    transition: transform .25s ease, opacity .2s ease;
  }
  .rail-btn { width: 52px; height: 48px; border-radius: 16px; }
  .rail-btn .glass { width: 30px; height: 30px; }
  .rail-tip { display: none; }
  body.kb .rail { transform: translate(-50%, 140%); opacity: 0; pointer-events: none; }

  .thread { padding: calc(16px + var(--safe-t)) 0 12px; }
  .topline { padding: 0 16px; margin-bottom: 14px; }
  .messages { padding: 0 16px; }
  .welcome { padding: 0 16px; }

  /* dashboard stacks on phones */
  .dash { grid-template-columns: 1fr; gap: 10px; margin-bottom: 28px; }
  .dash .card { height: 176px; }
  .dash .card-time { height: 200px; }
  .dash .card-time .time-chart { height: 146px; }
  .ring-wrap { width: 136px; height: 136px; }
  .week-bars { height: 104px; }
  .time-chart { height: 132px; }

  .composer-wrap { padding: 4px 12px calc(var(--tabbar-h) + 8px + var(--safe-b)); transition: padding .2s ease; }
  .view-chat.empty .composer-wrap { padding: 0 16px calc(var(--tabbar-h) + 24px + var(--safe-b)); }
  .view-chat.empty .composer textarea { min-height: 48px; }
  .view-chat.empty .empty-head h1 { font-size: 25px; }
  .view-chat.empty .empty-head .glass { width: 30px; height: 30px; }
  body.kb .composer-wrap { padding-bottom: 10px; }
  body.kb .chips { display: none; }
  .under-row { flex-wrap: wrap; gap: 10px; }
  .kcal-bar { flex: 1 1 100%; order: -1; }
  .view-chat.empty .kcal-bar { order: 2; }
  .wordmark { height: 28px; }
  .chips { padding-bottom: 8px; }
  .chip { padding: 5px 11px; font-size: 12.5px; }
  .composer { padding: 6px; }
  .icon-btn, .send { width: 38px; height: 38px; }
  .chips { padding-left: 2px; }
  .msg { max-width: 88%; }
  .msg.assistant { max-width: 100%; }
  /* phones: item name on its own line, then serving, kcal, protein */
  .item, .cols { grid-template-columns: minmax(0, 1fr) 64px 58px 28px; }
  .item [data-k="name"] { grid-column: 1 / -1; }
  .cols > span:first-child { display: none; }
  .single { grid-template-columns: 1fr 1fr; }
  #ex-form { display: grid; grid-template-columns: 1fr 1fr; }
  #ex-form input { width: 100%; }
  #ex-form input[name="activity"], #ex-form .btn { grid-column: 1 / -1; }
  #w-form input[name="weight_kg"] { max-width: none; }
  .pcard { padding: 14px 12px; }
  .row { gap: 12px; }
  .single input[name="activity"] { grid-column: 1 / -1; }
  .w-chart svg { height: 200px; }
  .w-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
  .stat .v { font-size: 27px; }
  .settings { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .rail-btn { width: 52px; }
  .ring-wrap { width: 120px; height: 120px; }
  .ring-num { font-size: 27px; }
}

/* first-time setup */
.setup-card { max-width: 460px; }
.setup-card h1 { margin: -6px 0 0; }
.setup-grid { width: 100%; margin: 10px 0 4px; text-align: left; grid-template-columns: 1fr 1fr; }
.setup-card .setup-grid input { margin-top: 0; text-align: left; font-size: 15px; padding: 9px 11px; border-radius: 9px; }
.unit-pick { grid-column: 1 / -1; display: flex; gap: 6px; min-width: 0; }
.unit-pick input { flex: 1; min-width: 0; }
.unit-pick select { flex: none; }
.danger-zone { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--hair); justify-content: space-between; align-items: center; }
.btn.danger { color: #ffb4a8; }
.btn.danger.armed { background: #3a1410; border-color: #6e2a20; }
@media (max-width: 420px) { .setup-grid { grid-template-columns: 1fr; } }
.danger-zone .hint { margin: 0; }
