/* ============================================================
   FITPULSE — "Kinetic Obsidian" design system
   Dark-tech · Glassmorphism · Neon-Infused Minimalism
   ============================================================ */

:root {
  --bg: #131313;
  --surface-lowest: #0e0e0e;
  --surface-low: #1c1b1b;
  --surface: #201f1f;
  --surface-high: #2a2a2a;
  --surface-highest: #353534;
  --on-surface: #e5e2e1;
  --on-surface-variant: #c6c9ab;
  --outline: #909378;
  --outline-variant: #454932;

  --primary: #d2f000;        /* Electric Lime */
  --primary-dim: #b8d300;
  --on-primary: #191e00;
  --secondary: #00eefc;      /* Cyber Blue */
  --secondary-dim: #00dbe9;
  --on-secondary: #00363a;
  --tertiary: #ffb4ab;       /* Pulse Red */
  --error: #ffb4ab;

  --font-display: 'Montserrat', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --r-sm: 0.25rem;
  --r-md: 0.5rem;
  --r-lg: 0.75rem;
  --r-xl: 1rem;
  --r-full: 9999px;

  --glass-bg: rgba(32, 31, 31, 0.9);
  --ghost: rgba(255, 255, 255, 0.15);
  --ghost-soft: rgba(255, 255, 255, 0.08);

  --app-w: 448px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--primary); color: var(--on-primary); }

/* hide scrollbars (app feel) */
::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

a { color: var(--primary); text-decoration: none; }

/* ---------- App shell ---------- */
.app-shell {
  max-width: var(--app-w);
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
}
@media (min-width: 480px) {
  .app-shell { border-left: 1px solid var(--ghost-soft); border-right: 1px solid var(--ghost-soft); }
}

/* Ambient glow background */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.ambient-bg .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  mix-blend-mode: screen;
}
.ambient-bg .blob-lime { width: 380px; height: 380px; background: rgba(210,240,0,.07); top: -10%; right: -15%; animation: blobpulse 5s ease-in-out infinite; }
.ambient-bg .blob-blue { width: 420px; height: 420px; background: rgba(0,238,252,.06); bottom: -12%; left: -20%; animation: blobpulse 6s ease-in-out 2s infinite; }
@keyframes blobpulse { 0%,100% { opacity:.75; transform: scale(1);} 50% { opacity:1; transform: scale(1.08);} }

/* ---------- Typography helpers ---------- */
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--on-surface); letter-spacing: -0.01em; }
.display { font-family: var(--font-display); font-weight: 900; letter-spacing: -0.02em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--on-surface-variant); }
.muted.tiny { font-size: 11px; opacity: .75; }
.small { font-size: 12px; }

/* ---------- Glass card ---------- */
.glass-card, .card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--ghost);
  border-top-color: rgba(255,255,255,.22);
  border-left-color: rgba(255,255,255,.22);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
}
.neon-glow { box-shadow: 0 0 15px rgba(210,240,0,.3); }
.ghost-border { border: 1px solid var(--ghost); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  border: none;
  cursor: pointer;
  padding: 13px 18px;
  border-radius: var(--r-md);
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary, .btn-success {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 0 15px rgba(210,240,0,.28);
}
.btn-primary:hover, .btn-success:hover { background: var(--primary-dim); }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid rgba(210,240,0,.5);
}
.btn-ghost:hover { background: rgba(210,240,0,.08); }
.btn-danger {
  background: rgba(255,180,171,.1);
  color: var(--tertiary);
  border: 1px solid rgba(255,180,171,.4);
}
.btn-block { width: 100%; }
.btn-lg { padding: 16px 26px; font-size: 16px; border-radius: var(--r-full); }
.small-btn { padding: 8px 12px; font-size: 13px; }

/* ---------- Chips ---------- */
.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--secondary-dim);
  background: rgba(0,238,252,.1);
  border: 1px solid rgba(0,238,252,.2);
  padding: 4px 9px;
  border-radius: var(--r-full);
  white-space: nowrap;
}
.chip.lime, .chip.diff-easy { color: var(--primary); background: rgba(210,240,0,.1); border-color: rgba(210,240,0,.25); }
.chip.diff-intermediate { color: var(--secondary-dim); }
.chip.diff-hard, .chip.diff-advanced { color: var(--tertiary); background: rgba(255,180,171,.1); border-color: rgba(255,180,171,.25); }

