/* FORGE AI. One deliberate dark look: charcoal surfaces, white text, one orange accent.
   Layout: bottom tab bar on phones, fixed sidebar on desktop; content in a single readable column. */
:root {
  --bg: #0d0e10;
  --surface: #15171a;
  --raised: #1e2125;
  --line: #2b2f35;
  --fg: #f4f5f7;
  --muted: #a3aab4;
  --accent: #ff5b1f;
  --accent-ink: #1a0a03;
  --accent-soft: rgb(255 91 31 / 0.15);
  --accent-rgb: 255 91 31;
  --good: #4cd68f;
  --warn: #f5b942;
  --bad: #ff7070;
  --bar: #4b525c;
  --font-display: 'Barlow Condensed', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 0;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.01em; line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: 2.2rem; text-transform: uppercase; }
h2 { font-size: 1.55rem; text-transform: uppercase; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; }
ul, ol { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.eyebrow { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.9rem; color: var(--accent); font-weight: 600; }
.ic { display: inline-flex; flex: none; }

/* ---------- shell ---------- */
#app { max-width: 1100px; margin: 0 auto; display: block; min-width: 0; }
#view { max-width: 720px; margin: 0 auto; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 32px); min-width: 0; }
body.focus #view { padding-bottom: 32px; }

#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  background: rgba(21, 23, 26, 0.96); border-top: 1px solid var(--line);
  padding: 4px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
  backdrop-filter: blur(10px);
}
#nav .brand { display: none; }
body.focus #nav { display: none; }
.nav-item {
  flex: 1; min-width: 0; min-height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 12px; font-size: 0.72rem; font-weight: 500;
}
.nav-item.on { color: var(--accent); }
.nav-item span:last-child { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; }
.word { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; letter-spacing: 0.08em; white-space: nowrap; }
.word b { color: var(--accent); font-weight: 700; }
.brand.big .mark { width: 46px; height: 46px; font-size: 2rem; border-radius: 12px; }
.brand.big .word { font-size: 2rem; }

@media (min-width: 900px) {
  body { padding-block: 24px 0; }
  #app { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 40px; align-items: start; }
  body.focus #app { display: block; }
  #nav {
    position: sticky; top: 24px; left: auto; right: auto; bottom: auto;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 12px; backdrop-filter: none;
  }
  #nav .brand { display: flex; padding: 4px 8px 16px; }
  #nav .word { font-size: 1.3rem; letter-spacing: 0.05em; }
  .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 12px; font-size: 1rem; }
  .nav-item.on { background: var(--accent-soft); }
  #view { max-width: 760px; margin: 0; padding-bottom: 64px; }
  body.focus #view { margin: 0 auto; }
}

