/* SmartMenu — design system «Тёплая кухня».
 * Mobile-first. All colour/space/type/radius decisions live in :root tokens;
 * components reference the tokens, never hard-coded values. Class names are kept
 * stable so the JS renderers (app.js) need no markup changes for the restyle. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* surfaces */
  --bg:          #FBF6EF;   /* page */
  --bg2:         #F6EFE6;   /* sunken / subtle fill */
  --card:        #FFFFFF;   /* cards, sheets */
  --border:      #EFE3D8;
  --border-h:    #E2D2C4;   /* hover/raised border */

  /* terracotta accent */
  --primary:     #E2643B;
  --ph:          #B84A28;   /* pressed / hover */
  --acc-soft:    #F6E7DF;   /* light accent fill */

  /* fresh green (secondary) */
  --accent:      #5E8C5A;
  --acc-l:       #E7F0E5;   /* light green fill */
  --acc-d:       #3F6B3C;   /* text on light green */

  /* text */
  --text:        #2B2420;
  --text2:       #8A7F76;
  --text3:       #B3A89F;   /* hints / placeholders */

  /* status */
  --ok:          #5E8C5A;
  --err:         #C0492F;
  --err-soft:    #F7E0DA;

  /* meal labels (soft pastel fill + dark text in the same family) */
  --m-b-bg: #FBEFD6; --m-b-fg: #9A6B12;   /* завтрак */
  --m-l-bg: #F6E7DF; --m-l-fg: #B84A28;   /* обед */
  --m-d-bg: #E7F0E5; --m-d-fg: #3F6B3C;   /* ужин */
  --m-s-bg: #F7E5EC; --m-s-fg: #9E3B5E;   /* перекус */

  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px;

  /* radii */
  --r-card: 16px;
  --r-ctl:  12px;
  --r-pill: 999px;

  /* soft, thin elevation (used sparingly) */
  --shadow:   0 1px 2px rgba(43,36,32,.04), 0 1px 3px rgba(43,36,32,.05);
  --shadow-h: 0 2px 6px rgba(43,36,32,.07), 0 4px 14px rgba(43,36,32,.06);

  --tap: 44px;            /* min touch target */
  --ease: 170ms ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.boot { display: flex; align-items: center; justify-content: center; height: 100vh; color: var(--text2); }

/* visible keyboard focus everywhere (accessibility); pointer taps stay clean */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── AUTH ────────────────────────────────────────────── */
.auth {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 28px 22px;
  max-width: 440px; margin: 0 auto;
}
.auth-logo  { font-size: 60px; line-height: 1; margin-bottom: var(--s3); }
.auth-title { font-size: 26px; font-weight: 500; letter-spacing: -.2px; }
.auth-sub   { color: var(--text2); font-size: 14px; margin-bottom: var(--s6); }
.auth-tabs  { display: flex; gap: var(--s1); width: 100%; margin-bottom: var(--s4); }
.atab {
  flex: 1; min-height: var(--tap); padding: 10px 4px;
  border: 1px solid var(--border); background: var(--card);
  border-radius: var(--r-ctl); font-size: 13px; font-weight: 500; color: var(--text2);
  cursor: pointer; transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.atab.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.auth-form { width: 100%; display: flex; flex-direction: column; gap: var(--s3); }
.auth-err  { color: var(--err); font-size: 13px; min-height: 18px; text-align: center; }
.auth-hint { font-size: 12px; color: var(--text2); text-align: center; }
.consent {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13px; line-height: 1.45; color: var(--text2); text-align: left;
}
.consent input { width: 18px; height: 18px; margin-top: 1px; flex: 0 0 auto; accent-color: var(--primary); }
.consent a, .auth-foot a, .set-link { color: var(--primary); }
.auth-foot { margin-top: var(--s4); font-size: 13px; }
.auth-foot a { color: var(--text2); text-decoration: underline; }
.set-link { display: inline-block; font-size: 14px; text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }

/* ── INPUTS / BUTTONS ────────────────────────────────── */
.inp {
  width: 100%; border: 1px solid var(--border); border-radius: var(--r-ctl);
  padding: 12px 14px; font-size: 15px; background: var(--card); color: var(--text);
  font-family: inherit; transition: border-color var(--ease), box-shadow var(--ease);
}
.inp::placeholder, .ta::placeholder, .chat-input::placeholder { color: var(--text3); }
.inp:focus, .ta:focus, .chat-input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--acc-soft);
}
.ta {
  width: 100%; min-height: 76px; border: 1px solid var(--border); border-radius: var(--r-ctl);
  padding: 12px 14px; font-size: 15px; background: var(--card); color: var(--text);
  font-family: inherit; line-height: 1.5; resize: vertical;
}
.btn-primary {
  background: var(--primary); color: #fff; border: none; border-radius: var(--r-ctl);
  padding: 13px 18px; font-size: 15px; font-weight: 500; cursor: pointer; min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--ease), transform var(--ease);
}
.btn-primary:hover { background: var(--ph); }
.btn-primary:active { background: var(--ph); transform: scale(.98); }
.btn-sm { padding: 10px 14px; font-size: 14px; min-height: 40px; }
.btn-outline {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-ctl); padding: 12px 14px; font-size: 14px; font-weight: 500; cursor: pointer;
  width: 100%; margin-top: var(--s2); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.btn-outline:hover { border-color: var(--border-h); background: var(--bg2); }