/* ---------- Top app bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  height: 64px;
  background: rgba(19,19,19,.82);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--ghost);
  box-shadow: 0 0 15px rgba(210,240,0,.1);
}
.topbar-inner {
  max-width: var(--app-w);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 900; font-size: 18px; color: var(--bg);
  box-shadow: 0 0 15px rgba(210,240,0,.35);
}
.brandname {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.brandname span { color: var(--on-surface); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.xp-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary);
  background: rgba(210,240,0,.1);
  border: 1px solid rgba(210,240,0,.25);
  border-radius: var(--r-full);
  padding: 4px 10px;
  white-space: nowrap;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-highest);
  border: 1px solid var(--ghost);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  color: var(--primary);
  cursor: pointer;
}
.avatar.big { width: 56px; height: 56px; font-size: 24px; flex-shrink: 0; }

/* ---------- Flash toasts ---------- */
.flashes {
  position: fixed;
  top: 74px; left: 0; right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  pointer-events: none;
}
.flash {
  max-width: var(--app-w);
  width: 100%;
  font-size: 13px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: toast .3s ease;
  pointer-events: auto;
}
@keyframes toast { from { opacity: 0; transform: translateY(-8px);} to { opacity: 1; transform: none;} }
.flash-success { background: rgba(210,240,0,.12); border: 1px solid rgba(210,240,0,.4); color: var(--primary); }
.flash-error { background: rgba(255,180,171,.12); border: 1px solid rgba(255,180,171,.4); color: var(--tertiary); }

/* ---------- Content layout ---------- */
.content {
  flex: 1;
  padding: 80px 20px 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(14,14,14,.9);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--ghost);
  box-shadow: 0 -4px 20px rgba(0,0,0,.5);
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav-inner {
  max-width: var(--app-w);
  margin: 0 auto;
  height: 76px;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding: 0 8px;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: rgba(198,201,171,.55);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: color .2s ease;
}
.nav-item .nav-ic { font-size: 23px; line-height: 1; }
.nav-item:active { transform: scale(.9); }
.nav-item.active {
  color: var(--primary);
  filter: drop-shadow(0 0 8px rgba(210,240,0,.5));
}
.nav-item.active .nav-ic { font-variation-settings: 'FILL' 1; }

/* ---------- Dashboard ---------- */
.dash-hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.dash-hello h1 { font-size: 24px; font-weight: 700; }
.dash-hello .muted { font-size: 12.5px; margin-top: 2px; }
.streak-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-high);
  border: 1px solid rgba(210,240,0,.3);
  box-shadow: 0 0 15px rgba(210,240,0,.25);
  border-radius: var(--r-full);
  padding: 6px 12px;
  font-family: var(--font-display);
}
.streak-badge .big { font-size: 18px; font-weight: 900; color: var(--primary); }
.streak-badge small { font-family: var(--font-mono); font-size: 9px; color: var(--on-surface-variant); text-transform: uppercase; letter-spacing: .06em; }

/* Bento stat grid */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--ghost);
  border-top-color: rgba(255,255,255,.22);
  border-left-color: rgba(255,255,255,.22);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.stat-card.col-span-2 { grid-column: span 2; }
.stat-ic {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--ghost-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: 20px;
}
.stat-card.blue .stat-ic { color: var(--secondary); }
.stat-val { font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--on-surface); }
.stat-val small { font-size: 12px; color: var(--on-surface-variant); font-weight: 500; }
.stat-lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--on-surface-variant); margin-top: 2px; }

/* Progress ring */
.ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--surface-highest); stroke-width: 5; }
.ring .fill { fill: none; stroke-linecap: round; stroke-width: 5; transition: stroke-dashoffset 1s ease; }
.ring .fill.lime { stroke: var(--primary); filter: drop-shadow(0 0 3px rgba(210,240,0,.5)); }
.ring .fill.blue { stroke: var(--secondary); filter: drop-shadow(0 0 3px rgba(0,238,252,.5)); }
.ring .ring-ic { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 20px; }
.ring.blue .ring-ic { color: var(--secondary); }