/* ---------- layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stack.lg { gap: 20px; }
.stack.tight { gap: 4px; }
.row { display: flex; align-items: center; gap: 0; min-width: 0; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.center { align-items: center; }
.row.start { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.w60 { width: 60px; flex: none; }
.pad-top { padding-top: 14px; }
.live { min-width: 0; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; color: inherit; text-align: left; }
.card.empty { align-items: flex-start; }
button.card { width: 100%; cursor: pointer; font: inherit; }
.hero { display: flex; flex-direction: column; gap: 8px; padding: 6px 0 2px; }
.hero h1 { font-size: 2.8rem; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.page-head h1 { font-size: 2rem; }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 14px; }
.banner.warn { background: rgba(245, 185, 66, 0.12); border-color: var(--warn); }
.error { background: rgba(255, 112, 112, 0.12); border: 1px solid var(--bad); color: var(--fg); border-radius: var(--radius-sm); padding: 12px 14px; }
.hint, .hintline { font-size: 0.875rem; color: var(--muted); }
.hintline { color: var(--fg); background: var(--accent-soft); padding: 8px 10px; border-radius: 8px; }

.pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill.accent { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }
.pill.good { background: rgba(76, 214, 143, 0.14); border-color: var(--good); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 6px; background: var(--raised); color: var(--muted); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; width: fit-content; }
.badge { padding: 6px 12px; border-radius: 999px; border: 1px dashed var(--line); color: var(--muted); font-size: 0.9rem; }
.badge.on { border: 1px solid var(--good); color: var(--fg); background: rgba(76, 214, 143, 0.12); }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; flex: none; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.tile { background: var(--raised); border-radius: var(--radius-sm); padding: 12px 14px; min-width: 0; }
.tile .big { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .small { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv strong { text-align: right; font-weight: 600; }
.kv.col { flex-direction: column; gap: 2px; text-align: left; }
.kv.col strong, .kv.col .link-btn { text-align: left; }

.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li.struck .grow, .li.struck > span:not(.tag) { text-decoration: line-through; color: var(--muted); }
.li.check { cursor: pointer; min-height: 44px; }
.li.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

.bullets, .steps-list { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.bullets.good li::marker { color: var(--good); }
.steps-list li::marker { color: var(--accent); font-weight: 700; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--raised); color: var(--fg); font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { border-color: #444a52; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #2a0707; }
.btn.danger.ghost { background: transparent; color: var(--bad); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.92rem; border-radius: 10px; }
.btn.big { min-height: 54px; font-size: 1.1rem; width: 100%; }
.btn.on { border-color: var(--accent); background: var(--accent-soft); }
.btn:disabled, button:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; background: transparent; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--muted); }
.icon-btn.on { color: var(--accent); border-color: var(--accent); }
.link-btn { background: none; border: 0; padding: 0; text-align: left; color: var(--fg); font-weight: 600; font-size: 1.05rem; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.link-btn:hover { text-decoration-color: var(--accent); }

.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); color: var(--fg); cursor: pointer; font-size: 0.95rem; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); }
.chip.locked { cursor: default; }
.choice { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); cursor: pointer; }
.choice span { color: var(--muted); font-size: 0.85rem; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-weight: 600; font-size: 0.95rem; }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 10px; color: var(--fg);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #6f7782; }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 32px; }
input[type="checkbox"] { accent-color: var(--accent); }
.scrollbox { max-height: 220px; overflow-y: auto; padding: 4px 0; }

.fold { padding: 0; }
.fold > summary { padding: 16px 18px; cursor: pointer; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 52px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: '+'; color: var(--accent); font-size: 1.5rem; line-height: 1; }
.fold[open] > summary::after { content: '–'; }
.fold > :not(summary) { margin-left: 18px; margin-right: 18px; }
.fold > :last-child { margin-bottom: 18px; }
.fold.inline { background: var(--raised); border-radius: var(--radius-sm); border: 0; }
.fold.inline > summary { font-family: var(--font-body); font-size: 0.95rem; font-weight: 600; min-height: 44px; padding: 10px 14px; }
.fold.inline > :not(summary) { margin-left: 14px; margin-right: 14px; }
.fold.inline > :last-child { margin-bottom: 14px; }
.fold.inline > * + * { margin-top: 8px; }
details.field.fold { background: var(--raised); border-radius: var(--radius-sm); }
details.field.fold > summary { font-family: var(--font-body); font-size: 1rem; font-weight: 600; }
details.field.fold > * + * { margin-top: 10px; }
details.section > * + * { margin-top: 0; }

.tabs { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.tab { flex: 1; min-height: 42px; border: 0; background: none; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab.on { background: var(--raised); color: var(--fg); }

.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); z-index: 5; padding: 12px 0 4px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
body.focus .sticky-actions { bottom: 8px; }
@media (min-width: 900px) { .sticky-actions { bottom: 8px; } }

/* ---------- sheets and toast ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.sheet { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; max-height: 88%; overflow-y: auto; }
.sheet.tall { min-height: 40%; }
@media (min-width: 700px) { .sheet-back { align-items: center; } .sheet { border-radius: 20px; padding-bottom: 20px; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60; background: var(--fg); color: #111; padding: 12px 16px; border-radius: 12px; max-width: min(92vw, 460px); font-weight: 600; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #2a0707; }
body.focus .toast { bottom: 24px; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ---------- onboarding ---------- */
.onboard { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding-bottom: 24px; }
.steps { display: flex; gap: 6px; }
.seg { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.seg.done { background: var(--accent); opacity: 0.6; }
.seg.cur { background: var(--accent); }
.ob-head { display: flex; flex-direction: column; gap: 8px; }
.tagline { color: var(--muted); font-size: 1.05rem; margin-bottom: 8px; }
.ob-actions { padding-top: 4px; }

/* ---------- home ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0; border-radius: 10px; }
.day .dn { font-size: 0.75rem; color: var(--muted); }
.day .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.day.planned .dot { border-color: var(--muted); }
.day.done .dot { background: var(--good); border-color: var(--good); color: #06220f; }
.day.today { background: var(--raised); }
.day.today .dn { color: var(--fg); font-weight: 700; }
.ring { width: 84px; height: 84px; flex: none; }
.ring-bg { stroke: var(--line); stroke-width: 8; }
.ring-fg { stroke: var(--accent); stroke-width: 8; stroke-linecap: round; }
.ring-text { fill: var(--fg); font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.qa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.qa { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; text-align: left; font-weight: 600; }
.qa .ic { color: var(--accent); }
.qa:hover { border-color: var(--accent); }

/* ---------- workouts ---------- */
.workout-card { display: flex; align-items: center; gap: 14px; }
.workout-card.today { border-color: var(--accent); }
.wc-day { width: 52px; flex: none; text-align: center; font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; text-transform: uppercase; display: flex; flex-direction: column; }
.wc-day b { font-size: 0.7rem; color: var(--accent); letter-spacing: 0.08em; }
.wc-name { font-family: var(--font-display); font-size: 1.35rem; text-transform: uppercase; }
.ex-row .num { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--raised); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.lib-row { display: flex; align-items: center; gap: 12px; }
.lib-row .ic { color: var(--muted); }
.meal.eaten { border-color: var(--good); }
.meal .mname { font-size: 1.1rem; }
.daypick { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
.daypick .chip { flex: none; }

/* ---------- workout mode ---------- */
.session { display: flex; flex-direction: column; gap: 16px; max-width: 620px; margin: 0 auto; }
.session-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); padding: 4px 0 10px; display: flex; flex-direction: column; gap: 10px; }
.sname { font-family: var(--font-display); font-size: 1.4rem; text-transform: uppercase; }
.elapsed { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: 8px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }
.ex-nav { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; }
.exn { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 700; cursor: pointer; display: grid; place-items: center; }
.exn.part { border-color: var(--warn); }
.exn.done { border-color: var(--good); color: var(--good); }
.exn.cur { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sets { display: flex; flex-direction: column; gap: 8px; }
.srow { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) 54px; gap: 8px; align-items: center; }
.srow.head { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.srow.head span:last-child { text-align: center; }
.srow input { text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 52px; }
.srow .sn { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--muted); text-align: center; }
.srow.done input { border-color: var(--good); }
.setdone { width: 54px; height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); color: var(--muted); display: grid; place-items: center; cursor: pointer; flex: none; }
.setdone.on { background: var(--good); border-color: var(--good); color: #06220f; }
.rest { position: sticky; bottom: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }
.rest.running { border-color: var(--accent); }
.rest.over { border-color: var(--good); }
.rest-time { font-family: var(--font-display); font-size: 2.8rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 18px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.chart .line { stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); }
.chart .dot.last { stroke: var(--bg); stroke-width: 2; }
.chart .bar { fill: var(--bar); }
.chart .bar.hi { fill: var(--accent); }
.chart .target { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- save status ---------- */
.sync { position: fixed; z-index: 70; top: calc(env(safe-area-inset-top, 0px) + 8px); right: max(12px, env(safe-area-inset-right, 0px)); display: flex; align-items: center; gap: 10px; max-width: min(92vw, 420px); padding: 7px 12px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }
.sync.ok { color: var(--fg); border-color: var(--good); }
.sync.err { background: rgba(255, 112, 112, 0.16); border-color: var(--bad); color: var(--fg); border-radius: 14px; }

/* ---------- generating ---------- */
.gen-row { align-items: flex-start; }
.gen-row .spin { width: 22px; height: 22px; margin-top: 2px; flex: none; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.gen-row.good .spin { animation: none; border-color: var(--good); background: var(--good); }
.gen-row.warn .spin { animation: none; border-color: var(--warn); background: var(--warn); }
.gen-row.bad .spin { animation: none; border-color: var(--bad); background: var(--bad); }
.gen-row.stopped .spin { animation: none; border-color: var(--muted); }
.gen-row:not(.working):not(.good):not(.warn):not(.bad):not(.stopped) .spin { animation: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .gen-row .spin { animation: none !important; } }

/* ---------- coach ---------- */
.coach { display: flex; flex-direction: column; gap: 16px; }
.msgs { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.msg { max-width: 92%; padding: 12px 14px; border-radius: 16px; min-width: 0; }
.msg .who { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.msg .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent-soft); border: 1px solid var(--accent); }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.composer { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); z-index: 5; }
@media (min-width: 900px) { .composer { bottom: 8px; } }

/* six tabs on a phone */
.nav-item { font-size: 0.68rem; }
@media (min-width: 900px) { .nav-item { font-size: 1rem; } }
.session .btn { scroll-margin-bottom: 150px; }

/* ================= motion and polish ================= */
:root { --ease: cubic-bezier(0.22, 0.8, 0.24, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.8); } 55% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes drift { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(30px, -24px) scale(1.12); } }
@keyframes pulseMark { 0%, 100% { box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / 0.5); } 50% { box-shadow: 0 0 0 14px rgb(var(--accent-rgb) / 0); } }
@keyframes ringGrow { from { stroke-dasharray: 0 400; } }
@keyframes shimmer { to { background-position: 200% 0; } }
@keyframes spinIn { to { transform: rotate(360deg); } }

