:root{
  --bg:#0b1120; --card:#131c30; --card2:#1b2740; --line:#243049;
  --txt:#e6edf7; --muted:#8a98b3; --accent:#34d399; --accent2:#38bdf8;
  --warn:#fbbf24; --danger:#f87171; --pro:#a78bfa;
  --radius:18px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
/* Removes the ~300ms tap-delay on mobile browsers and prevents text selection
   on quick taps — buttons fire on the FIRST press, not the second. */
button, label.photo-btn, .auth-tab, .add-tab, .toggle-btn, .scale-btns button, .nav-btn, .lang-btn, .au-btn{
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
/* Visible press feedback so the user SEES their tap registered before any
   network roundtrip completes. */
button:active, .scale-btns button:active{transform: scale(0.97); opacity: 0.85}
/* The HTML `hidden` attribute must always win over class display rules
   (e.g. .spinner-overlay/.result-card use display:flex). Without this the
   spinner overlay stays on screen forever. */
[hidden]{display:none !important}
/* Auto-detect text direction per field so Hebrew snaps right and English left.
   (`direction:auto` is invalid CSS — `unicode-bidi:plaintext` is the real fix.) */
input, textarea { unicode-bidi: plaintext; text-align: start; }
html,body{margin:0;padding:0}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  background:var(--bg); color:var(--txt);
  padding-bottom:env(safe-area-inset-bottom);
}
h1,h2,h3{margin:0}
.muted{color:var(--muted)}
.small{font-size:13px}
.center{text-align:center}
.spacer{height:90px}

/* ---------- Login ---------- */
.login-body{display:flex;align-items:center;justify-content:center;min-height:100vh}
.login-card{background:var(--card);padding:36px 28px;border-radius:24px;width:300px;text-align:center;border:1px solid var(--line)}
.login-card .logo{font-size:48px}
.login-card h1{margin:8px 0 2px;font-size:26px}
.login-card form{margin-top:22px;display:flex;flex-direction:column;gap:12px}
.login-card input,button{font-size:16px}
.login-card input{padding:14px;border-radius:12px;border:1px solid var(--line);background:var(--card2);color:var(--txt)}
.login-card button{padding:14px;border:none;border-radius:12px;background:var(--accent);color:#04221a;font-weight:700}
.error{color:var(--danger)}
.success{color:var(--accent);font-size:14px;line-height:1.5;background:rgba(52,211,153,.08);border:1px solid var(--accent);border-radius:10px;padding:10px 12px;margin-top:14px}
.auth-tabs{display:flex;gap:6px;background:var(--card2);border-radius:10px;padding:4px;margin-bottom:18px}
.auth-tab{flex:1;text-align:center;padding:9px;text-decoration:none;color:var(--muted);border-radius:7px;font-weight:600;font-size:14px}
.auth-tab.active{background:var(--card);color:var(--accent)}
.auth-link{display:block;text-align:center;color:var(--muted);font-size:13px;margin-top:14px;text-decoration:none}
.auth-link:hover{color:var(--accent)}
.consent{display:flex;align-items:flex-start;gap:8px;text-align:left;font-size:12px;line-height:1.45;color:var(--muted);padding:4px 2px}
.consent input[type=checkbox]{margin-top:2px;flex-shrink:0;width:16px;height:16px;cursor:pointer}
.consent a{color:var(--accent2);text-decoration:underline}
.auth-footer{margin-top:18px;padding-top:14px;border-top:1px solid var(--line);text-align:center;font-size:12px}
.auth-footer a{color:var(--muted);text-decoration:none;margin:0 4px}
.auth-footer a:hover{color:var(--accent2)}

/* ---------- Profile bar ---------- */
#app{padding-top:50px}
.profile-bar{position:fixed;top:0;left:0;right:0;height:50px;display:flex;align-items:center;justify-content:center;background:rgba(15,23,42,.95);backdrop-filter:blur(10px);border-bottom:1px solid var(--line);z-index:45}
.profile-chip{display:flex;align-items:center;gap:8px;background:var(--card);border:1px solid var(--line);border-radius:999px;padding:5px 14px 5px 5px;color:var(--txt);font-weight:600;max-width:80%}
.profile-chip .avatar{width:30px;height:30px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#04221a;font-weight:800;font-size:14px}
.admin-badge{background:linear-gradient(135deg,#facc15,#f97316);color:#1f1300;font-size:10px;font-weight:800;letter-spacing:.5px;padding:3px 8px;border-radius:6px}

/* Admin users list */
.admin-users{display:flex;flex-direction:column;gap:8px}
.admin-user-row{background:var(--card2);border:1px solid var(--line);border-radius:12px;padding:10px 12px;display:flex;align-items:center;gap:10px}
.admin-user-row .avatar{width:34px;height:34px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#04221a;font-weight:800;flex:none}
.admin-user-row .au-main{flex:1;min-width:0}
.admin-user-row .au-name{font-weight:700}
.admin-user-row .au-sub{color:var(--muted);font-size:12px}
.admin-user-row .au-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.admin-user-row .au-btn{background:var(--card);border:1px solid var(--line);color:var(--txt);padding:6px 10px;border-radius:8px;font-size:12px;font-weight:600}
.admin-user-row .au-btn.danger{color:var(--danger);border-color:var(--danger)}
.admin-user-row .au-tag{display:inline-block;background:rgba(250,204,21,.15);color:#facc15;font-size:10px;font-weight:700;padding:1px 6px;border-radius:4px;margin-left:6px}
.admin-user-row .au-tag.pending-tag{background:rgba(56,189,248,.15);color:var(--accent2)}
.admin-user-row.pending{border-color:var(--accent2);background:rgba(56,189,248,.06)}
.admin-user-row .au-btn.approve{background:var(--accent);color:#04221a;border-color:var(--accent);font-weight:800}
.pending-header{color:var(--accent2);font-weight:700;font-size:13px;padding:4px 2px;text-transform:uppercase;letter-spacing:.4px}
.pending-divider{height:1px;background:var(--line);margin:4px 0 8px}

/* Language dropdown */
.lang-select{font-size:15px;font-weight:600}

/* ---------- Ingredients (Add screen → Food tab) ---------- */
.ingredient-block{margin-top:22px;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px;display:flex;flex-direction:column;gap:10px}
.ing-head{display:flex;justify-content:space-between;align-items:center}
.ing-head-title{font-weight:700;font-size:14px}
.ing-search{font-size:14px}
.ing-list{display:flex;flex-direction:column;gap:8px;max-height:340px;overflow-y:auto}
.ing-item{background:var(--card2);border:1px solid var(--line);border-radius:12px;padding:10px 14px;display:flex;justify-content:space-between;align-items:center;cursor:pointer}
.ing-item:active{transform:scale(0.99);opacity:.85}
.ing-item .ing-name{font-weight:700}
.ing-item .ing-macros{color:var(--muted);font-size:12px;margin-top:2px}
.ing-item .ing-cal{font-weight:800;color:var(--accent);white-space:nowrap}
.ing-empty{color:var(--muted);font-size:13px;text-align:center;padding:14px 0}

.ing-fields{display:flex;flex-direction:column;gap:8px}
.ing-grams-label{color:var(--muted);font-size:12px;display:block;margin-top:4px}
.ing-calc-preview{background:linear-gradient(135deg,#10241d,#13233a);border:1px solid var(--accent);border-radius:12px;padding:14px;color:var(--accent);font-weight:800;font-size:18px;text-align:center}

/* ---------- Steps screen (Google Health) ---------- */
.big-emoji{font-size:54px;text-align:center;margin:32px 0 6px}
.steps-disconnected{text-align:center;padding:10px 6px}
.steps-disconnected h3{margin-bottom:8px}
.steps-card{background:linear-gradient(135deg,#10241d,#13233a);border:1px solid var(--accent);border-radius:var(--radius);padding:22px 18px}
.steps-big{text-align:center;margin-bottom:18px}
.steps-count{font-size:54px;font-weight:800;color:var(--accent);line-height:1}
.steps-label{color:var(--muted);font-size:13px;margin-top:4px}
.steps-meta{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:14px}
.steps-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.steps-actions .primary{flex:0 0 auto;padding:10px 16px}

/* Google Health section in Settings */
.gh-status{display:flex;align-items:center;gap:8px;padding:10px 12px;background:var(--card);border:1px solid var(--line);border-radius:12px;margin:6px 0}
.gh-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);flex:none}
.gh-dot.on{background:var(--accent);box-shadow:0 0 0 4px rgba(52,211,153,.18)}
.gh-buttons{display:flex;gap:8px;flex-wrap:wrap}
.gh-buttons .primary{text-decoration:none;display:inline-flex;align-items:center;justify-content:center;padding:12px 14px}
.gh-toggle{display:flex;align-items:center;gap:10px;margin-top:8px;padding:10px 12px;background:var(--card2);border:1px solid var(--line);border-radius:10px;font-size:14px;cursor:pointer}
.gh-toggle input{width:18px;height:18px}

/* Auto-direction for translated text: layout stays LTR, but Hebrew text
   reads right-to-left within its element. */
[data-i18n], [data-i18n-placeholder]{unicode-bidi:plaintext;text-align:start}
.profile-backdrop{position:fixed;inset:0;z-index:46}
.profile-menu{position:fixed;top:54px;left:50%;transform:translateX(-50%);width:min(340px,92%);background:var(--card);border:1px solid var(--line);border-radius:16px;padding:10px;z-index:47;box-shadow:0 12px 30px rgba(0,0,0,.45);display:flex;flex-direction:column;gap:6px}
.pm-title{color:var(--muted);font-size:12px;padding:4px 6px}
.pm-item{display:flex;align-items:center;gap:10px;padding:10px;border-radius:12px;background:var(--card2);border:1px solid transparent;cursor:pointer}
.pm-item.active{border-color:var(--accent)}
.pm-item .avatar{width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#04221a;font-weight:800;flex:none}
.pm-item .pm-name{flex:1;font-weight:600}
.pm-item .pm-del{background:none;border:none;color:var(--danger);font-size:16px;padding:6px 8px}
.pm-item .pm-check{color:var(--accent);font-weight:800}
.pm-add{margin-top:4px}

/* ---------- Screens ---------- */
.screen{display:none;padding:14px 16px 0;max-width:560px;margin:0 auto}
.screen.active{display:block}
.topbar{display:flex;align-items:center;justify-content:space-between;padding:8px 0 14px}
.topbar h2{font-size:22px}
.icon-btn{background:var(--card);border:1px solid var(--line);color:var(--txt);width:38px;height:38px;border-radius:12px;font-size:22px;line-height:1}
.date-pick{display:flex;flex-direction:column;align-items:center}
.date-pick input[type=date]{background:transparent;border:none;color:var(--muted);font-size:12px;text-align:center}

/* ---------- Rings ---------- */
.rings{display:flex;gap:12px}
.ring-card{flex:1;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px;text-align:center}
.ring{
  width:96px;height:96px;border-radius:50%;margin:0 auto 8px;
  display:flex;align-items:center;justify-content:center;font-size:22px;font-weight:800;
  background:conic-gradient(var(--accent) 0deg, var(--card2) 0deg);
  position:relative;
}
.ring.protein{background:conic-gradient(var(--pro) 0deg, var(--card2) 0deg)}
.ring::before{content:"";position:absolute;inset:9px;background:var(--card);border-radius:50%}
.ring span{position:relative;z-index:1}
.ring-label{font-weight:600}
.ring-sub{color:var(--muted);font-size:13px}

/* ---------- Stat grids ---------- */
.stat-grid,.avg-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin-top:14px}
.stat{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:12px}
.stat-val{font-size:20px;font-weight:800}
.stat-key{color:var(--muted);font-size:12px;margin-top:2px}

.reco-card{margin-top:14px;background:linear-gradient(135deg,#10241d,#13233a);border:1px solid var(--accent);border-radius:var(--radius);padding:14px 16px;display:flex;align-items:center;justify-content:space-between;gap:10px}
.reco-label{color:var(--muted);font-size:12px}
.reco-val{font-size:30px;font-weight:800;color:var(--accent)}
.reco-rem{text-align:center;white-space:nowrap}
.reco-rem span{font-size:22px;font-weight:800}
.reco-rem-key{color:var(--muted);font-size:11px}

.end-day-btn{width:100%;margin-top:20px}
.review-card{margin-top:14px;background:var(--card);border:1px solid var(--accent2);border-radius:var(--radius);padding:14px 16px}
.review-head{display:flex;align-items:center;justify-content:space-between;font-weight:700;margin-bottom:10px}
.review-text{white-space:pre-wrap;line-height:1.55}
.review-chat{margin-top:14px;border-top:1px solid var(--line);padding-top:12px}
.review-log{display:flex;flex-direction:column;gap:8px;max-height:340px;overflow-y:auto;margin-bottom:8px}
.review-log:empty{display:none}
.review-input{display:flex;gap:8px;align-items:flex-end}
.review-input textarea{flex:1;resize:none;max-height:120px;overflow-y:auto;line-height:1.4}
.review-input button{width:48px;height:46px;flex:none;border:none;border-radius:12px;background:var(--accent);color:#04221a;font-size:18px}
button.ghost.mini{padding:6px 12px;font-size:13px}

.day-tdee{margin-top:14px;background:var(--card);border:1px solid var(--line);border-radius:14px;padding:12px 14px;display:flex;flex-direction:column;gap:8px}
.day-tdee-label{font-size:13px;color:var(--muted)}
.tdee-edit{display:flex;gap:8px}
.tdee-edit input{flex:1}
.tdee-edit button{white-space:nowrap}

.section-title{margin:22px 0 8px;font-size:15px;color:var(--muted);text-transform:uppercase;letter-spacing:.5px}

/* ---------- Entry list ---------- */
.entry-list{display:flex;flex-direction:column;gap:8px}
.entry{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:12px 14px;display:flex;justify-content:space-between;align-items:center}
.entry .e-main{flex:1;min-width:0}
.entry .e-name{font-weight:600}
.entry .e-macros{color:var(--muted);font-size:12px;margin-top:3px}
.entry .e-cal{font-weight:800;font-size:16px;margin-left:10px;white-space:nowrap}
.entry{cursor:pointer}
.entry .chev{color:var(--muted);font-size:18px;margin-left:8px}
.entry .del{background:none;border:none;color:var(--danger);font-size:20px;padding:6px 10px;margin-left:4px}
.empty{color:var(--muted);font-size:14px;padding:8px 2px}

/* ---------- Toggle ---------- */
.toggle,.add-tabs{display:flex;background:var(--card);border-radius:12px;padding:4px;gap:4px;margin-bottom:14px;border:1px solid var(--line)}
.toggle-btn,.add-tab{flex:1;padding:10px;border:none;background:transparent;color:var(--muted);border-radius:9px;font-size:14px;font-weight:600;transition: all 0.15s}
.toggle-btn.active{background:var(--card2);color:var(--txt)}
/* The Add screen tab must POP so the user can tell at a glance which mode
   they're in (Food vs Workout vs Saved). Bold ring + accent color + filled
   background — impossible to confuse with the inactive tabs. */
.add-tab.active{
  background: rgba(52,211,153,.18);
  color: var(--accent);
  font-weight: 800;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: 0 0 12px rgba(52,211,153,.25);
}

/* ---------- Charts ---------- */
.chart-wrap{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:12px;margin-bottom:14px}

/* ---------- Add forms ---------- */
.add-pane{display:none;flex-direction:column;gap:12px}
.add-pane.active{display:flex}
.photo-btn{background:var(--card2);border:1px dashed var(--line);border-radius:14px;padding:22px;text-align:center;font-weight:600;cursor:pointer}
.preview{width:100%;max-height:220px;object-fit:cover;border-radius:14px}
.photo-row{display:flex;gap:10px}
.photo-btn.half{flex:1;padding:18px 8px}
.previews{display:flex;gap:10px;flex-wrap:wrap}
.previews .thumb{position:relative;width:74px;height:74px}
.previews .thumb img{width:74px;height:74px;object-fit:cover;border-radius:10px;border:1px solid var(--line)}
.thumb-x{position:absolute;top:-7px;right:-7px;background:var(--danger);color:#fff;border:none;border-radius:50%;width:22px;height:22px;font-size:12px;line-height:1;display:flex;align-items:center;justify-content:center}
input[type=text],input[type=number],input[type=password],textarea,select{
  width:100%;padding:13px;border-radius:12px;border:1px solid var(--line);
  background:var(--card);color:var(--txt);font-size:16px;font-family:inherit
}
button.primary{background:var(--accent);color:#04221a;border:none;padding:14px;border-radius:12px;font-weight:700;font-size:16px}
button.ghost{background:var(--card);color:var(--txt);border:1px solid var(--line);padding:13px;border-radius:12px;font-weight:600}
.or{text-align:center;color:var(--muted);font-size:13px;margin:2px 0}

.result-card{background:var(--card);border:1px solid var(--accent);border-radius:var(--radius);padding:14px;display:flex;flex-direction:column;gap:10px}
.res-name{font-weight:700}
.macro-row{display:flex;gap:8px}
.macro-row label{flex:1;display:flex;flex-direction:column;font-size:12px;color:var(--muted);gap:4px}
.items-break{display:flex;flex-direction:column;gap:6px;border-top:1px solid var(--line);padding-top:10px}
.items-title{font-size:12px;color:var(--muted);margin-bottom:2px}
.break-row{display:flex;justify-content:space-between;gap:10px;font-size:13px}
.break-row .b-name{flex:1;min-width:0}
.break-row .b-amt{color:var(--muted)}
.break-row .b-val{white-space:nowrap;color:var(--accent)}
.result-actions{display:flex;gap:8px}
.result-actions .primary{flex:2}.result-actions .ghost{flex:1}

/* ---------- Chat ---------- */
#screen-chat{display:none;flex-direction:column;height:calc(100vh - 50px);padding-bottom:0}
#screen-chat.active{display:flex}
.chat-log{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:14px;padding:10px 2px 14px}
/* Bubble base — softer corners, breathing room, no stiff line-height */
.bubble{max-width:84%;padding:12px 15px;border-radius:18px;line-height:1.55;word-wrap:break-word;font-size:15px}
.bubble .bubble-text{white-space:normal}  /* markdown handles wrapping */
.bubble.user{
  align-self:flex-end;
  background:linear-gradient(135deg,var(--accent2) 0%,#34d399 100%);
  color:#04222e;
  border-bottom-right-radius:6px;
  box-shadow:0 2px 10px rgba(52,211,153,.15);
}
.bubble.bot{
  align-self:flex-start;
  background:var(--card);
  border:1px solid var(--line);
  border-bottom-left-radius:6px;
  position:relative;
  padding-left:46px;  /* room for avatar */
}
/* Bot avatar — small gradient gem on the left */
.bubble.bot::before{
  content:"";
  position:absolute;
  left:10px;top:11px;
  width:26px;height:26px;
  border-radius:50%;
  background:conic-gradient(from 45deg,#a78bfa,#60a5fa,#34d399,#fbbf24,#f472b6,#a78bfa);
  box-shadow:0 0 0 2px var(--card),0 0 12px rgba(167,139,250,.4);
}
.bubble.bot::after{
  content:"✦";
  position:absolute;
  left:14px;top:13px;
  font-size:14px;
  color:#fff;
  pointer-events:none;
  font-weight:700;
}
/* RTL flip for Hebrew chats */
[dir="rtl"] .bubble.bot,
.bubble.bot[dir="rtl"]{padding-left:15px;padding-right:46px}
[dir="rtl"] .bubble.bot::before,
.bubble.bot[dir="rtl"]::before{left:auto;right:10px}
[dir="rtl"] .bubble.bot::after,
.bubble.bot[dir="rtl"]::after{left:auto;right:14px}
/* Markdown inside bubbles */
.bubble .bubble-text p{margin:0 0 8px 0}
.bubble .bubble-text p:last-child{margin-bottom:0}
.bubble .bubble-text strong{color:var(--accent);font-weight:700}
.bubble.user .bubble-text strong{color:#04221a}
.bubble .bubble-text em{font-style:italic;opacity:.92}
.bubble .bubble-text .md-list{margin:6px 0;padding-inline-start:22px}
.bubble .bubble-text .md-list li{margin:3px 0;line-height:1.5}
.bubble .bubble-text .md-code{
  background:var(--card2);
  border:1px solid var(--line);
  border-radius:5px;
  padding:1px 6px;
  font-family:"SF Mono","Menlo",monospace;
  font-size:13px;
  color:var(--accent2);
}
.bubble.user .bubble-text .md-code{background:rgba(4,34,46,.18);border-color:rgba(4,34,46,.25);color:#04221a}
.chat-compose{padding:8px 0 calc(90px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:8px}
/* New input: one pill-shaped capsule containing icons + textarea + send */
.chat-input{
  display:flex;gap:4px;align-items:center;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:26px;
  padding:4px 4px 4px 4px;
  transition:border-color .15s, box-shadow .15s;
}
.chat-input:focus-within{
  border-color:var(--accent2);
  box-shadow:0 0 0 3px rgba(52,211,153,.12);
}
.chat-input textarea{
  flex:1;resize:none;max-height:140px;overflow-y:auto;line-height:1.45;
  padding:10px 8px;
  background:transparent;
  border:none;outline:none;
  font-size:15px;
  color:var(--txt);
}
.chat-input button#chatSend{
  width:42px;height:42px;flex:none;border:none;border-radius:50%;
  background:linear-gradient(135deg,var(--accent) 0%,var(--accent2) 100%);
  color:#04221a;font-size:18px;font-weight:700;
  display:flex;align-items:center;justify-content:center;
  transition:transform .12s;
}
.chat-input button#chatSend:active{transform:scale(.92)}
.chat-icon-btn{
  width:38px;height:38px;flex:none;
  display:flex;align-items:center;justify-content:center;
  background:transparent;
  border:none;
  border-radius:50%;
  font-size:18px;cursor:pointer;color:var(--muted);
  transition:background .12s,color .12s;
}
.chat-icon-btn:hover{background:var(--card2);color:var(--txt)}
#chatMic.recording{background:var(--danger);color:#fff;animation:micPulse 1s infinite}
@keyframes micPulse{0%,100%{box-shadow:0 0 0 0 rgba(248,113,113,.5)}50%{box-shadow:0 0 0 8px rgba(248,113,113,0)}}
.bubble-speak{background:none;border:none;color:var(--accent2);font-size:14px;padding:2px 6px;margin-top:2px;cursor:pointer;opacity:.7}
.bubble-speak:hover{opacity:1}
.bubble-audio{display:flex;align-items:center;gap:8px;background:var(--card2);border-radius:10px;padding:6px 8px;margin-bottom:6px}
.bubble-audio audio{flex:1;height:28px}
.ing-quick-row{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0 8px}
.ing-quick-chip{background:var(--card2);border:1px solid var(--line);border-radius:999px;padding:5px 11px;font-size:13px;color:var(--txt);cursor:pointer}
.ing-quick-chip:hover{border-color:var(--accent2);color:var(--accent2)}
.ing-unit-row{display:flex;gap:8px;margin:10px 0 6px}
.ing-unit-btn{flex:1;background:var(--card2);border:1px solid var(--line);border-radius:10px;padding:9px 8px;font-size:14px;font-weight:600;color:var(--txt);cursor:pointer;transition:.15s}
.ing-unit-btn.active{background:var(--accent2);color:#04201a;border-color:var(--accent2);box-shadow:0 0 0 1px var(--accent2)}
.reauth-banner{background:rgba(248,113,113,.1);border:1px solid rgba(248,113,113,.4);border-radius:12px;padding:14px;margin:12px 0;display:flex;flex-direction:column;gap:10px;align-items:stretch}
.reauth-text{color:var(--txt);font-size:14px;line-height:1.45}
.reauth-btn{display:inline-block;text-align:center;text-decoration:none;padding:11px 14px;border-radius:10px;font-weight:700}
.qty-row{display:flex;align-items:center;gap:8px;margin:6px 0 10px;flex-wrap:wrap}
.qty-label{font-size:13px;color:var(--muted);font-weight:600;min-width:60px}
.qty-btn{width:38px;height:38px;border-radius:10px;background:var(--card2);border:1px solid var(--line);color:var(--txt);font-size:22px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1}
.qty-btn:active{transform:scale(.94);background:var(--accent2);color:#04201a}
.qty-input{width:64px;height:38px;text-align:center;font-size:16px;font-weight:700;background:var(--card2);border:1px solid var(--line);border-radius:10px;color:var(--txt)}
.qty-unit{font-size:13px;color:var(--muted);font-weight:600}
.xsmall{font-size:11px;line-height:1.35;opacity:.7}

/* Reply bar above input */
.reply-bar{display:flex;align-items:center;gap:8px;background:var(--card);border:1px solid var(--line);border-radius:12px;padding:8px 10px}
.reply-bar-line{width:3px;align-self:stretch;background:var(--accent);border-radius:2px}
.reply-bar-text{flex:1;min-width:0;overflow:hidden}
.reply-bar-who{font-size:11px;color:var(--accent);font-weight:700;text-transform:uppercase;letter-spacing:.4px}
.reply-bar-preview{font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* Attached images thumbnails above input */
.chat-attachments{display:flex;gap:6px;flex-wrap:wrap}
.chat-attachments:empty{display:none}
.chat-attachments .thumb{position:relative;width:62px;height:62px}
.chat-attachments .thumb img{width:62px;height:62px;object-fit:cover;border-radius:10px;border:1px solid var(--line)}
.chat-attachments .thumb-x{position:absolute;top:-6px;right:-6px;background:var(--danger);color:#fff;border:none;border-radius:50%;width:20px;height:20px;font-size:11px;line-height:1;display:flex;align-items:center;justify-content:center}

/* Bubble enhancements: reply preview + image + reply button */
.bubble{position:relative}
.bubble-quote{border-inline-start:3px solid var(--accent);background:rgba(52,211,153,.08);padding:5px 8px;border-radius:6px;margin-bottom:6px;font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.bubble-quote-who{color:var(--accent);font-weight:700;display:block;font-size:11px;text-transform:uppercase;letter-spacing:.4px}
.bubble-images{display:flex;flex-wrap:wrap;gap:4px;margin-bottom:6px}
.bubble-images img{max-width:240px;max-height:240px;border-radius:10px;cursor:pointer}
.bubble-reply-btn{position:absolute;top:-10px;right:-6px;background:var(--card);border:1px solid var(--line);color:var(--muted);width:26px;height:26px;border-radius:50%;font-size:13px;display:none;align-items:center;justify-content:center;cursor:pointer}
.bubble.user .bubble-reply-btn{right:auto;left:-6px}
.bubble:hover .bubble-reply-btn,
.bubble.show-reply .bubble-reply-btn{display:flex}
.bubble-time{display:block;color:var(--muted);font-size:10px;margin-top:4px;opacity:.7}

/* ---------- Settings ---------- */
.form{display:flex;flex-direction:column;gap:12px}
.logout{text-align:center;color:var(--danger);margin-top:8px;text-decoration:none}
.legal-links{text-align:center;margin-top:18px;padding-top:14px;border-top:1px solid var(--line);font-size:12px;color:var(--muted)}
.legal-links a{color:var(--muted);text-decoration:none;margin:0 4px}
.legal-links a:hover{color:var(--accent2)}

/* ---------- Bottom nav ---------- */
.bottom-nav{
  position:fixed;bottom:0;left:0;right:0;display:flex;justify-content:space-around;
  background:rgba(15,23,42,.92);backdrop-filter:blur(10px);border-top:1px solid var(--line);
  padding:8px 0 calc(8px + env(safe-area-inset-bottom));z-index:30;
}
.nav-btn{background:none;border:none;color:var(--muted);font-size:10px;display:flex;flex-direction:column;align-items:center;gap:2px;flex:1;padding:0 2px}
/* Only the FIRST span in each nav button is the icon; the optional second
   span is the translated label and must stay at the small font-size. */
.nav-btn > span:first-child{font-size:19px}
.nav-btn.active{color:var(--accent)}
.add-fab{color:#04221a}
.nav-btn.add-fab > span:first-child{background:var(--accent);width:48px;height:48px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:28px;margin-top:-18px;box-shadow:0 6px 16px rgba(52,211,153,.4)}

/* ---------- Toast + spinner ---------- */
.toast{position:fixed;bottom:100px;left:50%;transform:translateX(-50%);background:var(--card2);border:1px solid var(--line);padding:12px 18px;border-radius:12px;opacity:0;transition:.3s;pointer-events:none;z-index:50;max-width:90%}
.toast.show{opacity:1}
/* ---------- Edit modal ---------- */
.modal{position:fixed;inset:0;background:rgba(5,10,20,.7);display:flex;align-items:flex-end;justify-content:center;z-index:70;padding:0}
.modal-card{background:var(--card);border:1px solid var(--line);border-top-left-radius:22px;border-top-right-radius:22px;padding:20px 18px calc(20px + env(safe-area-inset-bottom));width:100%;max-width:560px;display:flex;flex-direction:column;gap:12px}
.modal-card h3{font-size:18px}
.quick-scale{display:flex;flex-direction:column;gap:6px}
.scale-btns{display:flex;gap:8px}
.scale-btns button{flex:1;padding:12px 0;border:1px solid var(--line);background:var(--card2);color:var(--txt);border-radius:10px;font-weight:600}
.scale-btns button.active{background:var(--accent);color:#04221a;border-color:var(--accent)}
.modal-actions{display:flex;gap:10px}
.modal-actions .primary{flex:2}
.danger-btn{flex:1;background:var(--card2);color:var(--danger);border:1px solid var(--danger);border-radius:12px;font-weight:700;padding:14px}

/* ---------- Calculation box (AI's math, shown under result) ---------- */
.calc-box{background:var(--card2);border:1px solid var(--line);border-radius:10px;padding:9px 12px;font-size:13px;color:var(--txt);line-height:1.45}
.calc-box:empty{display:none}

/* ---------- Exercise editor cards (used in Add + Edit modal) ---------- */
.ex-section{display:flex;flex-direction:column;gap:10px;margin-top:6px;border-top:1px solid var(--line);padding-top:12px}
.ex-section-head{display:flex;align-items:center;justify-content:space-between;font-weight:700}
.ex-list{display:flex;flex-direction:column;gap:10px}
.ex-list:empty + button + *,
.ex-list:empty{margin-bottom:0}
.ex-card{background:var(--card2);border:1px solid var(--line);border-radius:14px;padding:12px;display:flex;flex-direction:column;gap:10px}
.ex-head{display:flex;gap:8px;align-items:center}
.ex-head .ex-name{flex:1;background:transparent;border:none;border-bottom:1px solid var(--line);color:var(--txt);font-weight:700;font-size:15px;padding:6px 2px;text-align:start}
.ex-head .ex-cat{background:var(--card);border:1px solid var(--line);color:var(--txt);border-radius:8px;padding:4px 6px;font-size:12px}
.ex-head .ex-del{background:none;border:none;color:var(--danger);font-size:18px;padding:4px 8px}
.ex-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.ex-label{color:var(--muted);font-size:12px;width:60px;flex:none}
.set-pills{display:flex;flex-wrap:wrap;gap:6px;flex:1}
.set-pill{width:54px;text-align:center;padding:6px 4px;border:1px solid var(--line);background:var(--card);color:var(--txt);border-radius:8px;font-size:14px;font-weight:600}
.set-add,.set-rm{border:none;border-radius:8px;width:34px;height:34px;font-size:18px;line-height:1}
.set-add{background:var(--accent);color:#04221a}
.set-rm{background:transparent;color:var(--danger);border:1px solid var(--line);width:28px;height:28px;font-size:14px}
.cardio-body label,.ex-row label{display:flex;flex-direction:column;gap:4px;color:var(--muted);font-size:12px;flex:1}
.ex-notes{font-size:13px}
.small-btn{padding:8px 12px;font-size:13px}

/* ---------- Journal screen ---------- */
.journal-search{margin-bottom:10px;font-size:14px}
.j-pane{display:none;flex-direction:column;gap:10px}
.j-pane.active{display:flex}
.j-toggle{flex:1;padding:10px;border:none;background:transparent;color:var(--muted);border-radius:9px;font-size:14px;font-weight:600}
.j-toggle.active{background:var(--card2);color:var(--txt)}

.j-day-head{color:var(--muted);font-size:13px;font-weight:600;margin:10px 2px 4px;display:flex;justify-content:space-between}
.j-day-head .j-day-cal{color:var(--accent2)}
.j-wo-card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:12px 14px}
.j-wo-head{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:8px}
.j-wo-name{font-weight:700;font-size:15px}
.j-wo-meta{color:var(--muted);font-size:12px}
.j-ex-row{display:flex;justify-content:space-between;gap:8px;padding:6px 0;border-top:1px dashed var(--line);font-size:13px}
.j-ex-row:first-child{border-top:none}
.j-ex-name{font-weight:600;flex:1;min-width:0}
.j-ex-detail{color:var(--muted);text-align:end;white-space:nowrap}

.j-ex-item{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:14px;display:flex;align-items:center;gap:12px;cursor:pointer}
.j-ex-item:active{background:var(--card2)}
.j-ex-icon{width:38px;height:38px;border-radius:10px;background:var(--card2);display:flex;align-items:center;justify-content:center;font-size:18px;flex:none}
.j-ex-main{flex:1;min-width:0}
.j-ex-title{font-weight:700}
.j-ex-sub{color:var(--muted);font-size:12px}
.j-ex-best{color:var(--accent);font-weight:800;font-size:14px}

/* exercise history modal table */
.modal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px}
.ex-hist-row{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;padding:10px 0;border-top:1px solid var(--line)}
.ex-hist-row:first-child{border-top:none}
.ex-hist-date{font-weight:700;font-size:13px;color:var(--accent2);min-width:70px}
.ex-hist-detail{flex:1}
.ex-hist-headline{font-size:16px;font-weight:800;color:var(--accent);margin-bottom:4px}
.ex-hist-headline.is-pr{color:var(--accent2)}
.ex-hist-row.is-pr{background:rgba(74,222,128,.07);border-radius:8px;padding-left:6px;padding-right:6px;margin:0 -6px}
.ex-hist-sets{margin-top:2px}
.ex-hist-summary{display:flex;align-items:center;justify-content:space-between;background:var(--card2);border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin-bottom:12px;gap:10px;flex-wrap:wrap}
.ex-hist-summary-pr{font-size:15px;font-weight:700;color:var(--accent2)}
.set-chip{display:inline-block;background:var(--card2);border:1px solid var(--line);border-radius:6px;padding:2px 6px;margin:2px 4px 2px 0;font-size:12px;font-weight:600}
.set-chip b{color:var(--accent)}

/* z-index MUST be above .modal (70) so the spinner is visible while a modal
   is open — otherwise users tap Re-analyze and see nothing happen, then tap
   again, then again. */
.spinner-overlay{position:fixed;inset:0;background:rgba(5,10,20,.6);display:flex;align-items:center;justify-content:center;z-index:90}
.spinner{width:44px;height:44px;border:4px solid var(--card2);border-top-color:var(--accent);border-radius:50%;animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