/* XP bar */
.xp-bar { width: 100%; }
.xp-top { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; margin-bottom: 8px; }
.xp-top .lvl { color: var(--on-surface-variant); text-transform: uppercase; }
.xp-top .amt { color: var(--primary); }
.xp-track { height: 8px; background: var(--surface-highest); border-radius: var(--r-full); overflow: hidden; }
.xp-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  box-shadow: 0 0 10px rgba(210,240,0,.5);
  position: relative;
  transition: width 1s ease;
}
.xp-fill::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 14px; background: rgba(255,255,255,.4); filter: blur(3px); }

/* Card headers */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .03em; font-family: var(--font-display); }
.link { font-family: var(--font-mono); font-size: 11px; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; }

/* Daily plan list */
.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(32,31,31,.5);
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.plan-item img, .plan-card summary img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--surface); flex-shrink: 0; }
.plan-info { flex: 1; min-width: 0; }
.plan-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-meta { font-size: 11px; color: var(--on-surface-variant); margin-top: 2px; text-transform: capitalize; }
.plan-sets { font-family: var(--font-mono); font-size: 13px; color: var(--primary); white-space: nowrap; }

.done-banner {
  background: rgba(210,240,0,.1);
  border: 1px solid rgba(210,240,0,.35);
  color: var(--primary);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 12px;
}

/* Week row */
.week-row { display: flex; gap: 6px; }
.week-cell {
  flex: 1; text-align: center;
  background: var(--surface);
  border: 1px solid var(--ghost-soft);
  border-radius: 10px;
  padding: 8px 2px;
}
.week-cell.done { background: rgba(210,240,0,.1); border-color: rgba(210,240,0,.4); }
.week-day { font-family: var(--font-display); font-weight: 800; font-size: 14px; }
.week-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-highest); margin: 5px auto; }
.week-cell.done .week-dot { background: var(--primary); box-shadow: 0 0 8px rgba(210,240,0,.6); }
.week-cell small { font-size: 9px; color: var(--on-surface-variant); text-transform: capitalize; }

/* Two col */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .two-col { grid-template-columns: 1fr; } }

/* Feed */
.feed { display: flex; flex-direction: column; gap: 8px; }
.feed-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px;
  background: rgba(32,31,31,.5);
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-md);
  font-size: 12.5px;
}
.feed-item b { color: var(--on-surface); }
.feed-item small { color: var(--on-surface-variant); }
.feed-item > span { font-size: 16px; }

/* Badges */
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-mini {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-md);
  padding: 8px;
  font-size: 18px;
}
.badge-mini small { font-size: 9px; color: var(--on-surface-variant); max-width: 64px; text-align: center; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px,1fr)); gap: 8px; }
.badge-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--glass-bg);
  border: 1px solid var(--ghost);
  border-radius: var(--r-md);
  padding: 14px 8px;
  text-align: center;
}
.badge-card span { font-size: 24px; }
.badge-card b { font-size: 12px; color: var(--on-surface); }
.badge-card small { font-size: 10px; color: var(--on-surface-variant); }

/* Quick actions */
.quick-actions { display: flex; gap: 10px; }
.quick-actions .btn { flex: 1; }
.quick-grid { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.quick-act {
  flex-shrink: 0;
  width: 84px; height: 84px;
  background: var(--glass-bg);
  border: 1px solid var(--ghost);
  border-top-color: rgba(255,255,255,.22);
  border-left-color: rgba(255,255,255,.22);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--primary);
  font-size: 24px;
  cursor: pointer;
  transition: background .2s ease;
}
.quick-act small { font-size: 10px; color: var(--on-surface); text-align: center; line-height: 1.2; font-family: var(--font-body); }
.quick-act.blue { color: var(--secondary); }
.quick-act:hover { background: var(--surface-high); }

