:root {
  --bg: #0e1116;
  --bg2: #161b23;
  --card: #1b222d;
  --border: #2a3341;
  --text: #e8edf4;
  --muted: #8b97a8;
  --accent: #3ddc84;
  --accent-dim: #2aa863;
  --danger: #ff6b6b;
  --warn: #ffb454;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.6rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.2rem 0 .6rem; }

/* nav */
.nav {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.2rem; background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 1.25rem; color: var(--text); letter-spacing: .5px; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 1rem; flex: 1; flex-wrap: wrap; }
.nav-links a { color: var(--text); font-size: .95rem; opacity: .85; }
.nav-links a:hover { opacity: 1; text-decoration: none; color: var(--accent); }
.nav-links a.accent { color: var(--accent); font-weight: 600; }
.nav-links a.active { color: var(--accent); font-weight: 600; opacity: 1;
  text-decoration: underline; text-underline-offset: 5px; }
.nav-links .muted { color: var(--muted); }
.spacer { flex: 1; }
.lang a { color: var(--muted); font-size: .85rem; }
.lang a.on { color: var(--accent); font-weight: 700; }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.4rem; cursor: pointer; }
@media (max-width: 760px) {
  .nav-toggle { display: block; margin-left: auto; }
  .nav-links { display: none; flex-basis: 100%; flex-direction: column; align-items: flex-start; gap: .6rem; }
  body.nav-open .nav-links { display: flex; }
  .spacer { display: none; }
}

/* layout */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem;
}
.card h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin: .7rem 0 .25rem; }
input, select, textarea {
  width: 100%; padding: .55rem .7rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-dim); border-color: transparent; }
/* strip native select chrome (Safari renders its own, breaking consistency) and
   draw a matching caret so the dropdown looks like the inputs beside it */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393a1b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .65rem center; background-size: .85rem;
}
.btn {
  display: inline-block; padding: .55rem 1.2rem; border-radius: 8px; border: 0;
  background: var(--accent); color: #08130c; font-weight: 700; font-size: .95rem;
  cursor: pointer; margin-top: .8rem;
}
.btn:hover { background: var(--accent-dim); text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.btn.small { padding: .3rem .7rem; font-size: .82rem; margin-top: 0; }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.inline-form { display: inline; }
.row { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 110px; }

/* flash */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .95rem; }
.flash.ok { background: rgba(61,220,132,.12); border: 1px solid var(--accent-dim); }
.flash.error { background: rgba(255,107,107,.12); border: 1px solid var(--danger); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }

/* stats */
.stat { text-align: center; padding: .9rem .4rem; }
.stat .num { font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.stat .lbl { font-size: .8rem; color: var(--muted); }

/* progress bars */
.bar { height: 10px; background: var(--bg2); border-radius: 6px; overflow: hidden; margin: .25rem 0 .1rem; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar i.over { background: var(--warn); }

/* hero stat strip: progress rings */
.hero-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem;
  margin: 0 0 1rem;
}
.ring-tile {
  background: linear-gradient(160deg, var(--card) 0%, var(--bg2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem .4rem .55rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
}
.ring-tile svg { width: 74px; height: 74px; max-width: 100%; }
.ring-bg, .ring-fg { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--bg2); }
.ring-fg {
  stroke: var(--accent); stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 42px 42px;
  transition: stroke-dasharray .6s ease;
}
.ring-fg.done { stroke: var(--accent); filter: drop-shadow(0 0 4px rgba(61,220,132,.55)); }
.ring-fg.over { stroke: var(--warn); }
.ring-num { fill: var(--text); font-size: 17px; font-weight: 800; text-anchor: middle; }
.ring-sub { fill: var(--muted); font-size: 9.5px; text-anchor: middle; }
.ring-lbl { font-size: .72rem; color: var(--muted); margin-top: .35rem; letter-spacing: .02em; }
.weight-tile { justify-content: center; gap: .25rem; }
.weight-num { font-size: 1.45rem; font-weight: 800; line-height: 1.1; padding-top: .4rem; }
.weight-unit { font-size: .8rem; font-weight: 600; color: var(--muted); }
.trend {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.trend.good { background: rgba(61,220,132,.14); color: var(--accent); }
.trend.watch { background: rgba(255,180,84,.14); color: var(--warn); }
@media (max-width: 560px) {
  .hero-stats { gap: .45rem; }
  .ring-tile svg { width: 62px; height: 62px; }
  .weight-num { font-size: 1.15rem; }
}

/* coach tip card */
.tip-card {
  display: flex; align-items: center; gap: .9rem;
  background: linear-gradient(135deg, rgba(61,220,132,.10), rgba(61,220,132,.02));
  border: 1px solid var(--accent-dim); border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: 1rem;
}
.tip-ic {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(61,220,132,.15); color: var(--accent);
}
.tip-ic .ic { width: 22px; height: 22px; }
.tip-body { flex: 1; min-width: 200px; }
.tip-kicker { font-size: .68rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.tip-body p { margin: .1rem 0 0; font-size: .95rem; }
.tip-card .btn { margin-top: 0; white-space: nowrap; }
@media (max-width: 560px) {
  .tip-card { flex-wrap: wrap; }
  .tip-card .btn { margin-left: 48px; }
}

/* status dots (bloodwork flags) */
.status-dot {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .12rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700;
}
.status-dot i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.ok { background: rgba(61,220,132,.12); color: var(--accent); }
.status-dot.ok i { background: var(--accent); box-shadow: 0 0 5px rgba(61,220,132,.7); }
.status-dot.warn { background: rgba(255,180,84,.13); color: var(--warn); }
.status-dot.warn i { background: var(--warn); box-shadow: 0 0 5px rgba(255,180,84,.7); }

/* card headers with icon chip */
.card-h { display: flex; align-items: center; gap: .55rem; }
.card-ic {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(61,220,132,.12); color: var(--accent);
}
.card-ic .ic { width: 17px; height: 17px; }
.ic { width: 20px; height: 20px; }

/* chips */
.chip {
  display: inline-block; padding: .15rem .6rem; border-radius: 999px;
  border: 1px solid var(--border); font-size: .8rem; color: var(--muted); margin: 0 .3rem .3rem 0;
}
.chip.on, .chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 6px; font-size: .75rem; font-weight: 700; }
.badge.free { background: rgba(139,151,168,.2); color: var(--muted); }
.badge.pro { background: rgba(61,220,132,.15); color: var(--accent); }

/* coach chat */
.chat { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1rem; }
.msg { max-width: 85%; padding: .7rem 1rem; border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent-dim); color: #06130b; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .saved-link { display: block; margin-top: .5rem; font-weight: 600; }
.chat-input { display: flex; gap: .6rem; position: sticky; bottom: 0; background: var(--bg); padding: .6rem 0; }
.chat-input textarea { resize: none; height: 58px; }
.chat-input .btn { margin-top: 0; align-self: stretch; }
.typing { color: var(--muted); font-style: italic; }

/* charts */
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .line { stroke: var(--accent); stroke-width: 2; fill: none; }
.chart .dot { fill: var(--accent); }
.chart text { fill: var(--muted); font-size: 10px; }

/* auth pages */
.auth-box { max-width: 420px; margin: 3rem auto; }
.auth-box .brand-big { font-size: 2rem; font-weight: 800; text-align: center; display: block; margin-bottom: 1rem; color: var(--text); }
.auth-box .brand-big span { color: var(--accent); }

/* logged-out landing: hero + login side by side */
.landing {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 2.5rem;
  align-items: center; max-width: 960px; margin: 1.5rem auto; min-height: 70vh;
}
.landing .auth-box { margin: 0; width: 100%; max-width: 420px; }
.landing-hero { min-width: 0; }
.hero-title { font-size: 2.6rem; font-weight: 800; letter-spacing: .5px; margin: .2rem 0 .5rem; }
.hero-title span { color: var(--accent); }
.hero-lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 1.2rem; max-width: 30ch; }
.hero-feats { list-style: none; padding: 0; margin: 0 0 1.4rem; }
.hero-feats li { display: flex; align-items: center; gap: .6rem; margin: .55rem 0; font-size: .96rem; }
.hero-feats .ic { flex: 0 0 auto; width: 20px; height: 20px; color: var(--accent); }
.hero-cta { margin-top: 0; }

/* animated hero art: a row of KPI rings (numbers count up) + ECG sweep */
.hero-art { max-width: 340px; margin-bottom: .6rem; }
.hero-art svg { width: 100%; height: auto; display: block; overflow: visible; }
.hr-bg { fill: none; stroke: var(--bg2); stroke-width: 7; }
.hr-fg {
  fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 188.5; stroke-dashoffset: 188.5;
  transform: rotate(-90deg); transform-box: fill-box; transform-origin: center;
  filter: drop-shadow(0 0 3px rgba(61,220,132,.5));
}
.hr-num { fill: var(--text); font-size: 16px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
.hero-ecg {
  fill: none; stroke: var(--accent); stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round; opacity: .65;
  stroke-dasharray: 300; animation: ecgSweep 4.3s linear infinite;
}
@keyframes ecgSweep {
  0% { stroke-dashoffset: 300; }
  55% { stroke-dashoffset: 0; }
  70%, 100% { stroke-dashoffset: -300; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-ecg { animation: none; stroke-dashoffset: 0; }
}
@media (max-width: 760px) {
  .landing { grid-template-columns: 1fr; gap: 1.4rem; min-height: 0; text-align: center; }
  .landing .auth-box { margin: 0 auto; }
  .hero-lead { margin-left: auto; margin-right: auto; }
  .hero-feats { display: block; width: max-content; max-width: 100%; margin: 0 auto 1.4rem; text-align: left; }
  .hero-art { margin: 0 auto .6rem; max-width: 260px; }
  .hero-title { font-size: 2.2rem; }
}

/* footer */
.footer { padding: 1rem 1.2rem 1.6rem; border-top: 1px solid var(--border); background: var(--bg2); }
.footer p { max-width: 1080px; margin: 0 auto; color: var(--muted); font-size: .78rem; }
.footer-links { margin: 0 auto .5rem !important; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* legal / policy pages */
.legal { max-width: 780px; margin: 0 auto; line-height: 1.65; }
.legal h1 { margin-bottom: .3rem; }
.legal h2 { margin-top: 1.6rem; font-size: 1.15rem; }
.legal ul { padding-left: 1.2rem; }
.legal li { margin: .3rem 0; }
.requisites { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.requisites th, .requisites td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.requisites th { width: 42%; color: var(--muted); font-weight: 600; }

/* PWA install bar */
.install-bar {
  position: fixed; left: .6rem; right: .6rem; bottom: .6rem; z-index: 80;
  display: flex; align-items: center; gap: .8rem;
  background: var(--card); border: 1px solid var(--accent-dim);
  border-radius: 14px; padding: .7rem .9rem; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  max-width: 520px; margin: 0 auto;
}
/* the [hidden] attribute must win over the display above (author display:flex
   otherwise overrides the UA [hidden]{display:none} rule) */
.install-bar[hidden] { display: none; }
.install-bar img { border-radius: 9px; flex: 0 0 auto; }
.install-text { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.install-close { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: .2rem .3rem; }

/* exercise photo popover */
#ex-pop {
  display: none; position: absolute; z-index: 60; width: 300px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: .5rem; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
#ex-pop img { width: 100%; border-radius: 8px; display: block; background: #fff; }
#ex-pop .cap { margin: .4rem 0 0; font-size: .85rem; color: var(--muted); text-align: center; }
#ex-pop.fixed {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(90vw, 340px);
}
.ex-pic { cursor: pointer; }

/* set editor rows */
.set-row { display: grid; grid-template-columns: 2fr 70px 90px 70px 36px; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.set-row button { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 1.1rem; }
@media (max-width: 560px) { .set-row { grid-template-columns: 1fr 60px 80px 36px; } .set-row .rpe { display: none; } }