.btn-outline:active { transform: scale(.98); }
.btn-outline.danger { color: var(--err); border-color: var(--err-soft); }
.btn-outline.danger:hover { background: var(--err-soft); border-color: var(--err); }

/* inline SVG icons: each <svg> carries its own stroke/fill="currentColor",
 * so they inherit text colour; these rules only handle sizing. */
.ic { width: 20px; height: 20px; display: inline-flex; vertical-align: middle; flex: 0 0 auto; }
.ic svg, svg.ic { width: 100%; height: 100%; display: block; }

/* ── SHELL ───────────────────────────────────────────── */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.hdr {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; padding-top: max(10px, env(safe-area-inset-top));
}
.hdr-logo  { font-size: 16px; font-weight: 500; color: var(--primary); display: flex; align-items: center; gap: 6px; }
.hdr-right { display: flex; align-items: center; gap: var(--s2); }
.hdr-fam   { font-size: 13px; color: var(--text2); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-dot  { width: 8px; height: 8px; border-radius: 50%; background: var(--border-h); transition: background .3s; }
.sync-dot.ok  { background: var(--ok); }
.sync-dot.err { background: var(--err); }

.screen { flex: 1; padding: var(--s4) var(--s3) 84px; max-width: 1200px; width: 100%; margin: 0 auto; }
@media (min-width: 640px) { .screen { padding: 18px 20px 84px; } }
.screen-title { font-size: 22px; font-weight: 500; letter-spacing: -.2px; margin-bottom: var(--s3); }

/* gentle fade when switching tabs / first paint of a screen */
.screen > * { animation: fade-in 180ms ease both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* pull-to-refresh indicator (injected by the gesture layer) */
.ptr {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 0; overflow: hidden; color: var(--text2); font-size: 13px;
  transition: height 160ms ease;
}
.ptr.show { height: 36px; }
.ptr-spin {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TABBAR ──────────────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbtn {
  flex: 1; border: none; background: none; cursor: pointer; padding: 8px 2px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text2); font-size: 11px; font-weight: 500; min-height: var(--tap);
  transition: color var(--ease);
}
.tabbtn .tabic { width: 23px; height: 23px; display: block; }
.tabbtn .tabic svg { width: 100%; height: 100%; }
.tabbtn .tablbl { white-space: nowrap; font-size: 10px; }
.tabbtn.on { color: var(--primary); }

/* ── WEEK BAR ────────────────────────────────────────── */
.weekbar { display: flex; gap: var(--s2); margin-bottom: var(--s4); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wbtn {
  flex: 1; min-width: 72px; min-height: 40px; padding: 8px 6px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--card); font-size: 13px; font-weight: 500;
  cursor: pointer; color: var(--text2); white-space: nowrap;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.wbtn.cur { border-color: var(--accent); color: var(--acc-d); }
.wbtn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* horizontal week/day slide animation (gesture layer toggles these) */
.slide-out-left  { animation: slide-out-left  200ms ease forwards; }
.slide-out-right { animation: slide-out-right 200ms ease forwards; }
@keyframes slide-out-left  { to { opacity: 0; transform: translateX(-24px); } }
@keyframes slide-out-right { to { opacity: 0; transform: translateX(24px);  } }

/* ── MENU ────────────────────────────────────────────── */
.days { display: grid; grid-template-columns: 1fr; gap: var(--s3); }
@media (min-width: 560px)  { .days { grid-template-columns: repeat(2,1fr); } }
@media (min-width: 860px)  { .days { grid-template-columns: repeat(3,1fr); } }
@media (min-width: 1140px) { .days { grid-template-columns: repeat(4,1fr); } }

.daycard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card);
  overflow: hidden; transition: border-color var(--ease), box-shadow var(--ease);
}
.daycard:hover { border-color: var(--border-h); box-shadow: var(--shadow); }
.daycard.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.dayhd {
  padding: 10px 14px; background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.dayname { font-size: 14px; font-weight: 500; }
.daykcal { font-size: 11px; font-weight: 500; color: var(--primary); }

.meal {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: var(--s2); cursor: pointer; min-height: 48px;
  transition: background var(--ease);
}
.meal:last-child { border-bottom: none; }
.meal:hover, .meal:active { background: var(--bg2); }
.mbadge {
  font-size: 10px; font-weight: 500; padding: 3px 8px; border-radius: var(--r-pill);
  white-space: nowrap; flex-shrink: 0; margin-top: 1px;
}
.mb-b { background: var(--m-b-bg); color: var(--m-b-fg); }
.mb-l { background: var(--m-l-bg); color: var(--m-l-fg); }
.mb-d { background: var(--m-d-bg); color: var(--m-d-fg); }
.mb-s { background: var(--m-s-bg); color: var(--m-s-fg); }
.mbody { flex: 1; min-width: 0; }
.mtext { font-size: 14px; line-height: 1.4; }
.empty-meal { color: var(--text3); }
.mkb { font-size: 11px; color: var(--text2); margin-top: 3px; }
.medit { color: var(--text3); display: flex; align-items: center; }
.medit .ic { width: 16px; height: 16px; }

/* ── SHOPPING ────────────────────────────────────────── */
.shop-chips { display: flex; gap: var(--s2); margin-bottom: var(--s3); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chipf {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-pill); border: 1px solid var(--border);
  background: var(--card); font-size: 13px; font-weight: 500; color: var(--text2);
  white-space: nowrap; cursor: pointer; min-height: 38px;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.chipf.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.chipf-cnt {
  font-size: 11px; font-weight: 500; min-width: 18px; padding: 1px 6px;
  border-radius: var(--r-pill); background: var(--bg2); color: var(--text2); text-align: center;
}
.chipf.on .chipf-cnt { background: rgba(255, 255, 255, .25); color: #fff; }
.shop-ctxnote { font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: var(--s3); }
.magic-wrap { margin-top: var(--s4); }

.shop-prog { margin-bottom: var(--s3); }
.shop-prog-row { font-size: 12px; color: var(--text2); margin-bottom: 5px; }
.prog-wrap { background: var(--border); border-radius: var(--r-pill); height: 7px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width .35s ease; }

.shop-add { display: flex; gap: var(--s2); margin-bottom: var(--s4); flex-wrap: wrap; }
.shop-add .inp { flex: 1 1 100%; }
.shop-add .inp-qty { flex: 1 1 90px; }
.shop-add .btn-primary { min-width: var(--tap); }
@media (min-width: 560px) {
  .shop-add .inp { flex: 1; }
  .shop-add .inp-qty { flex: 0 0 110px; }
}

.catblock {
  margin-bottom: var(--s3); border-radius: var(--r-card); overflow: hidden;
  border: 1px solid var(--border); background: var(--card);
  transition: opacity var(--ease);
}
.catblock.cat-done { opacity: .6; }
.cathd {
  padding: 10px 14px; background: var(--bg2); border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 500; display: flex; justify-content: space-between;
}
.catcnt { color: var(--text2); font-weight: 400; }

/* swipeable row: foreground .sitem slides over the .sitem-actions behind it */
.sitem-wrap { position: relative; overflow: hidden; border-bottom: 1px solid var(--border); }
.sitem-wrap:last-child { border-bottom: none; }
.sitem-actions {
  position: absolute; inset: 0; display: flex; justify-content: flex-end;
}
.si-act {
  border: none; cursor: pointer; color: #fff; font-size: 12px; font-weight: 500;
  width: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.si-act .ic { width: 20px; height: 20px; color: #fff; }
.si-act span { font-size: 11px; }
.si-act.done { background: var(--accent); }
.si-act.del  { background: var(--err); }
.si-more {
  flex: 0 0 auto; align-self: center; width: 32px; height: 40px; margin: -8px -6px -8px 0;
  border: none; background: none; color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center; border-radius: 8px;
  transition: color var(--ease), background var(--ease);
}
.si-more .ic { width: 18px; height: 18px; }
.si-more:hover { color: var(--text2); background: var(--bg2); }
.sitem {
  position: relative; background: var(--card);
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; cursor: pointer;
  min-height: 48px; touch-action: pan-y; transition: background var(--ease), transform var(--ease);
}
.sitem:hover, .sitem:active { background: var(--bg2); }
.sitem.done { opacity: .55; }
.sitem.done .siname { text-decoration: line-through; }
.schk {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border-h);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;
  color: #fff; transition: background var(--ease), border-color var(--ease);
}
.schk .ic { width: 13px; height: 13px; }
.sitem.done .schk { background: var(--accent); border-color: var(--accent); }
.sibody { flex: 1; min-width: 0; }
.siname { font-size: 14px; }
.simeta { display: flex; gap: var(--s2); margin-top: 2px; flex-wrap: wrap; }
.siqty { font-size: 11px; color: var(--primary); font-weight: 500; }
.sinote { font-size: 11px; color: var(--text2); }

/* ── RECIPES ─────────────────────────────────────────── */
.rec-top { display: flex; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.search { flex: 1; }
.recgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: var(--s3); }
.reccard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: var(--s4); cursor: pointer; transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.reccard:hover { border-color: var(--border-h); box-shadow: var(--shadow-h); }
.reccard:active { transform: scale(.99); background: var(--bg2); }
.rc-emoji { font-size: 30px; margin-bottom: 6px; }
.rc-name  { font-size: 14px; font-weight: 500; line-height: 1.3; margin-bottom: 3px; }
.rc-meta  { font-size: 11px; color: var(--text2); margin-bottom: 5px; }
.rc-kb    { font-size: 11px; color: var(--primary); font-weight: 500; margin-bottom: 5px; }
.rc-tags  { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 10px; padding: 3px 9px; border-radius: var(--r-pill); background: var(--bg2); color: var(--text2); }

.rec-hero { font-size: 52px; text-align: center; margin-bottom: var(--s2); }
.rec-name { font-size: 22px; font-weight: 500; text-align: center; margin-bottom: var(--s2); }
.rec-meta { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: var(--text2); margin-bottom: var(--s4); }
.rec-kbzhu { display: flex; border: 1px solid var(--border); border-radius: var(--r-ctl); overflow: hidden; margin-bottom: var(--s4); }
.kbcell { flex: 1; text-align: center; padding: 10px 6px; }
.kbcell:not(:last-child) { border-right: 1px solid var(--border); }
.kbval { font-size: 17px; font-weight: 500; color: var(--primary); }
.kblbl { font-size: 10px; color: var(--text2); margin-top: 2px; }
.rec-note { background: var(--m-b-bg); border-radius: var(--r-ctl); padding: 12px 14px; font-size: 13px; color: var(--m-b-fg); margin-bottom: var(--s4); line-height: 1.5; }
.rec-sec { font-size: 12px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin: var(--s4) 0 var(--s2); }
.rec-ing { padding-left: 18px; } .rec-ing li { font-size: 14px; margin-bottom: 5px; line-height: 1.4; }
.rec-steps { padding-left: 18px; } .rec-steps li { font-size: 14px; margin-bottom: 9px; line-height: 1.55; }

/* ── PROFILES ────────────────────────────────────────── */
.proflist { display: flex; flex-direction: column; gap: var(--s3); }
.profcard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: var(--s4); transition: border-color var(--ease), box-shadow var(--ease);
}
.profcard:hover { border-color: var(--border-h); box-shadow: var(--shadow); }
.prof-acts { display: flex; gap: var(--s2); margin-top: var(--s3); }
.prof-act {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 6px 12px; border-radius: var(--r-pill); cursor: pointer;
  background: var(--bg2, transparent); border: 1px solid var(--border); color: var(--text);
  transition: border-color var(--ease), background var(--ease);
}
.prof-act:hover { border-color: var(--border-h); }
.prof-act.danger { color: var(--err); border-color: var(--err-soft); }
.prof-act.danger:hover { background: var(--err-soft); border-color: var(--err); }
.prof-act .ic svg { width: 15px; height: 15px; }
.prof-hd { display: flex; align-items: baseline; gap: var(--s2); margin-bottom: var(--s2); }
.prof-name { font-size: 16px; font-weight: 500; }
.prof-age  { font-size: 12px; color: var(--text2); }
.prof-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11px; padding: 3px 10px; border-radius: var(--r-pill); }
.chip.like    { background: var(--acc-l); color: var(--acc-d); }
.chip.dislike { background: var(--err-soft); color: var(--err); }
.chip.restr   { background: var(--m-b-bg); color: var(--m-b-fg); }
.prof-notes { font-size: 12px; color: var(--text2); margin-top: var(--s2); line-height: 1.4; }

/* ── SETTINGS ────────────────────────────────────────── */
.setcard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: var(--s4); margin-bottom: var(--s3); display: flex; flex-direction: column; gap: var(--s2);
}
.set-lbl { font-size: 14px; font-weight: 500; }
.set-val { font-size: 15px; }
.set-hint { font-size: 12px; color: var(--text2); line-height: 1.5; }
.set-hint code, .set-val code { background: var(--bg2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.set-note { font-size: 12px; color: var(--acc-d); background: var(--acc-l); border-radius: var(--r-ctl); padding: 8px 10px; }
.set-foot { text-align: center; color: var(--text2); font-size: 12px; padding: 18px 0; }
.set-status { font-size: 13px; font-weight: 500; margin: 2px 0 4px; }
.set-status.ok  { color: var(--accent); }
.set-status.off { color: var(--text2); }

/* ── MODAL ───────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(43,36,32,.40);
  display: flex; align-items: center; justify-content: center; z-index: 500; padding: var(--s4);
  opacity: 0; transition: opacity .18s ease;
}
.overlay.on { opacity: 1; }
.modal {
  background: var(--card); border-radius: 18px; padding: 20px; width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 16px 48px rgba(43,36,32,.18);
  display: flex; flex-direction: column; gap: 11px;
  animation: modal-in 180ms ease both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-title { font-size: 18px; font-weight: 500; }
.field-lbl { font-size: 12px; color: var(--text2); display: flex; flex-direction: column; gap: 5px; }
.rf-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.kbrow { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--s2); }
.kbrow label { font-size: 11px; color: var(--text2); display: flex; flex-direction: column; gap: 3px; }
.kbrow input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 6px;
  font-size: 14px; text-align: center; background: var(--card); color: var(--text);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.kbrow input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--acc-soft); }
.modal-btns { display: flex; gap: var(--s2); margin-top: var(--s1); }
.mbtn {
  flex: 1; padding: 12px; border-radius: var(--r-ctl); border: none; font-size: 14px; font-weight: 500;
  cursor: pointer; min-height: var(--tap); transition: background var(--ease), transform var(--ease);
}
.mbtn:active { transform: scale(.98); }
.mbtn.cancel { background: var(--bg2); color: var(--text2); }
.mbtn.save { background: var(--primary); color: #fff; }
.mbtn.save:hover { background: var(--ph); }
.mbtn.danger { background: var(--err); color: #fff; }

/* ── MISC ────────────────────────────────────────────── */
.empty { text-align: center; color: var(--text2); font-size: 14px; padding: 40px 20px; line-height: 1.6; }
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--text); color: #fff; padding: 11px 20px; border-radius: var(--r-pill); font-size: 13px;
  opacity: 0; transition: opacity .25s ease, transform .25s ease; z-index: 2000; pointer-events: none;
  white-space: nowrap; max-width: 90vw; box-shadow: var(--shadow-h);
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── ASSISTANT / CHAT ────────────────────────────────── */
.chat {
  position: fixed; left: 0; right: 0;
  top: calc(46px + env(safe-area-inset-top));
  bottom: calc(54px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; max-width: 1200px; margin: 0 auto;
}
.chat-log {
  flex: 1; overflow-y: auto; padding: var(--s4) var(--s3) var(--s2);
  display: flex; flex-direction: column; gap: 10px;
}
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; line-height: 1.45; font-size: 15px; animation: fade-in 160ms ease both; }
.bubble-who { font-size: 11px; font-weight: 500; opacity: .6; margin-bottom: 2px; }
.bubble-text { white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble.me .bubble-who { color: #fff; }
.bubble.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.typing .bubble-text { letter-spacing: 2px; opacity: .5; }

.chat-welcome { margin: auto; text-align: center; color: var(--text2); padding: 20px; }
.cw-emoji { font-size: 44px; }
.cw-title { font-size: 18px; font-weight: 500; color: var(--text); margin: var(--s2) 0 4px; }
.cw-sub { font-size: 14px; line-height: 1.5; max-width: 420px; margin: 0 auto var(--s4); }
.cw-suggs { display: flex; flex-direction: column; gap: var(--s2); max-width: 420px; margin: 0 auto; }
.chat-sugg {
  text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-ctl);
  padding: 11px 14px; font-size: 14px; color: var(--text); cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}
.chat-sugg:hover { border-color: var(--border-h); background: var(--bg2); }
.chat-sugg:active { background: var(--acc-soft); }

.chat-bar {
  display: flex; gap: var(--s2); align-items: flex-end; padding: 8px 10px;
  border-top: 1px solid var(--border); background: var(--card);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.chat-input {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 20px;
  padding: 10px 14px; font-size: 15px; max-height: 120px; background: var(--bg); color: var(--text);
  font-family: inherit; line-height: 1.4; transition: border-color var(--ease), box-shadow var(--ease);
}
.chat-send {
  flex: 0 0 auto; width: var(--tap); height: var(--tap); border-radius: 50%; border: none;
  background: var(--primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background var(--ease), transform var(--ease);
}
.chat-send .ic { width: 20px; height: 20px; }
.chat-send:hover { background: var(--ph); }
.chat-send:active { transform: scale(.94); }
.chat-send:disabled { opacity: .5; }
.chat-mic {
  flex: 0 0 auto; width: var(--tap); height: var(--tap); border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg); color: var(--text2);
  cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.chat-mic .ic { width: 20px; height: 20px; }
.chat-mic.unsupported { opacity: .4; }
.chat-mic.listening {
  background: var(--primary); color: #fff; border-color: var(--primary);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 100, 59, .5); }
  50% { box-shadow: 0 0 0 6px rgba(226, 100, 59, 0); }
}

/* ── ADMIN ANALYTICS (owner-only) ────────────────────── */
.admin-head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s4); }
.admin-head .screen-title { margin-bottom: 0; }
.acards { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
.acard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: var(--s3); text-align: center;
}
.acard-ic  { font-size: 18px; }
.acard-val { font-size: 22px; font-weight: 500; color: var(--primary); line-height: 1.2; }
.acard-lbl { font-size: 11px; color: var(--text2); margin-top: 2px; }
.apanel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: var(--s4); margin-bottom: var(--s4);
}
.apanel-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.apanel-sub   { font-size: 12px; color: var(--text2); margin-bottom: var(--s3); }
.achart { display: flex; align-items: flex-end; gap: 2px; height: 80px; margin-top: var(--s2); }
.abar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.abar-fill { width: 100%; min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; }
.abar-fill[style*="height:0%"] { background: var(--border); }
.aprog { margin-bottom: var(--s3); }
.aprog:last-child { margin-bottom: 0; }
.aprog-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.aprog-lbl { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.aprog-num { color: var(--text2); font-weight: 500; }
.aprog-bar { height: 8px; background: var(--bg2); border-radius: var(--r-pill); overflow: hidden; }
.aprog-fill { height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.aprog-fill.over { background: var(--primary); }
.atbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.atbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.atbl th, .atbl td { padding: 8px; text-align: left; white-space: nowrap; }
.atbl thead th { color: var(--text2); font-weight: 500; border-bottom: 1px solid var(--border); }
.atbl tbody tr { border-bottom: 1px solid var(--border); }
.atbl tbody tr:last-child { border-bottom: none; }
.atbl-email { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.atbl-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── ONBOARDING (first-run quiz: chat with no bottom tabbar) ── */
.onb-shell .chat { bottom: env(safe-area-inset-bottom); }
.onb-skip {
  background: none; border: none; color: var(--text2); font-size: 13px;
  cursor: pointer; padding: 6px 8px; text-decoration: underline; min-height: var(--tap);
}
.onb-skip:active { color: var(--text); }

/* respect users who ask for less motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