/* ---------- Workout ---------- */
.plan-card { border-radius: var(--r-md); overflow: hidden; }
.plan-card summary {
  list-style: none;
  display: flex; align-items: center; gap: 12px;
  background: rgba(32,31,31,.5);
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .2s ease;
}
.plan-card[open] summary { border-color: rgba(210,240,0,.4); background: rgba(210,240,0,.05); }
.plan-card summary::-webkit-details-marker { display: none; }
.plan-card summary::after { content: '⌄'; color: var(--on-surface-variant); font-size: 16px; }
.plan-card[open] summary::after { content: '⌃'; }
.plan-body { padding: 12px 4px 4px; display: flex; flex-direction: column; gap: 12px; }
.plan-body p { font-size: 13px; color: var(--on-surface-variant); }

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--ghost-soft);
}
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Library strip */
.lib-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.lib-chip {
  flex-shrink: 0;
  width: 92px;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--glass-bg);
  border: 1px solid var(--ghost);
  border-radius: var(--r-md);
  padding: 8px;
}
.lib-chip img { width: 100%; height: 52px; object-fit: cover; border-radius: 8px; background: var(--surface); }
.lib-chip span { font-size: 10.5px; color: var(--on-surface); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Library ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.filter-row.small { gap: 4px; }
.filter-chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--on-surface-variant);
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-full);
  padding: 5px 11px;
  transition: all .15s ease;
}
.filter-chip.on {
  color: var(--on-primary);
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(210,240,0,.3);
}
.filter-chip:hover { border-color: rgba(210,240,0,.4); }

.ex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ex-card {
  background: var(--glass-bg);
  border: 1px solid var(--ghost);
  border-top-color: rgba(255,255,255,.22);
  border-left-color: rgba(255,255,255,.22);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, border-color .2s ease;
}
.ex-card:active { transform: scale(.97); }
.ex-thumb { position: relative; aspect-ratio: 16/10; background: var(--surface); }
.ex-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ex-thumb.noimg { display: flex; align-items: center; justify-content: center; }
.ex-thumb.noimg::after { content: '🏋️'; font-size: 28px; }
.ex-thumb.noimg img { display: none; }
.ex-diff {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .05em; text-transform: uppercase;
  background: rgba(19,19,19,.85);
  border: 1px solid var(--ghost);
  color: var(--primary);
  padding: 3px 7px;
  border-radius: var(--r-full);
}
.ex-diff.intermediate { color: var(--secondary); }
.ex-diff.hard, .ex-diff.advanced { color: var(--tertiary); }
.ex-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.ex-name { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-meta { font-size: 10.5px; color: var(--on-surface-variant); text-transform: capitalize; }
.ex-set { font-family: var(--font-mono); font-size: 12px; color: var(--primary); }

/* ---------- Exercise detail ---------- */
.back-link { font-family: var(--font-mono); font-size: 12px; color: var(--on-surface-variant); display: inline-flex; align-items: center; gap: 6px; }
.back-link:hover { color: var(--primary); }
.ex-detail .ex-detail-head { display: flex; gap: 14px; margin-bottom: 14px; }
.ex-detail-head .ex-thumb.big { width: 110px; height: 110px; border-radius: var(--r-lg); overflow: hidden; flex-shrink: 0; }
.ex-detail-head .ex-thumb.big img { width: 100%; height: 100%; object-fit: cover; }
.ex-detail-head h1 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ex-presc { font-size: 13px; color: var(--on-surface-variant); }
.ex-presc b { color: var(--primary); font-family: var(--font-mono); }
.ex-detail h3 { font-size: 14px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .03em; margin: 14px 0 8px; }
.ex-detail p { font-size: 13px; color: var(--on-surface-variant); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { font-size: 12px; color: var(--on-surface-variant); display: flex; flex-direction: column; gap: 6px; }
input, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--ghost);
  color: var(--on-surface);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(210,240,0,.15);
}
input::placeholder { color: rgba(198,201,171,.4); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23c6c9ab' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
input[type="checkbox"] { width: auto; }

/* Switch row */
.switch-row { flex-direction: row; align-items: center; justify-content: space-between; }
.switch-row span { color: var(--on-surface); font-size: 13px; }
.switch-row input { transform: scale(1.3); accent-color: var(--primary); }

/* ---------- Diet ---------- */
.macro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.macro-card {
  background: var(--glass-bg);
  border: 1px solid var(--ghost);
  border-radius: var(--r-md);
  padding: 12px;
}
.macro-val { font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--primary); }
.macro-val small { font-size: 12px; color: var(--on-surface-variant); font-weight: 500; }
.macro-lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--on-surface-variant); margin-top: 3px; }
.bmi-banner {
  margin-top: 12px;
  font-size: 12px;
  color: var(--on-surface-variant);
  background: rgba(0,238,252,.07);
  border: 1px solid rgba(0,238,252,.2);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.bmi-banner b { color: var(--secondary); font-family: var(--font-mono); }

.food-results, #food-results { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.food-results h4, #food-results h4 { font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--on-surface-variant); margin: 4px 0 2px; }
.food-opt {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--ghost-soft);
  color: var(--on-surface);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.food-opt small { color: var(--on-surface-variant); font-family: var(--font-mono); }
.food-opt:hover { border-color: rgba(210,240,0,.4); }
.recipe-opt { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--ghost-soft); border-radius: var(--r-md); padding: 8px; }
.recipe-opt img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.recipe-opt small { color: var(--on-surface-variant); }
.recipe-opt a { color: var(--primary); text-decoration: none; }
.food-selected {
  background: rgba(210,240,0,.08);
  border: 1px dashed rgba(210,240,0,.4);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 13px;
  color: var(--primary);
}