#view > * { animation: viewIn 0.42s var(--ease) both; }
#view > .stack > *, #view > .onboard > * { animation: riseIn 0.5s var(--ease) both; }
#view > .stack > *:nth-child(1), #view > .onboard > *:nth-child(1) { animation-delay: 0.02s; }
#view > .stack > *:nth-child(2), #view > .onboard > *:nth-child(2) { animation-delay: 0.07s; }
#view > .stack > *:nth-child(3), #view > .onboard > *:nth-child(3) { animation-delay: 0.12s; }
#view > .stack > *:nth-child(4), #view > .onboard > *:nth-child(4) { animation-delay: 0.17s; }
#view > .stack > *:nth-child(5), #view > .onboard > *:nth-child(5) { animation-delay: 0.22s; }
#view > .stack > *:nth-child(6) { animation-delay: 0.27s; }
#view > .stack > *:nth-child(n+7) { animation-delay: 0.32s; }

.card { background: linear-gradient(180deg, #181b1f, var(--surface)); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.8); transition: border-color 0.2s, transform 0.25s var(--ease), box-shadow 0.25s; }
@media (hover: hover) { .card:hover { border-color: #3a3f47; } .ex-row:hover, .li:hover { transform: translateY(-1px); } }
.btn { transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, filter 0.2s, box-shadow 0.25s; }
.btn:active, .qa:active, .icon-btn:active, .setdone:active, .nav-item:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 78%, white), var(--accent) 55%, color-mix(in srgb, var(--accent) 90%, black)); box-shadow: 0 8px 24px -10px rgb(var(--accent-rgb) / 0.75); }
@media (hover: hover) { .btn.primary:hover { box-shadow: 0 10px 30px -8px rgb(var(--accent-rgb) / 0.9); transform: translateY(-1px); } .qa:hover { transform: translateY(-2px); border-color: var(--accent); } }
.qa { transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s; }
.nav-item { transition: color 0.2s, transform 0.15s var(--ease); }
.nav-item.on .ic { animation: pop 0.4s var(--ease); }
.nav-item.on { text-shadow: 0 0 18px rgb(var(--accent-rgb) / 0.5); }
.setdone { transition: background 0.2s, border-color 0.2s, transform 0.15s; }
.setdone.on { animation: pop 0.38s var(--ease); box-shadow: 0 0 18px rgba(76, 214, 143, 0.45); }
.ring-fg { animation: ringGrow 1.1s var(--ease) 0.15s both; stroke-linecap: round; }
.sheet-back { animation: fadeIn 0.2s ease both; }
.sheet { animation: sheetUp 0.32s var(--ease) both; }
.hero h1 { background: linear-gradient(90deg, #fff, color-mix(in srgb, var(--accent) 25%, white)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pill.accent { box-shadow: 0 0 18px -6px var(--accent); }
.cue { color: var(--fg); font-size: 0.92rem; border-left: 2px solid var(--accent); padding-left: 10px; margin-top: 2px; }
.fg { color: var(--fg); }
.notice { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.92rem; }
.notice[hidden] { display: none; }
.steps .seg { transition: background 0.4s var(--ease), transform 0.4s var(--ease); }
.steps .seg.cur { transform: scaleY(1.5); }
.gen-row.working { background-image: linear-gradient(90deg, transparent, rgb(var(--accent-rgb) / 0.1), transparent); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }

/* welcome */
.welcome { position: relative; min-height: calc(100vh - 32px); display: flex; justify-content: center; overflow: hidden; border-radius: 0; }
.welcome .glow { position: absolute; width: 320px; height: 320px; border-radius: 50%; filter: blur(70px); opacity: 0.5; z-index: 0; animation: drift 11s ease-in-out infinite; }
.welcome .g1 { background: rgb(var(--accent-rgb) / 0.55); top: -80px; left: -90px; }
.welcome .g2 { background: rgba(255, 150, 80, 0.3); bottom: 40px; right: -110px; animation-delay: -5s; }
.w-inner { position: relative; z-index: 1; width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 18px; padding: 24px 0 32px; align-items: stretch; }
.w-inner > * { animation: riseIn 0.6s var(--ease) both; }
.w-inner > :nth-child(2) { animation-delay: 0.08s; } .w-inner > :nth-child(3) { animation-delay: 0.16s; } .w-inner > :nth-child(5) { animation-delay: 0.45s; } .w-inner > :nth-child(6) { animation-delay: 0.55s; }
.w-title { font-size: clamp(2.6rem, 11vw, 3.8rem); line-height: 0.98; }
.accent-text { color: var(--accent); text-shadow: 0 0 30px rgb(var(--accent-rgb) / 0.45); }
.w-sub { font-size: 1.05rem; max-width: 36ch; }
.w-feats { display: flex; flex-direction: column; gap: 10px; }
.w-feat { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(21, 23, 26, 0.7); backdrop-filter: blur(6px); animation: riseIn 0.6s var(--ease) both; }
.w-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.w-card { background: rgba(21, 23, 26, 0.85); backdrop-filter: blur(8px); }
.brand.pulse .mark { animation: pulseMark 2.4s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: 0.001ms !important; }
}

/* auth forms */
.lbl { font-size: 0.85rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.w-card input[type=text], .w-card input[type=email], .w-card input[type=password], .sheet input[type=password] { width: 100%; min-height: 48px; padding: 0 14px; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; transition: border-color 0.2s, box-shadow 0.2s; }
.w-card input:focus, .sheet input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pw { position: relative; display: block; }
.pw input { padding-right: 64px !important; }
.eye { position: absolute; right: 6px; top: 6px; bottom: 6px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; border-radius: 8px; }
.eye:hover { color: var(--fg); }
label.check { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 40px; }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.sync[hidden], [hidden] { display: none !important; }

/* smoother auth + extra motion */
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fieldIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes cardFloat { from { opacity: 0; transform: translateY(26px) scale(0.97); } to { opacity: 1; transform: none; } }
.shake { animation: shake 0.45s var(--ease); }
.spinner { display: inline-block; width: 16px; height: 16px; margin-right: 10px; border-radius: 50%; border: 2px solid rgba(26, 10, 3, 0.35); border-top-color: var(--accent-ink); animation: spin 0.7s linear infinite; vertical-align: -3px; }
.btn.loading { pointer-events: none; opacity: 0.85; }
.error:not([hidden]) { animation: fieldIn 0.3s var(--ease) both; }
.w-card { animation: cardFloat 0.65s var(--ease) 0.1s both; }
.w-card > .field, .w-card > .meter, .w-card > .check, .w-card > h2, .w-card > .btn { animation: fieldIn 0.5s var(--ease) both; }
.w-card > :nth-child(2) { animation-delay: 0.18s; } .w-card > :nth-child(3) { animation-delay: 0.24s; } .w-card > :nth-child(4) { animation-delay: 0.3s; }
.w-card > :nth-child(5) { animation-delay: 0.36s; } .w-card > :nth-child(6) { animation-delay: 0.42s; } .w-card > :nth-child(7) { animation-delay: 0.48s; } .w-card > :nth-child(8) { animation-delay: 0.54s; }
.field .lbl { transition: color 0.2s; }
.field:focus-within .lbl { color: var(--accent); }
.meter { display: flex; flex-direction: column; gap: 6px; margin-top: -4px; }
.bar-track { display: block; height: 5px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--bad); transition: width 0.4s var(--ease), background 0.3s; }
.bar-fill.s2 { background: var(--warn); } .bar-fill.s3 { background: #b4d86a; } .bar-fill.s4 { background: var(--good); }
.auth-links { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; animation: fieldIn 0.5s var(--ease) 0.6s both; }
.auth-links .btn { gap: 6px; }
.tile .big { font-variant-numeric: tabular-nums; }
/* top nav pill that glides in under the active tab */
.nav-item { position: relative; }
.nav-item::before { content: ''; position: absolute; left: 22%; right: 22%; top: 0; height: 3px; border-radius: 0 0 4px 4px; background: var(--accent); transform: scaleX(0); transition: transform 0.35s var(--ease); box-shadow: 0 0 12px var(--accent); }
.nav-item.on::before { transform: scaleX(1); }
@media (min-width: 900px) { .nav-item::before { left: 0; right: auto; top: 20%; bottom: 20%; width: 3px; height: auto; transform: scaleY(0); } .nav-item.on::before { transform: scaleY(1); } }
.li, .ex-row, .qa { transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s; }
.card.stack > * { animation: fieldIn 0.45s var(--ease) both; }
.card.stack > :nth-child(2) { animation-delay: 0.05s; } .card.stack > :nth-child(3) { animation-delay: 0.1s; } .card.stack > :nth-child(4) { animation-delay: 0.15s; }

/* smoother, livelier motion */
@keyframes vtOut { to { opacity: 0; transform: translateY(-6px) scale(0.995); } }
@keyframes vtIn { from { opacity: 0; transform: translateY(10px); } }
::view-transition-old(root) { animation: vtOut 0.16s ease both; }
::view-transition-new(root) { animation: vtIn 0.3s var(--ease) both; }
.rv { opacity: 0; transform: translateY(22px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); animation: none !important; }
.rv.in { opacity: 1; transform: none; }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 14px 4px 5px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); cursor: pointer; font-weight: 600; transition: transform 0.15s var(--ease), border-color 0.2s, background 0.2s; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.chip:active { transform: scale(0.96); }
.chip .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-family: var(--font-display); font-size: 1rem; }
.btn::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), rgba(255, 255, 255, 0.28), transparent 55%); opacity: 0; transition: opacity 0.5s; pointer-events: none; }
.btn { position: relative; overflow: hidden; }
.btn:active::after { opacity: 1; transition: none; }
.avatar { transition: transform 0.3s var(--ease); } .avatar:hover { transform: rotate(-6deg) scale(1.06); }
.tag, .pill { transition: transform 0.2s var(--ease), background 0.2s; }
.list > .li { animation: fieldIn 0.4s var(--ease) both; }
.list > .li:nth-child(2) { animation-delay: 0.05s; } .list > .li:nth-child(3) { animation-delay: 0.1s; } .list > .li:nth-child(4) { animation-delay: 0.15s; } .list > .li:nth-child(n+5) { animation-delay: 0.2s; }
.ex-row { animation: riseIn 0.5s var(--ease) both; }
.ex-row:nth-child(2) { animation-delay: 0.06s; } .ex-row:nth-child(3) { animation-delay: 0.12s; } .ex-row:nth-child(4) { animation-delay: 0.18s; } .ex-row:nth-child(n+5) { animation-delay: 0.24s; }
.line-path, .chart path.line { stroke-dasharray: 1200; stroke-dashoffset: 1200; animation: draw 1.4s var(--ease) 0.2s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ripple, confetti, smoother scrolling and list motion */
html { scroll-behavior: smooth; }
.btn, .qa, .chip { position: relative; overflow: hidden; }
.ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.28); transform: scale(0); animation: rippleOut 0.6s var(--ease) forwards; pointer-events: none; }
@keyframes rippleOut { to { transform: scale(1); opacity: 0; } }
.confetti { position: fixed; left: 50%; top: 32%; width: 0; height: 0; z-index: 80; pointer-events: none; }
.confetti i { position: absolute; width: 8px; height: 12px; border-radius: 2px; opacity: 0; animation: burst 1.5s cubic-bezier(0.1, 0.7, 0.3, 1) forwards; }
@keyframes burst { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 160px)) rotate(var(--r)); } }
.list > .li { animation: fieldIn 0.4s var(--ease) both; }
.list > .li:nth-child(2) { animation-delay: 0.05s; } .list > .li:nth-child(3) { animation-delay: 0.1s; } .list > .li:nth-child(4) { animation-delay: 0.15s; } .list > .li:nth-child(n+5) { animation-delay: 0.2s; }
.ex-row { animation: fieldIn 0.45s var(--ease) both; }
.ex-row:nth-child(2) { animation-delay: 0.06s; } .ex-row:nth-child(3) { animation-delay: 0.12s; } .ex-row:nth-child(4) { animation-delay: 0.18s; } .ex-row:nth-child(n+5) { animation-delay: 0.24s; }
.acct-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* splash + onboarding slide */
.splash { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.loadbar { width: 160px; height: 4px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.loadbar span { display: block; height: 100%; width: 40%; border-radius: 999px; background: var(--accent); animation: loadslide 1.1s ease-in-out infinite; }
@keyframes loadslide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
@keyframes slideFwd { from { opacity: 0; transform: translateX(44px); } to { opacity: 1; transform: none; } }
@keyframes slideBack { from { opacity: 0; transform: translateX(-44px); } to { opacity: 1; transform: none; } }
.onboard.slide-fwd > .card { animation: slideFwd 0.42s var(--ease) both; }
.onboard.slide-back > .card { animation: slideBack 0.42s var(--ease) both; }
.steps .seg.done { animation: pop 0.4s var(--ease); }

/* level, badges, water, tools */
.level-mini { width: 100%; cursor: pointer; border-color: #3a2a22; background: linear-gradient(120deg, rgb(var(--accent-rgb) / 0.14), var(--surface) 55%); }
@media (hover: hover) { .level-mini:hover { border-color: var(--accent); transform: translateY(-2px); } }
.level-mini .ring, .level-card .ring { width: 72px; height: 72px; flex: none; }
.xpbar { height: 8px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.xpbar.thin { height: 5px; }
.xpbar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, white)); animation: grow 1s var(--ease) both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); opacity: 0.62; animation: riseIn 0.5s var(--ease) both; }
.badge.got { opacity: 1; border-color: var(--accent); background: linear-gradient(160deg, rgb(var(--accent-rgb) / 0.16), var(--surface)); box-shadow: 0 8px 26px -16px var(--accent); }
.b-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--raised); color: var(--muted); }
.badge.got .b-ic { background: var(--accent); color: var(--accent-ink); animation: pop 0.6s var(--ease); }
.water { overflow: hidden; }
.bottle { width: 46px; height: 92px; border: 2px solid #3d4a5a; border-radius: 12px 12px 16px 16px; position: relative; overflow: hidden; flex: none; background: rgba(90, 160, 255, 0.05); }
.wfill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, #6fb7ff, #2f7fe0); transition: height 0.8s var(--ease); }
.wfill::before { content: ''; position: absolute; left: -20%; top: -6px; width: 140%; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); animation: wave 2.4s ease-in-out infinite; }
@keyframes wave { 0%, 100% { transform: translateX(-6%); } 50% { transform: translateX(6%); } }
.cups { display: flex; gap: 5px; flex-wrap: wrap; }
.cup { width: 16px; height: 20px; border-radius: 3px 3px 6px 6px; border: 1.5px solid #3d4a5a; transition: background 0.3s, transform 0.3s var(--ease); }
.cup.on { background: #4a9cf0; border-color: #4a9cf0; transform: scale(1.08); }
.plates { display: flex; gap: 8px; flex-wrap: wrap; }
.plate { padding: 10px 14px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); font-weight: 700; font-variant-numeric: tabular-nums; animation: pop 0.4s var(--ease) both; }
.pct-table { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.review-txt { white-space: pre-wrap; line-height: 1.55; }
.review-txt:empty { display: none; }

/* save pill sits above the tab bar so it never covers a page title; toasts sit a little higher */
.sync { top: auto; right: auto; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px); transform: translateX(-50%); box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.7); animation: fieldIn 0.3s var(--ease) both; }
.toast { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 64px); }
body.focus .sync { bottom: 16px; }
body.focus .toast { bottom: 64px; }
@media (min-width: 900px) { .sync { bottom: 16px; } .toast { bottom: 64px; } }