.quick-foods { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--on-surface-variant); }
.chip-btn {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--on-surface-variant);
  background: var(--surface);
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-full);
  padding: 6px 12px;
  cursor: pointer;
  transition: all .15s ease;
}
.chip-btn:hover { border-color: rgba(210,240,0,.4); }
.chip-btn.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); box-shadow: 0 0 10px rgba(210,240,0,.3); }

.meal-head { font-size: 12px; font-weight: 700; color: var(--secondary); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 8px; }
.meal-table { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.meal-day {
  display: flex; justify-content: space-between; gap: 10px;
  background: rgba(32,31,31,.5);
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 12px;
}
.meal-day b { color: var(--primary); font-family: var(--font-mono); text-transform: uppercase; font-size: 11px; flex-shrink: 0; }
.meal-day div { color: var(--on-surface-variant); text-align: right; }
.ai-box {
  background: rgba(0,238,252,.06);
  border: 1px solid rgba(0,238,252,.2);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 12.5px;
  color: var(--on-surface-variant);
  white-space: pre-wrap;
  margin-bottom: 12px;
}

/* ---------- Assistant chat ---------- */
.chat-card {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 176px);
  background: var(--glass-bg);
  border: 1px solid var(--ghost);
  border-top-color: rgba(255,255,255,.22);
  border-left-color: rgba(255,255,255,.22);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ghost-soft);
}
.chat-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.chat-head b { font-family: var(--font-display); font-size: 14px; color: var(--on-surface); }
.chat-head .muted { font-size: 11px; }
.chat-head .btn { margin-left: auto; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-ai { justify-content: flex-start; }
.bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user .bubble {
  background: var(--primary);
  color: var(--on-primary);
  border-bottom-right-radius: 4px;
}
.msg-ai .bubble {
  background: var(--surface);
  border: 1px solid var(--ghost-soft);
  border-bottom-left-radius: 4px;
  color: var(--on-surface);
}
.chat-input {
  display: flex; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--ghost-soft);
  background: rgba(14,14,14,.6);
}
.chat-input input { flex: 1; }
.chat-input .btn { width: 50px; padding: 0; border-radius: var(--r-md); flex-shrink: 0; }
.suggest-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chat-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.chat-actions .btn { margin-left: 0; }
.chat-actions .btn.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.bubble-voice {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; margin-left: 8px; vertical-align: middle;
  background: transparent; border: 1px solid var(--ghost-soft); border-radius: 50%;
  color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.bubble-voice:hover { color: var(--primary); border-color: var(--primary); }
.bubble-voice .material-symbols-outlined { font-size: 14px; }
.chat-input .mic-btn { width: 44px; padding: 0; border-radius: var(--r-md); flex-shrink: 0; }
.listening { animation: pulse 1s ease-in-out infinite; border-color: var(--secondary) !important; color: var(--secondary) !important; box-shadow: 0 0 14px rgba(0,238,252,.45); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
#voice-status { min-height: 0; padding: 4px 16px 10px; font-size: 11px; color: var(--secondary); text-align: center; }

/* ---------- Auth ---------- */
.auth-card {
  margin: auto;
  width: 100%;
  max-width: 380px;
  background: var(--glass-bg);
  border: 1px solid var(--ghost);
  border-top-color: rgba(255,255,255,.22);
  border-left-color: rgba(255,255,255,.22);
  border-radius: var(--r-xl);
  padding: 28px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.auth-logo {
  width: 64px; height: 64px;
  margin: 0 auto;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  box-shadow: 0 0 30px rgba(210,240,0,.3);
}
.auth-card h1 { font-size: 22px; font-weight: 800; text-align: center; }
.auth-card .muted { text-align: center; font-size: 13px; }
.demo-box {
  background: rgba(210,240,0,.06);
  border: 1px dashed rgba(210,240,0,.35);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 12.5px;
  color: var(--on-surface-variant);
}
.demo-box code { color: var(--primary); font-family: var(--font-mono); font-size: 11px; }
.auth-alt { text-align: center; font-size: 13px; color: var(--on-surface-variant); }
.auth-alt a { color: var(--primary); font-weight: 600; }

/* ---------- Onboarding ---------- */
.onboarding-wrap { width: 100%; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.onboarding-wrap > h1 { font-size: 22px; font-weight: 800; text-align: center; }
.onboarding-wrap > .muted { text-align: center; font-size: 13px; }
.progress-bar { height: 6px; background: var(--surface-highest); border-radius: var(--r-full); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--secondary), var(--primary)); box-shadow: 0 0 10px rgba(210,240,0,.5); transition: width .4s ease; border-radius: var(--r-full); }
.onboard-step h2 { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.onboard-step { display: flex; flex-direction: column; gap: 14px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { display: flex; }
.choice input { display: none; }
.choice span {
  flex: 1;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-md);
  padding: 16px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
  cursor: pointer;
  transition: all .15s ease;
}
.choice input:checked + span {
  background: rgba(210,240,0,.08);
  border-color: rgba(210,240,0,.7);
  color: var(--primary);
  box-shadow: 0 0 12px rgba(210,240,0,.2);
}
.onboard-nav { display: flex; gap: 10px; margin-top: 8px; }
.onboard-nav .btn { flex: 1; }
@media (max-width: 360px) { .choice-grid { grid-template-columns: 1fr; } }

/* ---------- Landing ---------- */
.landing-page .content { padding-top: 96px; gap: 0; }
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; padding-top: 8px; }
.hero-badge {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--primary);
  background: rgba(210,240,0,.08);
  border: 1px solid rgba(210,240,0,.3);
  padding: 6px 14px;
  border-radius: var(--r-full);
}
.hero-title { font-size: 34px; font-weight: 900; line-height: 1.15; letter-spacing: -0.02em; }
.hero-title .grad { color: var(--primary); }
.hero-sub { font-size: 14.5px; color: var(--on-surface-variant); max-width: 360px; line-height: 1.6; }
.hero-actions { display: flex; gap: 10px; width: 100%; max-width: 360px; }
.hero-actions .btn { flex: 1; }
.hero-login-demo { font-size: 12px; color: var(--on-surface-variant); }
.hero-login-demo code { font-family: var(--font-mono); font-size: 11px; color: var(--primary); }

.landing-logo {
  width: 88px; height: 88px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 900; font-size: 42px; color: var(--bg);
  box-shadow: 0 0 40px rgba(210,240,0,.25);
}

/* feature cards */
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 400px; }
.feature-card {
  background: var(--glass-bg);
  border: 1px solid var(--ghost);
  border-top-color: rgba(255,255,255,.22);
  border-left-color: rgba(255,255,255,.22);
  border-radius: var(--r-lg);
  padding: 16px;
  text-align: left;
}
.feature-card .fic {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--ghost-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  color: var(--primary);
  margin-bottom: 10px;
}
.feature-card.blue .fic { color: var(--secondary); }
.feature-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.feature-card p { font-size: 11.5px; color: var(--on-surface-variant); line-height: 1.5; }

/* preview bento */
.preview-grid { display: grid; gap: 10px; width: 100%; max-width: 400px; margin: 20px 0 4px; }
.preview-card { position: relative; overflow: hidden; }
.preview-card .deco { position: absolute; border-radius: 50%; filter: blur(60px); pointer-events: none; }
.preview-card .deco-lime { width: 120px; height: 120px; background: rgba(210,240,0,.12); top: -30px; right: -30px; }
.preview-card .deco-blue { width: 140px; height: 140px; background: rgba(0,238,252,.1); bottom: -40px; left: -40px; }
.preview-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--on-surface-variant); margin-bottom: 6px; }
.preview-title { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.preview-row { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--ghost-soft); padding-top: 12px; margin-top: 12px; }
.preview-badges { display: flex; gap: 6px; }

/* footer */
.landing-footer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(198,201,171,.5);
  padding: 24px 0 12px;
}

/* ---------- Charts ---------- */
canvas { max-width: 100%; }

/* ---------- Material icons fallback ---------- */
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* ---------- Notifications ---------- */
.bell {
  position: relative;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--on-surface-variant);
  border: 1px solid var(--ghost);
  border-radius: 50%;
  background: var(--surface-highest);
}
.bell .material-symbols-outlined { font-size: 19px; }
.bell:active { transform: scale(.92); }
.bell-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  align-items: center; justify-content: center;
  box-shadow: 0 0 10px rgba(210,240,0,.6);
}
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--ghost-soft);
  border-radius: var(--r-md);
  background: rgba(255,255,255,.02);
  position: relative;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.notif-item:active { background: rgba(210,240,0,.05); }