/* tiers, quests, swatches */
.badge.bronze.got { --tier: #d08a5a; } .badge.silver.got { --tier: #c9d1db; } .badge.gold.got { --tier: #ffc94d; }
.badge.got { border-color: var(--tier, var(--accent)); box-shadow: 0 8px 26px -16px var(--tier, var(--accent)); }
.badge.got .b-ic { background: var(--tier, var(--accent)); color: #1a1208; }
.badge.gold.got { background: linear-gradient(160deg, rgba(255, 201, 77, 0.18), var(--surface)); }
.tier-tag { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.68rem; color: var(--muted); margin-top: auto; }
.quest .q-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; transition: background 0.3s, border-color 0.3s; }
.quest.done .q-dot { background: var(--good); border-color: var(--good); color: #06220f; animation: pop 0.4s var(--ease); }
.quest.done .grow { text-decoration: line-through; color: var(--muted); }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform 0.2s var(--ease), border-color 0.2s; }
.swatch.on { border-color: var(--fg); transform: scale(1.12); }

.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatch-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 14px; border: 1px solid var(--line); background: var(--raised); cursor: pointer; color: var(--muted); transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s; }
.swatch-tile.on { border-color: var(--fg); color: var(--fg); transform: translateY(-2px); background: var(--surface); }
.swatch-tile .swatch { width: 30px; height: 30px; border: 0; transform: none; box-shadow: 0 0 0 3px transparent; transition: box-shadow 0.25s; }
.swatch-tile.on .swatch { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--fg); }