.notif-item.unread { border-color: rgba(210,240,0,.35); background: rgba(210,240,0,.05); }
.notif-ic {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-highest);
  border: 1px solid var(--ghost-soft);
}
.notif-ic .material-symbols-outlined { font-size: 20px; color: var(--primary); }
.notif-body { flex: 1; min-width: 0; }
.notif-body b { font-family: var(--font-display); font-size: 13px; color: var(--on-surface); }
.notif-body p { font-size: 12px; color: var(--on-surface-variant); margin: 2px 0 4px; }
.notif-dot {
  position: absolute; top: 14px; right: 12px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--secondary);
  box-shadow: 0 0 8px rgba(0,238,252,.8);
}

/* ============================================================
   RESPONSIVE & DEVICE-FIT OVERRIDES
   Safe-areas (notch/home-bar), small phones, tablets, landscape
   ============================================================ */

/* dvh fallback for older iOS/WebViews */
body, .app-shell { min-height: 100vh; min-height: 100dvh; }

/* topbar safe-area (notch) */
.topbar {
  padding-top: env(safe-area-inset-top);
  height: calc(64px + env(safe-area-inset-top));
}
.flashes { top: calc(74px + env(safe-area-inset-top)); }
.content { padding-top: calc(80px + env(safe-area-inset-top)); }

/* chat card should respect safe areas too */
.chat-card { height: calc(100dvh - 176px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }

/* ---------- Small phones (<=360px) ---------- */
@media (max-width: 360px) {
  .content { padding: calc(70px + env(safe-area-inset-top)) 14px calc(84px + env(safe-area-inset-bottom)); }
  .topbar-inner { padding: 0 14px; }
  .brand .logo { width: 32px; height: 32px; font-size: 16px; }
  .brandname { font-size: 17px; }
  .xp-chip { font-size: 10px; padding: 3px 8px; }
  .bottomnav-inner { height: 68px; }
  .nav-item .nav-ic { font-size: 21px; }
  .nav-item { font-size: 8.5px; }
  .dash-hello h1 { font-size: 20px; }
  .stat-card, .card { padding: 14px; }
  .row-2, .macro-grid, .two-col { gap: 8px; }
  .ex-grid { gap: 10px; }
  .chat-head { padding: 12px; }
  .chat-log { padding: 12px; }
  .bubble { max-width: 88%; }
  .preview-title { font-size: 16px; }
}

/* ---------- Short / landscape screens ---------- */
@media (max-height: 620px) and (orientation: landscape) {
  .content { padding: calc(64px + env(safe-area-inset-top)) 16px calc(72px + env(safe-area-inset-bottom)); }
  .topbar { height: calc(56px + env(safe-area-inset-top)); }
  .bottomnav-inner { height: 62px; }
  .chat-card { height: calc(100dvh - 130px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Tablets & desktop (>=600px): keep app feel, center the shell ---------- */
@media (min-width: 600px) {
  body {
    background:
      radial-gradient(900px 500px at 20% 0%, rgba(210,240,0,.04), transparent 60%),
      radial-gradient(900px 600px at 85% 100%, rgba(0,238,252,.05), transparent 60%),
      var(--bg);
  }
  .app-shell { box-shadow: 0 0 60px rgba(0,0,0,.55); }
  .chat-card { height: calc(100dvh - 176px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}

/* ---------- Large phones (>=480px) already have shell borders ---------- */

/* reduce oversized blobs on tiny screens */
@media (max-width: 380px) {
  .ambient-bg .blob-lime { width: 260px; height: 260px; }
  .ambient-bg .blob-blue { width: 280px; height: 280px; }
}