/* home + profile layout */
.sec-head { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.sec-head h2 { font-size: 1.05rem; letter-spacing: 0.14em; color: var(--muted); }
.sec-head::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.home-head { display: flex; align-items: center; gap: 14px; padding-top: 4px; }
.home-head h1 { font-size: 2.3rem; background: linear-gradient(90deg, #fff, color-mix(in srgb, var(--accent) 25%, white)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.big-av { width: 56px; height: 56px; border: 0; cursor: pointer; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.lvl-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 54px; height: 58px; border-radius: 16px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--fg); cursor: pointer; line-height: 1; gap: 2px; transition: transform 0.2s var(--ease); }
.lvl-chip span { font-size: 0.62rem; letter-spacing: 0.14em; color: var(--accent); font-weight: 700; }
.lvl-chip strong { font-family: var(--font-display); font-size: 1.6rem; }
.lvl-chip:active { transform: scale(0.94); }
.stat-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-strip .tile { padding: 12px 6px; text-align: center; }
.stat-strip .big { font-size: 1.5rem; }
.stat-strip .small { font-size: 0.72rem; }
.avatar.xl { width: 76px; height: 76px; font-size: 2.6rem; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent), 0 12px 30px -10px var(--accent); }
.me-hero { background: linear-gradient(160deg, var(--accent-soft), var(--surface) 60%); }
.me-hero h2 { font-size: 1.9rem; }
.lvl-row { all: unset; display: flex; flex-direction: column; gap: 8px; cursor: pointer; padding: 12px; margin-top: 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); box-sizing: border-box; }
.me-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.me-stat { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); animation: riseIn 0.5s var(--ease) both; }
.me-stat strong { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.me-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.me-stat:nth-child(2) { animation-delay: 0.05s; } .me-stat:nth-child(3) { animation-delay: 0.1s; } .me-stat:nth-child(4) { animation-delay: 0.15s; } .me-stat:nth-child(5) { animation-delay: 0.2s; } .me-stat:nth-child(6) { animation-delay: 0.25s; }
.kv-grid { display: grid; grid-template-columns: 1fr; }
@media (min-width: 560px) { .kv-grid { grid-template-columns: 1fr 1fr; column-gap: 28px; } }
.mini-badge { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); font-size: 0.9rem; }
.mini-badge .b-ic { width: 30px; height: 30px; border-radius: 50%; }
.mini-badge.bronze .b-ic { background: #d08a5a; color: #1a1208; } .mini-badge.silver .b-ic { background: #c9d1db; color: #1a1208; } .mini-badge.gold .b-ic { background: #ffc94d; color: #1a1208; }
.page-head .btn { flex: none; gap: 6px; }

/* overflow guards for long values */
.kv strong, .lvl-row strong, .me-stat strong, .tile .big { min-width: 0; overflow-wrap: anywhere; }
.kv { min-width: 0; }
.me-stats > *, .tiles > * { min-width: 0; }
.me-stat strong { font-size: clamp(1.3rem, 6.5vw, 1.8rem); }

/* ================= colour system ================= */
:root { --c-food: #4cd68f; --c-prog: #5aa9ff; --c-coach: #a078ff; --c-gold: #ffc94d; --c-protein: #ff6b8a; --c-carbs: #f5b942; --c-fat: #5aa9ff; }
body { background: radial-gradient(900px 520px at 8% -8%, rgb(var(--accent-rgb) / 0.16), transparent 60%), radial-gradient(760px 520px at 105% 18%, rgb(90 169 255 / 0.09), transparent 60%), radial-gradient(700px 500px at 50% 115%, rgb(160 120 255 / 0.08), transparent 60%), var(--bg); background-attachment: fixed; }
body[data-section=nutrition] { --sec: var(--c-food); } body[data-section=progress] { --sec: var(--c-prog); } body[data-section=coach] { --sec: var(--c-coach); } body[data-section=profile] { --sec: var(--c-gold); }
body[data-section=nutrition] { background-image: radial-gradient(900px 520px at 8% -8%, rgb(76 214 143 / 0.15), transparent 60%), radial-gradient(760px 520px at 105% 18%, rgb(90 169 255 / 0.07), transparent 60%), radial-gradient(700px 500px at 50% 115%, rgb(245 185 66 / 0.07), transparent 60%); }
body[data-section=progress] { background-image: radial-gradient(900px 520px at 8% -8%, rgb(90 169 255 / 0.16), transparent 60%), radial-gradient(760px 520px at 105% 18%, rgb(160 120 255 / 0.08), transparent 60%); }
body[data-section=coach] { background-image: radial-gradient(900px 520px at 8% -8%, rgb(160 120 255 / 0.17), transparent 60%), radial-gradient(760px 520px at 105% 18%, rgb(255 95 162 / 0.07), transparent 60%); }
body[data-section=profile] { background-image: radial-gradient(900px 520px at 8% -8%, rgb(255 201 77 / 0.13), transparent 60%), radial-gradient(760px 520px at 105% 18%, rgb(var(--accent-rgb) / 0.08), transparent 60%); }
.page-head h1::after { content: ''; display: block; width: 46px; height: 4px; border-radius: 4px; margin-top: 8px; background: linear-gradient(90deg, var(--sec, var(--accent)), transparent); animation: grow 0.8s var(--ease) both; transform-origin: left; }
.page-head .eyebrow, body[data-section] .card > .eyebrow:first-child { color: var(--sec, var(--accent)); }
.nav-item[data-tab=nutrition].on { color: var(--c-food); } .nav-item[data-tab=nutrition]::before { background: var(--c-food); box-shadow: 0 0 12px var(--c-food); }
.nav-item[data-tab=progress].on { color: var(--c-prog); } .nav-item[data-tab=progress]::before { background: var(--c-prog); box-shadow: 0 0 12px var(--c-prog); }
.nav-item[data-tab=coach].on { color: var(--c-coach); } .nav-item[data-tab=coach]::before { background: var(--c-coach); box-shadow: 0 0 12px var(--c-coach); }
.nav-item[data-tab=profile].on { color: var(--c-gold); } .nav-item[data-tab=profile]::before { background: var(--c-gold); box-shadow: 0 0 12px var(--c-gold); }
/* colourful stat tiles and quick actions */
.tiles .tile:nth-child(4n+1) { --t: var(--accent); } .tiles .tile:nth-child(4n+2) { --t: var(--c-prog); } .tiles .tile:nth-child(4n+3) { --t: var(--c-gold); } .tiles .tile:nth-child(4n+4) { --t: var(--c-food); }
.tile { position: relative; overflow: hidden; background: linear-gradient(160deg, color-mix(in srgb, var(--t, var(--accent)) 16%, var(--raised)), var(--raised) 70%); border-color: color-mix(in srgb, var(--t, var(--accent)) 28%, var(--line)); }
.tile .big { color: color-mix(in srgb, var(--t, var(--accent)) 35%, white); }
.qa-grid .qa:nth-child(6n+1) { --t: var(--accent); } .qa-grid .qa:nth-child(6n+2) { --t: var(--c-prog); } .qa-grid .qa:nth-child(6n+3) { --t: var(--c-coach); }
.qa-grid .qa:nth-child(6n+4) { --t: var(--c-food); } .qa-grid .qa:nth-child(6n+5) { --t: var(--c-gold); } .qa-grid .qa:nth-child(6n+6) { --t: #ff5fa2; }
.qa { background: linear-gradient(160deg, color-mix(in srgb, var(--t, var(--accent)) 14%, var(--surface)), var(--surface) 75%); border-color: color-mix(in srgb, var(--t, var(--accent)) 26%, var(--line)); }
.qa .ic { color: var(--t, var(--accent)); }
.sec-head h2 { background: linear-gradient(90deg, #fff, color-mix(in srgb, var(--accent) 40%, white)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ================= nutrition ================= */
.nut-today { background: linear-gradient(150deg, rgb(76 214 143 / 0.14), var(--surface) 60%); border-color: rgb(76 214 143 / 0.3); display: flex; flex-direction: column; gap: 16px; }
.kring .ring { width: 84px; height: 84px; } .kring .ring-fg { stroke: var(--c-food); } .kring .ring-text { font-size: 17px; }
.kbig { font-family: var(--font-display); font-size: 2rem; line-height: 1; }
.macros { display: flex; flex-direction: column; gap: 10px; }
.m-label { font-weight: 600; font-size: 0.92rem; }
.m-track { height: 9px; border-radius: 999px; background: var(--raised); overflow: hidden; margin-top: 5px; }
.m-fill { display: block; height: 100%; border-radius: 999px; transition: width 0.8s var(--ease); animation: grow 1s var(--ease) both; transform-origin: left; }
.mp .m-fill { background: var(--c-protein); } .mc .m-fill { background: var(--c-carbs); } .mf .m-fill { background: var(--c-fat); }
.mp .m-label { color: var(--c-protein); } .mc .m-label { color: var(--c-carbs); } .mf .m-label { color: var(--c-fat); }
.nut-tiles .tile:nth-child(1) { --t: var(--accent); } .nut-tiles .tile:nth-child(2) { --t: var(--c-protein); } .nut-tiles .tile:nth-child(3) { --t: var(--c-carbs); } .nut-tiles .tile:nth-child(4) { --t: var(--c-fat); }
.mchip { display: inline-flex; padding: 4px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; border: 1px solid; }
.mchip.k { color: color-mix(in srgb, var(--accent) 60%, white); border-color: rgb(var(--accent-rgb) / 0.4); background: rgb(var(--accent-rgb) / 0.12); }
.mchip.p { color: var(--c-protein); border-color: rgb(255 107 138 / 0.4); background: rgb(255 107 138 / 0.1); }
.mchip.c { color: var(--c-carbs); border-color: rgb(245 185 66 / 0.4); background: rgb(245 185 66 / 0.1); }
.mchip.f { color: var(--c-fat); border-color: rgb(90 169 255 / 0.4); background: rgb(90 169 255 / 0.1); }
.card.meal { --slot: var(--c-food); border-left: 4px solid var(--slot); animation: riseIn 0.5s var(--ease) both; }
.slot-breakfast { --slot: #f5b942 !important; } .slot-lunch { --slot: #4cd68f !important; } .slot-dinner { --slot: #a078ff !important; } .slot-snack { --slot: #5aa9ff !important; }
.slot-tag { align-self: flex-start; padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #101114; background: var(--slot); }
.card.meal.eaten { opacity: 0.7; background: linear-gradient(120deg, rgb(76 214 143 / 0.1), var(--surface)); }
.card.meal.eaten .mname { text-decoration: line-through; text-decoration-color: rgb(255 255 255 / 0.3); }
.mname { font-size: 1.12rem; }
.tabs { display: flex; gap: 6px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.tab { flex: 1; min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; transition: background 0.25s, color 0.25s; }
.tab.on { background: var(--sec, var(--accent)); color: #101114; }
.chip.today:not(.on) { border-color: var(--sec, var(--accent)); }
.chip.on { background: color-mix(in srgb, var(--sec, var(--accent)) 22%, transparent); border-color: var(--sec, var(--accent)); }

/* ================= workout mode ================= */
.session-top { background: linear-gradient(180deg, var(--bg) 75%, transparent); backdrop-filter: blur(6px); }
.session .bar { height: 10px; border-radius: 999px; background: var(--raised); }
.session .bar-fill { background: linear-gradient(90deg, var(--accent), var(--c-gold)); border-radius: 999px; transition: width 0.5s var(--ease); box-shadow: 0 0 14px rgb(var(--accent-rgb) / 0.6); }
.sname { font-family: var(--font-display); font-size: 1.35rem; text-transform: uppercase; letter-spacing: 0.02em; }
.exn.cur { box-shadow: 0 6px 18px -6px var(--accent); transform: translateY(-2px); } .exn { transition: transform 0.2s var(--ease), box-shadow 0.2s, background 0.2s; }
.exn.done { background: rgb(76 214 143 / 0.14); } .exn.part { background: rgb(245 185 66 / 0.12); }
.plan-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pc { display: inline-flex; align-items: baseline; gap: 5px; padding: 7px 12px; border-radius: 12px; font-size: 0.85rem; color: var(--muted); border: 1px solid; }
.pc b { font-family: var(--font-display); font-size: 1.3rem; color: var(--fg); line-height: 1; }
.pc-sets { background: rgb(var(--accent-rgb) / 0.12); border-color: rgb(var(--accent-rgb) / 0.4); } .pc-reps { background: rgb(90 169 255 / 0.12); border-color: rgb(90 169 255 / 0.4); }
.pc-rest { background: rgb(160 120 255 / 0.12); border-color: rgb(160 120 255 / 0.4); } .pc-rir { background: rgb(76 214 143 / 0.12); border-color: rgb(76 214 143 / 0.4); }
.srow.done { background: rgb(76 214 143 / 0.07); border-radius: 12px; padding: 2px 0; }
.rest { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); border-radius: 18px; backdrop-filter: blur(10px); background: rgb(21 23 26 / 0.92); box-shadow: 0 -10px 30px -12px rgb(0 0 0 / 0.8); display: flex; flex-direction: column; gap: 8px; }
.rest-time { font-size: 2rem; }
.rest-left { display: flex; align-items: baseline; gap: 12px; }
.rest-bar { height: 5px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.rest-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.5s linear; }
.rest.over .rest-fill { background: var(--good); } .rest.over { animation: pulseMark 1.4s ease-in-out infinite; }
.session .card { background: linear-gradient(170deg, rgb(var(--accent-rgb) / 0.08), var(--surface) 45%); }
body[data-section] .eyebrow { color: var(--sec, var(--accent)); }
.exn.cur, .exn.cur.part, .exn.cur.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rest .btn { white-space: nowrap; padding: 0 12px; }
.rest-left { gap: 10px; }
.water .eyebrow { color: var(--c-prog); }

/* ================= workouts tab ================= */
.t-push { --wt: var(--accent); } .t-pull { --wt: var(--c-prog); } .t-lower { --wt: var(--c-food); } .t-upper { --wt: var(--c-coach); } .t-full { --wt: var(--c-gold); }
.plan-head { background: linear-gradient(150deg, rgb(var(--accent-rgb) / 0.12), var(--surface) 60%); }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); color: var(--muted); font: inherit; cursor: pointer; transition: transform 0.2s var(--ease), border-color 0.2s; }
.wd:disabled { opacity: 0.5; cursor: default; }
.wd.train { color: var(--fg); border-color: color-mix(in srgb, var(--wt, var(--accent)) 55%, var(--line)); background: color-mix(in srgb, var(--wt, var(--accent)) 14%, var(--raised)); }
.wd.today { box-shadow: 0 0 0 2px var(--fg) inset; }
.wd-n { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.wd-d { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.8rem; }
.wd.done .wd-d { background: var(--good); color: #06220f; animation: pop 0.4s var(--ease); }
.wd.train:not(.done) .wd-d::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--wt, var(--accent)); }
.workout-card { --wt: var(--accent); border-left: 5px solid var(--wt); background: linear-gradient(120deg, color-mix(in srgb, var(--wt) 14%, var(--surface)), var(--surface) 55%); animation: riseIn 0.5s var(--ease) both; }
.workout-card.today { border-color: var(--wt); box-shadow: 0 10px 30px -16px var(--wt); }
.wc-day { color: var(--wt); } .wc-day b { color: var(--wt); } .wc-day b.ok { color: var(--good); }
.wc-name { font-size: 1.25rem; font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.02em; }
.wc-list { font-size: 0.85rem; color: var(--muted); }
.mini-stat { font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgb(255 255 255 / 0.06); color: var(--muted); }
.wd-hero { --wt: var(--accent); background: linear-gradient(150deg, color-mix(in srgb, var(--wt) 18%, var(--surface)), var(--surface) 65%); border-color: color-mix(in srgb, var(--wt) 35%, var(--line)); }
.wd-hero .tile { --t: var(--wt); }
.ex-row { border-left: 4px solid var(--c-prog); }
.ex-row:nth-child(4n+1) { border-left-color: var(--accent); } .ex-row:nth-child(4n+2) { border-left-color: var(--c-prog); } .ex-row:nth-child(4n+3) { border-left-color: var(--c-food); } .ex-row:nth-child(4n+4) { border-left-color: var(--c-coach); }
.ex-row .num { background: var(--accent); color: var(--accent-ink); }
.small-chips .pc { padding: 4px 9px; font-size: 0.78rem; } .small-chips .pc b { font-size: 1.05rem; }
.hint-fold summary { font-size: 0.85rem; padding: 4px 0; min-height: 0; color: var(--muted); }

/* ================= validation feedback ================= */
.ferr { color: var(--bad); font-size: 0.85rem; font-weight: 600; line-height: 1.2; min-height: 1.2em; }
.ferr[hidden] { display: block; visibility: hidden; }   /* space is reserved so showing an error never shifts the page under a tap */
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(255, 112, 112, 0.18); }

/* ================= admin + terms ================= */
.admin-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin-stats .tile { text-align: center; align-items: center; padding: 12px 8px; }
.admin-stats .tile strong { font-family: var(--font-display); font-size: 1.6rem; }
.admin-row { display: flex; flex-direction: column; align-items: stretch; gap: 0; width: 100%; padding: 0; overflow: hidden; transition: transform 0.2s var(--ease), border-color 0.2s; }
.admin-row:hover { border-color: var(--accent); }
.admin-main { display: flex; align-items: center; gap: 12px; flex: none; min-width: 0; width: 100%; padding: 14px; background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.admin-row > .btn, .admin-you { flex: none; align-self: flex-end; margin: -4px 14px 12px; }
.admin-main { align-items: flex-start; }
.admin-row.is-banned { border-color: var(--bad); background: linear-gradient(120deg, rgba(255, 112, 112, 0.1), var(--surface) 60%); }
.admin-row .grow { min-width: 0; } .admin-row .grow > * { overflow-wrap: anywhere; }
.flagline { color: var(--bad); font-size: 0.8rem; font-weight: 600; }
.pill.bad { background: rgba(255, 112, 112, 0.18); color: var(--bad); border-color: var(--bad); }
.pill.good { background: rgba(80, 220, 130, 0.16); color: var(--good); }
.notice.flag { background: rgba(255, 112, 112, 0.1); border-color: var(--bad); }
.ban-card { border-color: var(--bad); }
.owner-card { border-color: var(--accent); background: linear-gradient(150deg, var(--accent-soft), var(--surface) 70%); }
.terms-list { padding-left: 1.2em; display: grid; gap: 10px; }
.terms-check { align-items: flex-start; }
.terms-check input { margin-top: 3px; flex: none; }
.link-btn.inline { display: inline; padding: 0; min-height: 0; font-size: inherit; text-decoration: underline; }
textarea { width: 100%; }
.admin-stats .tile { display: flex; flex-direction: column; gap: 2px; }
.infoline { font-size: 0.9rem; font-weight: 600; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* terms, appeals, coach chat review */
.terms-h { font-family: var(--font-display); font-size: 1.05rem; margin-top: 14px; }
.terms p { line-height: 1.55; }
.terms-bullet { padding-left: 1.1em; text-indent: -0.9em; }
.terms-scroll { max-height: 38vh; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.appeal-quote { margin: 4px 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.appeal-box { border-top: 1px solid var(--line); padding-top: 12px; }
.appeal-card.ap-pending { border-color: var(--accent); }
.tile.hot { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.chat-row { display: flex; gap: 12px; align-items: center; text-align: left; width: 100%; cursor: pointer; color: inherit; }
.chat-row.is-flagged { border-color: var(--bad); }
.admin-msgs .msg { max-width: 100%; }
.admin-msgs .msg.flagged { border-color: var(--bad); background: rgba(255, 112, 112, 0.08); }
.coach-note { border-left: 2px solid var(--accent); padding-left: 8px; }
.terms-scroll .terms { gap: 8px; }
