/* ==========================================================================
   StayOnTrack – design system
   Editorial and calm: Midnight Navy type on white and Soft Blue surfaces,
   one Coral accent used like a highlighter, a muted blue as quiet second accent.
   Three radii create rhythm: sharp buttons · asymmetric cards · round pills/data cards.
   ========================================================================== */

@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/space-grotesk.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* Light: Soft Blue · Midnight Navy · Coral */
  --bg: #edf5f8;            /* page – a whisper of Soft Blue */
  --surface: #ffffff;       /* cards */
  --surface-2: #f4f9fb;     /* nested */
  --ivory: #b6dfed;         /* Soft Blue – featured blocks */
  --text: #002941;          /* Midnight Navy */
  --steel: #2c4a5e;
  --muted: #526b7b;         /* 5.6:1 on white, 5.1:1 on page */
  --border: #e1ebf0;
  --line: #c6d7e0;          /* hairline dividers only */
  --field: #7d95a5;         /* control outlines: 3.1:1 on white */
  --accent: #fd6e6e;        /* Coral */
  --accent-soft: #ffe4e4;
  --accent-text: #002941;
  --accent-display: #e85656; /* coral for large display text: 3.2:1 */
  --brass: #3b6f88;         /* quiet second accent between navy and soft blue */
  --btn-bg: #002941;
  --btn-text: #ffffff;
  --weight: #fd6e6e;
  --steps: #002941;
  --sleep: #4f9cbb;
  --good: #2f7d5b;
  --warn: #8a5a07;          /* 5.9:1 on white */
  --bad: #c0392b;

  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --track: -0.02em;

  --r-card: 14px 0 0 0;     /* signature: soft top-left, sharp elsewhere */
  --r-data: 20px;           /* data widgets */
  --r-pill: 200px;          /* navigation & tags */
  --r-btn: 0;               /* buttons: deliberately square */
  --radius: 14px;
  --shadow: none;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #001a2b;
    --surface: #002941;
    --surface-2: #08344f;
    --ivory: #0d3f5e;
    --text: #eaf5fa;
    --steel: #c4dbe6;
    --muted: #8fb0c2;
    --border: #0f3c58;
    --line: #1e4f6c;
    --field: #5f8ba3;
    --accent: #fd6e6e;
    --accent-soft: #4a2333;
    --accent-text: #002941;
    --accent-display: #fd6e6e;
    --brass: #b6dfed;
    --btn-bg: #fd6e6e;
    --btn-text: #002941;
    --weight: #fd6e6e;
    --steps: #b6dfed;
    --sleep: #7cc3dc;
    --good: #7fd1a0;
    --warn: #f2c46d;
    --bad: #ff8f8f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #001a2b;
    --surface: #002941;
    --surface-2: #08344f;
    --ivory: #0d3f5e;
    --text: #eaf5fa;
    --steel: #c4dbe6;
    --muted: #8fb0c2;
    --border: #0f3c58;
    --line: #1e4f6c;
    --field: #5f8ba3;
    --accent: #fd6e6e;
    --accent-soft: #4a2333;
    --accent-text: #002941;
    --accent-display: #fd6e6e;
    --brass: #b6dfed;
    --btn-bg: #fd6e6e;
    --btn-text: #002941;
    --weight: #fd6e6e;
    --steps: #b6dfed;
    --sleep: #7cc3dc;
    --good: #7fd1a0;
    --warn: #f2c46d;
    --bad: #ff8f8f;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-body);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Links: base colour with a coral underline */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: var(--track);
  margin: 0;
}
h1 { font-size: clamp(2rem, 4.2vw, 2.75rem); line-height: 1.02; letter-spacing: -0.03em; }
h2 { font-size: 1.3rem; line-height: 1.2; }
h3 { font-size: 1.08rem; line-height: 1.25; }
strong { font-weight: 600; }

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: var(--track);
  color: var(--brass);
  margin: 0 0 8px !important;
  display: flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before { content: ''; width: 18px; height: 1px; background: var(--accent); }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 16px calc(48px + env(safe-area-inset-bottom));
}
@media (min-width: 720px) { .container { padding-left: 28px; padding-right: 28px; } }

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 720px) { .topbar { padding-left: 28px; padding-right: 28px; } }
.brand {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  color: var(--text); text-decoration: none;
  font-family: var(--font-display); font-size: 1.15rem; letter-spacing: var(--track);
}
.brand:hover { color: var(--text); }
.brand img { height: 38px; width: auto; border-radius: 10px 0 0 0; display: block; }

/* ---- Navigation: floating pill ---- */
.nav {
  display: flex; gap: 2px; justify-content: center;
  background: var(--bg); border-radius: var(--r-pill); padding: 4px;
  margin: 0 auto;
}
.nav a, .tabs a {
  display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none; white-space: nowrap;
  font-family: var(--font-display); letter-spacing: var(--track);
}
.nav a {
  padding: 7px 16px; border-radius: var(--r-pill); min-height: 38px;
  color: var(--steel); font-size: 0.98rem;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--text); }
.nav a[aria-current="page"]::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.count {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-text);
  font: 600 0.72rem/1 var(--font-body); display: inline-flex; align-items: center; justify-content: center;
}

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs a {
  padding: 10px 0; color: var(--muted); font-size: 1.02rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.topbar-user { display: flex; align-items: center; gap: 4px; font-size: 0.88rem; color: var(--muted); min-width: 0; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .nav a { flex: 1; justify-content: center; padding: 7px 8px; }
}
@media (max-width: 420px) {
  .brand span { display: none; }
  .nav a { font-size: 0.86rem; gap: 4px; padding: 7px 4px; }
  .nav a[aria-current="page"]::before { display: none; }
}

/* ---- Cards & layout ---- */
.card {
  background: var(--surface);
  border: 0;
  border-radius: var(--r-card);
  padding: 20px;
}
@media (min-width: 720px) { .card { padding: 24px; } }
.card.feature, .banner, .checkin-card, .plan-summary, .requests-card {
  background: var(--ivory);
}
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 28px; }
.page-head p { margin: 10px 0 0; color: var(--steel); max-width: 60ch; }
.page-head p.muted { color: var(--steel); }

.grid-2 { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.grid-2 > * { min-width: 0; }
@media (min-width: 860px) {
  .grid-2 { grid-template-columns: minmax(300px, 380px) 1fr; align-items: start; }
}

/* ---- Forms ---- */
label { display: block; font-size: 0.86rem; font-weight: 500; margin-bottom: 6px; color: var(--steel); }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }

input, textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--field);
  border-radius: 0;
  padding: 10px 12px;
  min-height: 46px;
  transition: border-color 0.12s;
}
.card input, .card textarea, .card select { background: var(--surface); }
.feature input, .feature textarea, .checkin-card textarea { background: var(--surface); }
input:hover, textarea:hover, select:hover { border-color: var(--steel); }
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.input-unit { position: relative; }
.input-unit input { padding-right: 56px; }
.input-unit span {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.84rem; pointer-events: none;
}

/* ---- Buttons: square, quiet, typographic ---- */
button, .btn {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 400;
  letter-spacing: var(--track);
  line-height: 1;
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  padding: 12px 20px;
  min-height: 46px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.btn-primary { background: var(--btn-bg); color: var(--btn-text); }
.btn-primary:hover { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--text); }
.btn-secondary:hover { background: var(--text); color: var(--surface); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; color: var(--steel); padding: 8px 10px; min-height: 36px; }
.btn-ghost:hover { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; min-height: 34px; font-size: 0.88rem; }
button:disabled { opacity: 0.5; cursor: default; }
button:disabled:hover { background: inherit; }

.error { color: var(--bad); font-size: 0.9rem; margin: 10px 0 0; }

/* ---- Login: editorial hero ---- */
.login-wrap {
  min-height: calc(100dvh - 76px);
  display: grid; align-items: center; gap: 32px;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1080px; margin: 0 auto;
}
@media (min-width: 900px) { .login-wrap { grid-template-columns: 1.1fr minmax(360px, 420px); gap: 64px; } }
.login-intro h1 { font-size: clamp(2.4rem, 6vw, 4.1rem); line-height: 0.95; letter-spacing: -0.035em; }
.login-intro h1 em { font-style: normal; color: var(--accent-display); }
.login-intro p { color: var(--steel); font-size: 1.08rem; max-width: 46ch; margin: 18px 0 0; }
.login-facts { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 28px; font-family: var(--font-display); color: var(--brass); font-size: 0.9rem; }
.login-facts span::before { content: '— '; color: var(--accent); }
.login-card { width: 100%; }
.login-logo { display: block; width: 100%; height: auto; border-radius: 14px 0 0 0; margin-bottom: 22px; }
@media (max-width: 899px) { .login-intro h1 { font-size: 2.3rem; } .login-intro { order: 2; } }

/* ---- Segmented control (pill dialect) ---- */
.segmented { display: inline-flex; background: var(--surface); border-radius: var(--r-pill); padding: 3px; }
.segmented button {
  min-height: 32px; padding: 6px 14px; font-size: 0.86rem;
  background: transparent; color: var(--muted); border-radius: var(--r-pill);
}
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--surface); }

/* ---- Stats: data cards ---- */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card.stat { padding: 18px 18px 16px; border-radius: var(--r-data); }
.stat-label {
  font-family: var(--font-display); letter-spacing: var(--track);
  font-size: 0.84rem; color: var(--brass); display: flex; align-items: center; gap: 7px;
}
.stat-value {
  font-family: var(--font-display); font-size: 2.1rem; font-weight: 400; letter-spacing: -0.035em;
  line-height: 1.05; margin-top: 10px; font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: 0.95rem; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.stat-sub { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.dot-key { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.up { color: var(--bad); }
.down { color: var(--good); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

/* ---- Charts ---- */
.chart-card { border-radius: var(--r-data); }
.chart-card h3 { margin-bottom: 10px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 400 11px var(--font-body); font-variant-numeric: tabular-nums; }
.chart .goal { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.55; }
.chart .goal-label { fill: var(--steel); font: 400 11px var(--font-display); }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-raw { stroke: var(--brass); stroke-width: 1.2; opacity: 0.7; }
.chart .line-trend { stroke-width: 2.6; }
.chart .dot { fill: var(--brass); opacity: 0.85; }
.chart .bar { fill: var(--series); opacity: 0.22; }
.chart .bar-hit { opacity: 0.9; }
.chart-steps .bar-hit { fill: var(--steps); opacity: 1; }
.chart .cursor { stroke: var(--text); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.5; }
.chart .marker { fill: var(--surface); stroke: var(--series); stroke-width: 2.4; }
.chart-empty { padding: 48px 0; text-align: center; color: var(--muted); font-size: 0.9rem; }
.chart-tip {
  position: absolute; top: 0; transform: translateX(-50%);
  background: var(--text); color: var(--surface);
  padding: 6px 10px; border-radius: 0; border-top: 2px solid var(--accent);
  font-size: 0.76rem; line-height: 1.35;
  pointer-events: none; text-align: center; white-space: nowrap;
}
.chart-tip strong { display: block; font: 400 0.95rem var(--font-display); letter-spacing: var(--track); }
.chart-tip span { display: block; }
.chart-weight { --series: var(--weight); }
.chart-steps { --series: var(--steps); }
.chart-sleep { --series: var(--sleep); }
.chart-kcal { --series: var(--accent); }
.legend { display: flex; gap: 14px; font-size: 0.76rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; background: var(--weight); display: inline-block; }
.legend i.faint { background: var(--brass); opacity: 0.8; height: 1px; }
.legend .lg-band { width: 14px; height: 10px; background: var(--accent); opacity: 0.22; display: inline-block; }
.legend .lg-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Calories */
.chart .kcal-band { fill: var(--accent); opacity: 0.13; }
.chart .kcal-mid { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .kcal-mid-label { fill: var(--accent); font: 400 11px var(--font-display); }
.chart .kcal-ok { fill: var(--good); stroke: var(--surface); stroke-width: 1.5; }
.chart .kcal-miss { fill: var(--bad); stroke: var(--surface); stroke-width: 1.5; }
.chart .kcal-unknown { fill: var(--surface); stroke: var(--bad); stroke-width: 2; }
.kcal-now { font-size: 0.92rem; color: var(--muted); }
.kcal-now strong { font: 400 1.35rem var(--font-display); letter-spacing: -0.03em; color: var(--text); }

/* No text selection / callout on long press in charts */
.chart, .chart *, .chart-card, .chart-card * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.chart svg { cursor: crosshair; }

/* ---- Tables: datasheet look ---- */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
@media (min-width: 720px) { .table-wrap { margin: 0 -24px -24px; } }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 11px 20px; border-top: 1px solid var(--border); white-space: nowrap; }
@media (min-width: 720px) { th, td { padding-left: 24px; padding-right: 24px; } }
th {
  font: 400 0.74rem var(--font-display); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
td.num, th.num { text-align: right; }
td.note { white-space: normal; min-width: 160px; max-width: 320px; color: var(--muted); }
td.actions { text-align: right; }
tbody tr:hover td { background: var(--surface-2); }

/* ---- Client list (coach) ---- */
.client-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.client-card { display: block; color: inherit; text-decoration: none; transition: box-shadow 0.12s; }
.client-card:hover { color: inherit; box-shadow: inset 0 0 0 1px var(--text); }
.client-card h3 { font-size: 1.2rem; }
.client-card .metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.client-card .metric-v { font: 400 1.15rem var(--font-display); letter-spacing: var(--track); font-variant-numeric: tabular-nums; }
.client-card .metric-l { font-size: 0.74rem; color: var(--muted); }

/* ---- Tags ---- */
.badge {
  font: 500 0.74rem/1.5 var(--font-body); padding: 2px 10px; border-radius: 20px;
  background: var(--surface-2); color: var(--steel); white-space: nowrap; display: inline-block;
}
.feature .badge, .banner .badge, .checkin-card .badge, .plan-summary .badge { background: var(--surface); }
.badge.good { background: color-mix(in srgb, var(--good) 13%, transparent); color: var(--good); }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.unread-badge {
  font: 600 0.74rem/1.5 var(--font-body); padding: 2px 9px; border-radius: 20px;
  background: var(--accent); color: var(--accent-text); white-space: nowrap;
}

.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }

.credentials { background: var(--surface-2); padding: 14px; font-family: ui-monospace, Menlo, monospace; font-size: 0.88rem; white-space: pre-wrap; user-select: all; border-left: 2px solid var(--accent); }

/* ---- Dialog ---- */
dialog {
  border: 0;
  border-radius: 16px 0 0 0;
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
dialog::backdrop { background: rgba(0, 26, 43, 0.55); }
dialog h2 { margin-bottom: 16px; font-size: 1.45rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.sub-dialog { z-index: 100; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--surface);
  padding: 12px 18px; border-radius: 0; border-left: 3px solid var(--accent);
  font: 400 0.95rem var(--font-display); letter-spacing: var(--track);
  z-index: 50; max-width: calc(100vw - 32px);
}
.toast.error-toast { background: var(--bad); color: #fff; border-left-color: #fff; }

.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font: 400 0.95rem var(--font-display); color: var(--steel); margin-bottom: 10px; }
.back:hover { color: var(--text); }

/* ---- Chat ---- */
.chat { display: flex; flex-direction: column; height: min(72vh, 680px); padding: 0 !important; overflow: hidden; max-width: 860px; }
@media (max-width: 720px) { .chat { height: calc(100dvh - 210px); min-height: 360px; } }
.chat-head { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.chat-head p { margin: 4px 0 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.chat-day { align-self: center; font: 400 0.76rem var(--font-display); color: var(--brass); padding: 2px 10px; margin: 10px 0; }
.msg { max-width: min(78%, 560px); padding: 10px 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg time { display: block; font-size: 0.7rem; opacity: 0.6; margin-top: 4px; text-align: right; }
.msg.theirs { align-self: flex-start; background: var(--surface); border-radius: 0 14px 14px 14px; }
.msg.mine { align-self: flex-end; background: var(--text); color: var(--surface); border-radius: 14px 0 14px 14px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 380px; padding: 16px; }
.chat-form { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--border); background: var(--surface); align-items: flex-end; }
.chat-form textarea { min-height: 46px; max-height: 160px; resize: none; }

/* ---- Push & settings ---- */
.section-head { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.push-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .push-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .push-grid #coach-push-card { grid-column: 1 / -1; }
}
.settings-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); max-width: 860px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.plain-list a { color: var(--text); text-decoration: none; font-family: var(--font-display); letter-spacing: var(--track); }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif { padding: 12px 0; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.notif:first-child { border-top: 0; padding-top: 0; }
.notif strong { font: 400 1.02rem var(--font-display); letter-spacing: var(--track); }
.notif.inactive { opacity: 0.55; }
.notif-actions { gap: 2px; margin-top: 2px; }
.notif.automation { background: var(--ivory); border-radius: 12px 0 0 0; padding: 14px 16px; margin-bottom: 14px; border: 0; }
.danger-text { color: var(--bad); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.banner strong { font: 400 1.1rem var(--font-display); letter-spacing: var(--track); }
.banner p { margin: 6px 0 0; }
.hint-box { background: var(--surface-2); padding: 12px 14px; font-size: 0.875rem; border-left: 2px solid var(--brass); }
.copy-field { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); padding: 6px 6px 6px 12px; }
.copy-field code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 0.85rem; background: transparent; }
.howto summary { cursor: pointer; font: 400 1rem var(--font-display); letter-spacing: var(--track); padding: 8px 0; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }
.howto ol { padding-left: 20px; margin: 10px 0; }
.howto li { margin-bottom: 10px; font-size: 0.92rem; }
.howto ul { padding-left: 18px; margin: 4px 0; }
code { font-family: ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; font-size: 0.85em; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-size: 0.86rem; font-weight: 500; margin-bottom: 8px; padding: 0; color: var(--steel); }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 400; font-size: 0.95rem; margin: 6px 0; color: var(--text); }
label.check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--text); }
.choice-list { margin: 4px 0 0 28px; max-height: 180px; overflow-y: auto; }

/* Pill toggles in dialogs */
.seg-wide { display: flex; width: 100%; margin-bottom: 12px; background: var(--bg); }
.seg-wide label, .weekday-picker label { flex: 1; margin: 0; position: relative; }
.seg-wide input, .weekday-picker input { position: absolute; opacity: 0; pointer-events: none; }
.seg-wide span { display: block; text-align: center; padding: 7px 4px; border-radius: var(--r-pill); color: var(--muted); font: 400 0.88rem var(--font-display); cursor: pointer; }
.seg-wide input:checked + span { background: var(--text); color: var(--surface); }
.seg-wide input:focus-visible + span, .weekday-picker input:focus-visible + span { outline: 2px solid var(--accent); }
.weekday-picker { display: flex; gap: 4px; margin-bottom: 12px; }
.weekday-picker span { display: block; text-align: center; padding: 9px 0; border: 1px solid var(--field); font: 400 0.88rem var(--font-display); cursor: pointer; color: var(--muted); }
.weekday-picker input:checked + span { background: var(--text); border-color: var(--text); color: var(--surface); }

/* Yes / no choices: square, navy when chosen */
.choice { display: flex; gap: 8px; }
.choice label { flex: 1; margin: 0; position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 8px 10px;
  border: 1px solid var(--line); font: 400 0.98rem var(--font-display); letter-spacing: var(--track);
  color: var(--steel); cursor: pointer; background: var(--surface);
}
.choice span:hover { border-color: var(--text); }
.choice input:checked + span { border-color: var(--text); background: var(--text); color: var(--surface); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice input[value="false"]:checked + span.no { border-color: var(--bad); color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.plan-hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.kcal-range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.kcal-range > span { color: var(--muted); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; font: 400 0.98rem var(--font-display); color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 46px; height: 26px; border-radius: var(--r-pill); background: var(--field); position: relative; transition: background 0.15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
.switch b { font-weight: 400; }

/* ---- Check-in ---- */
.progress { width: 240px; max-width: 100%; height: 3px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.queue { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 12px; margin-bottom: 12px; scrollbar-width: thin; }
.queue-item {
  display: inline-flex; align-items: center; gap: 9px; flex-shrink: 0;
  padding: 6px 16px 6px 6px; border-radius: var(--r-pill); background: var(--surface);
  color: var(--text); text-decoration: none; font: 400 0.95rem var(--font-display); letter-spacing: var(--track);
}
.queue-item:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.queue-item[aria-current="page"] { background: var(--text); color: var(--surface); }
.queue-num {
  width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font: 500 0.76rem var(--font-body);
}
.queue-item[aria-current="page"] .queue-num { background: var(--accent); color: var(--accent-text); }
.queue-item.done .queue-num { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.queue-item.done { color: var(--muted); }
.queue-item.done[aria-current="page"] { color: var(--surface); }
.checkin-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .checkin-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); align-items: start; }
  .checkin-form { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
}
.checkin-form h2 { margin-bottom: 8px; }
.compare td:first-child { color: var(--steel); }
.compare td strong { font: 400 1rem var(--font-display); }
.day-table .empty-day td { color: var(--muted); opacity: 0.55; }
.plan-field.changed input { border-color: var(--accent); background: var(--accent-soft); }
.client-msgs { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.client-msgs .msg { max-width: 100%; background: var(--surface-2); }
details.card summary { cursor: pointer; font-family: var(--font-display); }
details.card summary strong { font-weight: 400; }
.checkin-card { margin-bottom: 16px; border-left: 3px solid var(--accent); }
.checkin-card h2 { font-size: 1.25rem; }
.checkin-msg { white-space: pre-wrap; margin: 12px 0; color: var(--steel); }
.proposal { background: var(--surface); padding: 12px 14px; }
.change-list { list-style: none; margin: 0; padding: 0; }
.change-list li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; flex-wrap: wrap; font-size: 0.95rem; }
.change-list strong { font: 400 1.05rem var(--font-display); letter-spacing: var(--track); }
.change-list s { text-decoration-thickness: 1px; }
.reply-form { margin-top: 12px; }

/* ---- Two-column pages: left column scrolls with the page, then stays (app.js sets `top`) ---- */
@media (min-width: 860px) {
  .grid-2 > :first-child { position: sticky; top: 76px; }
}

/* ---- Only vertical page scrolling ---- */
html { overflow-x: hidden; overscroll-behavior-x: none; }
@supports (overflow: clip) {
  html, body { overflow-x: clip; }
}

/* ---- Nutrition plan ---- */
.nutrition-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .nutrition-grid { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.plan-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.plan-summary .stat-value { margin-top: 4px; }
.meal-head { margin-bottom: 10px; }
.meal-head h2 { font-size: 1.3rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meal.has-request { box-shadow: inset 3px 0 0 var(--warn); }
.meal-items { list-style: none; margin: 0 0 14px; padding: 0; }
.meal-items li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.meal-items li:first-child { border-top: 0; }
.item-main { display: flex; flex-direction: column; min-width: 0; }
.item-name { font: 400 1.02rem var(--font-display); letter-spacing: var(--track); overflow-wrap: anywhere; }
.plan-table td { vertical-align: middle; }
.plan-table tr.has-request td { background: color-mix(in srgb, var(--warn) 7%, transparent); }
.amount-input { width: 78px; min-height: 36px; padding: 4px 8px; text-align: right; display: inline-block; }
.add-item { display: grid; grid-template-columns: minmax(0, 1fr) 130px auto; gap: 8px; margin-top: 16px; align-items: start; }
@media (max-width: 600px) { .add-item { grid-template-columns: 1fr 1fr; } .add-item > :first-child { grid-column: 1 / -1; } }
.add-meal h3 { margin-bottom: 10px; }
.add-meal .row { margin-bottom: 10px; }
.chip { border: 1px solid var(--field) !important; border-radius: var(--r-pill) !important; padding: 6px 14px !important; }
.chip:hover { border-color: var(--text) !important; text-decoration: none !important; }
.swap-req { padding: 12px 0; border-top: 1px solid var(--border); }
.swap-req:first-of-type { border-top: 0; }
.swap-req .swap-req { padding: 0; border: 0; }
.swap-req strong { font: 400 1rem var(--font-display); letter-spacing: var(--track); }
.requests-card { border-left: 3px solid var(--accent); }
.food-picker { position: relative; }
.food-results {
  list-style: none; margin: 4px 0 0; padding: 4px; max-height: 240px; overflow-y: auto;
  border: 1px solid var(--text); background: var(--surface);
}
.food-results li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; cursor: pointer; }
.food-results li:hover { background: var(--surface-2); }
.food-results li.create { color: var(--text); font-family: var(--font-display); text-decoration: underline; text-decoration-color: var(--accent); }
.food-table-wrap { max-height: 520px; overflow-y: auto; }

/* ---- Admin ---- */
.activity-table td, .activity-table th { white-space: nowrap; }
.activity-table a { color: var(--text); text-decoration: none; }
.activity-table a strong { font: 400 1rem var(--font-display); letter-spacing: var(--track); }
.reminder-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.reminder-grid .input-unit input { padding-right: 160px; }

/* ---- Client categories (coach only): small coloured text tags ---- */
:root {
  --cat-diet: #d64545;
  --cat-reverse: #b7791f;
  --cat-build: #2c6fa3;
  --cat-maintenance: #2f7d5b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cat-diet: #ff8f8f;
    --cat-reverse: #f2c46d;
    --cat-build: #8cc8ea;
    --cat-maintenance: #7fd1a0;
  }
}
:root[data-theme="dark"] {
    --cat-diet: #ff8f8f;
    --cat-reverse: #f2c46d;
    --cat-build: #8cc8ea;
    --cat-maintenance: #7fd1a0;
  }
.cat-diet { --cat: var(--cat-diet); }
.cat-reverse { --cat: var(--cat-reverse); }
.cat-build { --cat: var(--cat-build); }
.cat-maintenance { --cat: var(--cat-maintenance); }
.cat {
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle;
  font: 500 0.72rem/1.4 var(--font-body); letter-spacing: 0.02em;
  color: var(--cat); background: color-mix(in srgb, var(--cat) 11%, transparent);
  padding: 1px 8px; border-radius: 20px; white-space: nowrap;
}
.cat::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--cat); }
h1 .cat { font-size: 0.8rem; position: relative; top: -0.5em; }
h2 .cat, h3 .cat { position: relative; top: -2px; }
.cat-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cat); display: inline-block; margin-left: -2px; }
.cat-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-option {
  min-height: 36px; padding: 7px 14px; border-radius: var(--r-pill) !important;
  background: transparent; color: var(--steel); border: 1px solid var(--line); font-size: 0.92rem;
}
.cat-option:hover { border-color: var(--text); }
.cat-option[aria-checked="true"] { border-color: var(--text); background: var(--text); color: var(--surface); }
.cat-option.cat-diet[aria-checked="true"], .cat-option.cat-reverse[aria-checked="true"],
.cat-option.cat-build[aria-checked="true"], .cat-option.cat-maintenance[aria-checked="true"] {
  background: color-mix(in srgb, var(--cat) 14%, var(--surface)); border-color: var(--cat); color: var(--cat);
}

/* ---- Extra measurements & PRs ---- */
.chart-metric { --series: var(--brass); }
.pr-form { display: grid; grid-template-columns: minmax(0, 1fr) 150px 110px auto; gap: 8px; margin-bottom: 16px; }
@media (max-width: 640px) { .pr-form { grid-template-columns: 1fr 1fr; } .pr-form input[name=exercise] { grid-column: 1 / -1; } .pr-form button { grid-column: 1 / -1; } }
.pr-history { margin-top: 28px; }
.pr-history summary { cursor: pointer; font: 400 0.95rem var(--font-display); color: var(--steel); }
.pr-week { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.metrics-table th.center, .metrics-table td.center { text-align: center; }
.cell-check { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--text); cursor: pointer; }
.metric-form { display: grid; grid-template-columns: minmax(0, 1fr) 140px 160px auto; gap: 8px; margin-top: 30px; }
@media (max-width: 720px) { .metric-form { grid-template-columns: 1fr 1fr; } .metric-form input[name=name], .metric-form button { grid-column: 1 / -1; } }

/* ---- "Gespeichert" confirmation ---- */
.saved-hud {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  pointer-events: none; visibility: hidden;
}
.saved-hud.show { visibility: visible; animation: hud-out 0.25s ease-in 1.35s forwards; }
.saved-box {
  --hud: #1f9d63;
  min-width: 190px; max-width: min(320px, calc(100vw - 48px));
  padding: 26px 28px 22px; border-radius: 22px;
  background: var(--hud); color: #fff; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 18px 50px rgba(0, 41, 65, 0.28);
}
.saved-hud.show .saved-box { animation: hud-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.25) both; }
.saved-box svg { width: 64px; height: 64px; margin-bottom: 6px; }
.saved-box circle { fill: rgba(255, 255, 255, 0.16); stroke: none; }
.saved-box path {
  fill: none; stroke: #fff; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
}
.saved-hud.show .saved-box path { animation: hud-check 0.38s ease-out 0.18s forwards; }
.saved-box strong { font: 400 1.6rem/1.1 var(--font-display); letter-spacing: -0.02em; }
.saved-box span { font-size: 0.88rem; opacity: 0.9; }
@keyframes hud-in { from { opacity: 0; transform: scale(0.82); } to { opacity: 1; transform: scale(1); } }
@keyframes hud-check { to { stroke-dashoffset: 0; } }
@keyframes hud-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .saved-hud.show .saved-box, .saved-hud.show { animation-duration: 0.01s; }
  .saved-box path { stroke-dashoffset: 0; }
}

/* ---- Account menu (profile picture) ---- */
.topbar-user { position: static; }
.avatar-btn {
  width: 42px; height: 42px; min-height: 0; padding: 0; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line); overflow: hidden; flex-shrink: 0;
}
.avatar-btn:hover { border-color: var(--text); }
.avatar-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.avatar {
  display: grid; place-items: center; width: 100%; height: 100%;
  border-radius: 50%; overflow: hidden; color: var(--muted); background: var(--bg);
}
.avatar svg { width: 62%; height: 62%; margin-top: 18%; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 46px; height: 46px; flex-shrink: 0; }
.avatar-xl { width: 128px; height: 128px; flex-shrink: 0; border: 1px solid var(--line); }
.user-menu {
  position: absolute; right: 16px; top: calc(100% + 6px); z-index: 40;
  min-width: 240px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px 0 14px 14px;
  box-shadow: 0 18px 44px rgba(0, 41, 65, 0.16);
}
@media (min-width: 720px) { .user-menu { right: 28px; } }
.user-menu-head { display: flex; align-items: center; gap: 12px; padding: 8px 8px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.user-menu-head strong { display: block; font: 400 1.05rem var(--font-display); letter-spacing: var(--track); }
.user-menu-head span:not(.avatar) { font-size: 0.8rem; color: var(--muted); }
.user-menu a, .user-menu button {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 10px 12px;
  justify-content: flex-start; background: transparent; border: 0; color: var(--text);
  font: 400 1rem var(--font-display); letter-spacing: var(--track); text-decoration: none;
}
.user-menu a:hover, .user-menu button:hover { background: var(--surface-2); color: var(--text); }
.user-menu #btn-logout { color: var(--bad); }

/* ---- Account page ---- */
.account-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); max-width: 860px; }
.account-photo { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.account-photo h2 { margin-bottom: 4px; }
.account-photo p { margin: 0 0 12px; }
.file-btn { margin: 0; cursor: pointer; color: var(--text); font-size: 0.98rem; }

/* ---- Coach dashboard ---- */
.dash-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); margin-bottom: 36px; }
.dash-tile { border-radius: var(--r-data); padding: 18px 18px 14px !important; }
.dash-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dash-num { font: 400 2.1rem/1 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.dash-tile.has-items .dash-num { color: var(--text); }
.dash-tile.is-off { background: var(--surface-2); }
.dash-tile.is-off .dash-num { color: var(--muted); }
.dash-note { margin: 4px 0 0; }
.dash-list { list-style: none; margin: 10px 0 0; padding: 0; }
.dash-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-top: 1px solid var(--border); }
.dash-list a { display: inline-flex; align-items: center; text-decoration: none; font: 400 0.98rem var(--font-display); letter-spacing: var(--track); min-width: 0; }
.dash-list a:hover { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); }
.dash-empty { margin: 10px 0 0; color: var(--good); }
.dash-tile.is-off .dash-empty { color: var(--muted); }
.list-head { margin: 0 0 14px; }
.mini-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; margin-right: 8px; vertical-align: middle; flex-shrink: 0; }

/* ---- Navigation: icons only in the phone tab bar ---- */
.nav-icon { display: inline-flex; align-items: center; order: 2; }
.nav-label { order: 1; }
.nav-icon svg { display: none; }

@media (max-width: 720px) {
  .topbar { flex-wrap: nowrap; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    margin: 0; border-radius: 0; gap: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    display: flex; justify-content: space-around;
  }
  .nav a {
    flex: 1; flex-direction: column; justify-content: center; gap: 3px;
    min-height: 54px; padding: 4px 2px; border-radius: 12px;
    font-size: 0.7rem; color: var(--muted); letter-spacing: 0;
  }
  .nav a[aria-current="page"] { background: transparent; color: var(--text); }
  .nav a[aria-current="page"]::before { display: none; }
  .nav-icon { order: 0; position: relative; display: grid; place-items: center; width: 52px; height: 30px; border-radius: 15px; transition: background 0.15s; }
  .nav-label { order: 1; }
  .nav-icon svg { display: block; width: 22px; height: 22px; }
  .nav a[aria-current="page"] .nav-icon { background: var(--ivory); }
  .nav-icon .count { position: absolute; top: -3px; right: 4px; min-width: 17px; height: 17px; font-size: 0.66rem; padding: 0 4px; }
  .container { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .chat { height: calc(100dvh - 250px); }
}
@media (max-width: 720px) { .brand span { display: inline; } }

/* ---- Pull to refresh (phones) ---- */
.ptr {
  position: fixed; top: calc(62px + env(safe-area-inset-top)); left: 50%; z-index: 25;
  transform: translate(-50%, -56px); opacity: 0; pointer-events: none;
}
.ptr.settling { transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.3s; }
#app.settling { transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1); }
.ptr-badge {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 41, 65, 0.14);
}
.ptr svg { width: 34px; height: 34px; overflow: visible; }
.ptr-track { fill: none; stroke: var(--border); stroke-width: 3; }
.ptr-ring {
  fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 20px 20px;
}
.ptr-arrow, .ptr-check { fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transform-origin: 20px 20px; transition: transform 0.2s, opacity 0.2s; }
.ptr-check { opacity: 0; stroke: var(--good); stroke-dasharray: 20; stroke-dashoffset: 20; }
.ptr.ready .ptr-arrow { transform: rotate(180deg); stroke: var(--accent); }
.ptr.loading .ptr-arrow { opacity: 0; }
.ptr.loading .ptr-ring { stroke-dashoffset: 70 !important; animation: ptr-spin 0.8s linear infinite; }
.ptr.done .ptr-arrow { opacity: 0; }
.ptr.done .ptr-ring { stroke: var(--good); stroke-dashoffset: 0 !important; }
.ptr.done .ptr-check { opacity: 1; animation: ptr-check 0.3s ease-out forwards; }
@keyframes ptr-spin { to { transform: rotate(270deg); } }
@keyframes ptr-check { to { stroke-dashoffset: 0; } }
@media (max-width: 720px) {
  html, body { overscroll-behavior-y: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ptr.loading .ptr-ring { animation-duration: 2s; }
}

/* ---- Week highlights in the check-in ---- */
.highlights {
  margin: 12px 0; padding: 12px 14px 10px;
  background: var(--surface); border-radius: 12px 0 12px 12px;
  border-left: 3px solid var(--good);
}
.highlights-title { font: 400 1rem var(--font-display); letter-spacing: var(--track); margin-bottom: 6px; }
.highlights ul { list-style: none; margin: 0; padding: 0; }
.highlights li { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: 0.95rem; }
.hl-icon { width: 22px; flex-shrink: 0; text-align: center; }
.hl-preview .highlights { background: var(--surface-2); margin-top: 14px; }

/* ---- Coach inbox: all chats ---- */
.inbox { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 721px) {
  .inbox { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
  .inbox-list { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
  .inbox-back { display: none; }
}
@media (max-width: 720px) {
  .inbox.has-chat .inbox-list, .inbox.has-chat ~ * { display: none; }
  .inbox:not(.has-chat) .inbox-chat { display: none; }
  .inbox.has-chat { margin-top: -12px; }
  body:has(.inbox.has-chat) .inbox-head { display: none; }
}
.inbox-list { padding: 16px !important; }
.inbox-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.inbox-search { margin-bottom: 8px; min-height: 40px; }
.inbox-items { list-style: none; margin: 0; padding: 0; }
.inbox-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 8px; border-radius: 12px 0 12px 12px;
  text-decoration: none; color: var(--text);
}
.inbox-item:hover { background: var(--surface-2); color: var(--text); }
.inbox-item.active { background: var(--ivory); }
.inbox-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.inbox-avatar.initials {
  display: grid; place-items: center; background: var(--bg); color: var(--steel);
  font: 400 0.95rem var(--font-display); letter-spacing: 0;
}
.inbox-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inbox-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.inbox-name { font: 400 1.02rem var(--font-display); letter-spacing: var(--track); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-top time { font-size: 0.74rem; color: var(--muted); flex-shrink: 0; }
.inbox-preview { font-size: 0.86rem; color: var(--steel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-item.unread .inbox-preview { color: var(--text); font-weight: 600; }
.inbox-item.unread .inbox-top time { color: var(--text); font-weight: 600; }
.inbox-item .count { flex-shrink: 0; }
.inbox-empty { text-align: center; color: var(--muted); padding: 60px 20px !important; }
.inbox-chat .chat { max-width: none; }
.chat-head { display: flex; align-items: center; gap: 12px; }
.chat-head > div { flex: 1; min-width: 0; }
.inbox-back { font-size: 1.4rem; text-decoration: none; padding: 4px 8px 4px 0; color: var(--text); }
.inbox-profile { flex-shrink: 0; }
@media (max-width: 720px) {
  .inbox-chat .chat { height: calc(100dvh - 200px); }
}

/* ---- Start screen: logo while the app loads ---- */
.splash {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: var(--bg);
  transition: opacity 0.35s ease, visibility 0.35s;
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash img {
  width: 132px; height: 132px; border-radius: 30px;
  box-shadow: 0 18px 50px rgba(0, 41, 65, 0.22);
  animation: splash-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) both, splash-breathe 2.4s ease-in-out 0.6s infinite;
}
.splash-bar { width: 56px; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.splash-bar i { display: block; width: 40%; height: 100%; background: var(--accent); border-radius: 3px; animation: splash-bar 1.1s ease-in-out infinite; }
@keyframes splash-in { from { opacity: 0; transform: scale(0.86); } to { opacity: 1; transform: scale(1); } }
@keyframes splash-breathe { 50% { transform: scale(1.035); } }
@keyframes splash-bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* Page placeholder while data loads */
.page-loading { min-height: 50vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.page-loading img { width: 56px; height: 56px; border-radius: 14px; opacity: 0.9; animation: splash-breathe 1.6s ease-in-out infinite; }
.page-loading span { width: 40px; height: 3px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.page-loading span::after { content: ''; position: absolute; inset: 0; width: 40%; background: var(--accent); border-radius: 3px; animation: splash-bar 1.1s ease-in-out infinite; }
#nutrition .page-loading, #checkin-body .page-loading { min-height: 30vh; }
@media (prefers-reduced-motion: reduce) {
  .splash img, .page-loading img, .splash-bar i, .page-loading span::after { animation: none; }
}

/* ---- Coach: goals panel behind "Ziele ändern" ---- */
.goals-panel { margin-bottom: 20px; }
.goals-panel-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .goals-panel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.goals-panel:not([hidden]) { animation: panel-in 0.22s ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (min-width: 980px) { .dash-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.dash-list li > span { flex-shrink: 0; white-space: nowrap; }

/* ==========================================================================
   Overview redesign: metric rows with sparklines, "Heute" card + sheet on phones,
   coach "Zu erledigen", collapsed push section.
   ========================================================================== */
/* helper text on Soft Blue uses steel (6.6:1) instead of muted */
.card.feature, .banner, .checkin-card, .plan-summary, .requests-card, .notif.automation, .inbox-item.active { --muted: var(--steel); }

/* Metric rows: value, context, sparkline – tap for the full chart */
.dash-head { align-items: flex-end; margin-bottom: 12px; }
.dash-summary { margin: 4px 0 0; color: var(--muted); }
.metric-list { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1180px) {
  .metric-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric.open { grid-column: 1 / -1; }
}
.card.metric { padding: 0; border-radius: var(--r-data); overflow: hidden; }
.metric-row {
  width: 100%; display: flex; align-items: center; justify-content: flex-start; gap: 14px;
  padding: 16px 18px; min-height: 68px; background: transparent; border: 0; border-radius: 0;
  color: var(--text); text-align: left; font: inherit; letter-spacing: normal; line-height: 1.3; text-transform: none;
}
button.metric-row { cursor: pointer; }
button.metric-row:hover { background: var(--surface-2); color: var(--text); }
.metric-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.metric-label { font: 500 0.86rem var(--font-body); color: var(--steel); display: flex; align-items: center; gap: 7px; }
.metric-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mcolor); flex-shrink: 0; }
.metric-value { font: 400 1.75rem/1.1 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric-value small { font: 400 0.88rem var(--font-body); color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.metric-sub { font-size: 0.86rem; color: var(--muted); }
.metric-visual { flex-shrink: 0; color: var(--mcolor); }
.metric-chev {
  width: 9px; height: 9px; flex-shrink: 0; margin: 0 6px 3px 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.2s;
}
.metric.open .metric-chev, .push-section[open] > summary .metric-chev { transform: rotate(45deg); }
.metric-detail { padding: 0 18px 16px; }
.metric-detail .legend { margin-bottom: 6px; flex-wrap: wrap; }
.m-weight { --mcolor: var(--weight); }
.m-kcal { --mcolor: var(--brass); }
.m-steps { --mcolor: var(--steps); }
.m-sleep { --mcolor: var(--sleep); }
.m-training { --mcolor: var(--good); }
.m-extra { --mcolor: var(--brass); }
.spark { width: 96px; height: 34px; display: block; overflow: visible; }
.spark path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: currentColor; }
.spark.bars rect { fill: currentColor; opacity: 0.3; }
.spark.bars rect.hit { opacity: 1; }
.spark.bars rect.empty { opacity: 0.12; }
.week-marks { display: flex; gap: 4px; }
.wm { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.wm i {
  width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font-style: normal;
  font: 700 0.68rem/1 var(--font-body); border: 1.5px solid var(--field); color: transparent;
}
.wm.yes i { background: var(--good); border-color: var(--good); color: var(--surface); }
.wm.no i { border-color: var(--bad); color: var(--bad); }
.wm small { font-size: 0.69rem; color: var(--muted); }
.entries-details > summary {
  display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none;
  font: 400 1.08rem var(--font-display); letter-spacing: var(--track);
}
.entries-details > summary::-webkit-details-marker { display: none; }
.entries-details > summary > span.muted { margin-left: auto; font-family: var(--font-body); }
.entries-details > summary::after { content: 'Anzeigen'; font: 500 0.86rem var(--font-body); color: var(--steel); }
.entries-details[open] > summary::after { content: 'Ausblenden'; }
.entries-details[open] > summary { margin-bottom: 12px; }

/* "Heute" card + entry form as bottom sheet (phones only) */
.today-card, .sheet-grabber, .sheet-close { display: none; }
.sheet-close {
  width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 50%; border: 0;
  background: var(--surface-2); color: var(--steel); font-size: 0.9rem;
}
.today-head { margin-bottom: 8px; align-items: center; }
.today-ring {
  --p: 0; width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--border) 0);
}
.today-ring b { width: 42px; height: 42px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font: 400 0.9rem var(--font-display); }
.today-list { list-style: none; margin: 0 0 14px; padding: 0; }
.today-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.tc-mark {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  border: 1.5px solid var(--field); color: var(--surface); font: 700 0.75rem/1 var(--font-body);
}
.today-list li.done .tc-mark { background: var(--good); border-color: var(--good); }
.tc-label { flex: 1; }
.tc-value { color: var(--muted); font-size: 0.92rem; }
.today-list li.done .tc-value { color: var(--text); font-family: var(--font-display); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 720px) {
  .today-card { display: block; margin-bottom: 16px; border-radius: var(--r-data); }
  .entry-sheet { display: none; }
  body.sheet-open { overflow: hidden; }
  body.sheet-open .entry-sheet {
    display: block; position: fixed !important; top: auto !important; left: 0; right: 0; bottom: 0; z-index: 60;
    max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; margin: 0;
    border-radius: 22px 22px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 40px rgba(0, 41, 65, 0.22);
    animation: sheet-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  }
  .sheet-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0, 26, 43, 0.45); animation: fade-in 0.2s; }
  .sheet-backdrop[hidden] { display: none; }
  .sheet-grabber { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
  .sheet-close { display: inline-flex; align-items: center; justify-content: center; }
  .metric-row { padding: 14px 14px 14px 16px; gap: 10px; }
  .metric-value { font-size: 1.55rem; }
  .metric-detail { padding: 0 10px 14px; }
  .spark { width: 76px; }
  .week-marks { gap: 2px; }
  .wm i { width: 16px; height: 16px; }
}
@media (min-width: 721px) { .sheet-backdrop { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  body.sheet-open .entry-sheet, .sheet-backdrop { animation: none; }
  .metric-chev { transition: none; }
}

/* Coach: "Zu erledigen" – open to-dos as tiles, the rest as small ✓ chips */
.todo-section { margin-bottom: 36px; }
.todo-head { margin-bottom: 12px; align-items: baseline; }
.all-done { border-radius: var(--r-data); }
.done-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; }
.done-chips li { font-size: 0.86rem; color: var(--good); background: var(--surface); padding: 5px 12px; border-radius: var(--r-pill); }
.done-chips li.off { color: var(--muted); }

/* Coach: push section collapsed into one row */
.push-section { margin-top: 44px; border-top: 1px solid var(--line); }
.push-summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 18px 0; min-height: 44px; }
.push-summary::-webkit-details-marker { display: none; }
.push-title { display: block; font: 400 1.3rem var(--font-display); letter-spacing: var(--track); margin-bottom: 2px; }
.push-body { padding-bottom: 8px; }

/* ==========================================================================
   Training plan: setup (days + split), editor, overview, workout logging, history
   ========================================================================== */
button.back { background: none; border: 0; padding: 0; min-height: 32px; }
.setup-step { margin-bottom: 28px; }
.setup-step h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--text); color: var(--surface); font: 400 0.85rem var(--font-display);
}
.days-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.days-picker button {
  flex-direction: column; gap: 4px; min-height: 72px; padding: 10px 4px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-data);
}
.days-picker button b { font: 400 1.6rem/1 var(--font-display); }
.days-picker button span { font: 400 0.8rem var(--font-body); color: var(--muted); }
.days-picker button[aria-checked="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.days-picker button[aria-checked="true"] span { color: var(--surface); opacity: 0.85; }
.split-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 12px; }
.split-card {
  flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 6px; text-align: left;
  padding: 16px 18px; min-height: 104px; line-height: 1.35; letter-spacing: normal;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-data);
}
.split-card:hover { border-color: var(--text); background: var(--surface); color: var(--text); }
.split-card.fits { border-color: var(--field); }
.split-card.custom { border-style: dashed; border-color: var(--field); }
.split-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.split-name { font: 400 1.12rem var(--font-display); letter-spacing: var(--track); }
.split-fit { font: 500 0.76rem var(--font-body); color: var(--muted); white-space: nowrap; }
.split-card.fits .split-fit { color: var(--surface); background: var(--good); padding: 3px 9px; border-radius: var(--r-pill); }
.split-desc { font: 400 0.88rem var(--font-body); color: var(--muted); }

/* editor */
.tp-days, .tp-overview, .wo-list { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .tp-days, .tp-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tp-day { border-radius: var(--r-data); }
.tp-day-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tp-day-num { font: 500 0.76rem var(--font-body); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; flex-shrink: 0; }
.tp-day-name { font: 400 1.15rem var(--font-display) !important; border-width: 0 0 1px !important; padding-left: 0 !important; background: transparent !important; min-height: 40px; }
.icon-btn {
  width: 36px; height: 36px; min-height: 0; padding: 0; flex-shrink: 0; border-radius: 50%;
  background: transparent; color: var(--muted); border: 0; font-size: 0.9rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--bad); }
.tp-ex-head, .tp-ex { display: grid; grid-template-columns: minmax(0, 1fr) 54px 76px 36px; gap: 6px; align-items: center; }
.tp-ex-head { font-size: 0.76rem; color: var(--muted); padding: 0 2px 4px; }
.tp-ex-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tp-ex input { min-height: 42px; padding: 8px 10px; }
.tp-ex input[data-f="sets"] { text-align: center; }
.tp-empty { padding: 8px 2px; }
.btn-add {
  width: 100%; margin-top: 10px; min-height: 44px; justify-content: center;
  background: var(--surface-2); color: var(--text); border: 1px dashed var(--field); border-radius: var(--r-data);
  font-size: 0.92rem;
}
.btn-add span { font-size: 1.2rem; line-height: 0; }
.btn-add:hover { background: var(--ivory); color: var(--text); border-style: solid; }
.tp-add-day { margin-top: 14px; }
.save-bar {
  position: sticky; bottom: 12px; z-index: 20; margin-top: 22px;
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px; background: var(--surface); border-radius: var(--r-data);
  box-shadow: 0 8px 30px rgba(0, 41, 65, 0.16);
}
.save-bar .btn-primary { flex: 1; max-width: 320px; }
@media (max-width: 720px) {
  .save-bar { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .save-bar .btn-primary { max-width: none; }
  .tp-ex-head, .tp-ex { grid-template-columns: minmax(0, 1fr) 44px 64px 32px; gap: 4px; }
  .tp-ex input { padding: 8px 7px; font-size: 16px; }
  .icon-btn { width: 32px; height: 32px; }
}

/* overview */
.tp-day-view { border-radius: var(--r-data); }
.tp-day-view-head { align-items: flex-start; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.tp-day-view-head h2 { margin: 2px 0; }
.tp-view-list { list-style: none; margin: 0; padding: 0; }
.tp-view-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto 84px; gap: 10px; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--border); }
.tp-view-name { min-width: 0; }
.tp-view-target { color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
.tp-view-last { text-align: right; font: 400 0.95rem var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-link { margin-top: 22px; min-height: 52px; }

/* workout */
.wo-date { margin: 0; min-width: 170px; }
.wo-ex { border-radius: var(--r-data); }
.wo-head { gap: 10px; align-items: baseline; }
.wo-last { margin: 4px 0 12px; }
.wo-sets { display: grid; gap: 6px; }
.wo-set { display: grid; grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.wo-set-head { font-size: 0.76rem; color: var(--muted); }
.wo-num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font: 400 0.85rem var(--font-display);
}
.wo-set input { font: 400 1.1rem var(--font-display); font-variant-numeric: tabular-nums; }
@media (min-width: 980px) { .wo-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* history */
.hist-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .hist-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hist-card { border-radius: var(--r-data); }
.hist-head { margin-bottom: 10px; }
.hist-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.hist-stats > div { display: flex; flex-direction: column; gap: 2px; }
.hist-stats .metric-value { font-size: 1.35rem; }
.chart-hist { --series: var(--text); }
.chart-hist .dot { fill: var(--text); opacity: 1; }
@media (max-width: 720px) {
  .tp-day { padding: 16px 14px; }
  .tp-ex-head, .tp-ex { grid-template-columns: minmax(0, 1fr) 40px 60px 28px; }
  .tp-ex input { padding: 8px 6px; }
  .tp-ex input[data-f="name"] { padding-left: 8px; }
  .tp-ex .icon-btn { width: 28px; }
  .tp-view-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .tp-view-last { grid-column: 1 / -1; text-align: left; font-size: 0.86rem; color: var(--muted); margin-top: -4px; }
  .tp-view-last:has(.muted) { display: none; }
}
.page-title-sm { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.1; letter-spacing: -0.02em; }
@media (max-width: 360px) { .nav a { font-size: 0.62rem; padding: 4px 0; } .nav-icon { width: 44px; } }

/* ==========================================================================
   Hall of Fame: medals (bronze / silver / gold), progress, animated icons
   ========================================================================== */
.user-menu #menu-fame { gap: 8px; }
.fame-new-banner {
  background: var(--ivory); color: var(--text); padding: 14px 18px; border-radius: var(--r-data); margin-bottom: 16px;
  --muted: var(--steel); animation: fame-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.fame-summary { border-radius: var(--r-data); margin-bottom: 18px; display: grid; gap: 12px; }
.fame-count { display: flex; align-items: baseline; gap: 10px; }
.fame-big { font: 400 2.8rem/1 var(--font-display); letter-spacing: -0.04em; }
.fame-tally { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.92rem; }
.fame-tally li { display: flex; align-items: center; gap: 7px; }
.tally-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.tally-dot.tier-bronze, .fame-bar span.tier-bronze { background: linear-gradient(135deg, #f0b27a, #8a4f1f); }
.tally-dot.tier-silver, .fame-bar span.tier-silver { background: linear-gradient(135deg, #ffffff, #8794a0); box-shadow: inset 0 0 0 1px #8794a0; }
.tally-dot.tier-gold, .fame-bar span.tier-gold { background: linear-gradient(135deg, #fff1a8, #b8860b); }
.fame-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.fame-bar span { display: block; height: 100%; border-radius: 4px; background: var(--text); transition: width 0.6s ease; }
.fame-next { border-top: 1px solid var(--border); padding-top: 12px; }
.fame-next h3 { font: 500 0.86rem var(--font-body); color: var(--muted); margin: 0 0 6px; }
.fame-next ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fame-next li { display: flex; align-items: center; gap: 9px; font-size: 0.92rem; }
.fn-text { flex: 1; min-width: 0; }
.fame-pct { font: 400 0.95rem var(--font-display); font-variant-numeric: tabular-nums; margin-left: auto; }

.fame-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 720px) { .fame-grid { grid-template-columns: minmax(0, 1fr); } }
.fame-card { border-radius: var(--r-data); display: flex; flex-direction: column; gap: 12px; }
.fame-card.complete { box-shadow: inset 0 0 0 2px #e8b923; }
.fame-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.fame-head h2 { margin: 0 0 2px; }
.fame-medals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.medal {
  flex-direction: column; gap: 6px; padding: 8px 2px 6px; min-height: 0; height: auto;
  background: transparent; border: 0; border-radius: 14px; color: var(--text); letter-spacing: normal;
}
.medal:hover { background: var(--surface-2); color: var(--text); }
.medal[aria-pressed="true"] { background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--field); }
.medal-svg { width: 68px; height: 68px; overflow: visible; }
.medal-cap { display: flex; flex-direction: column; align-items: center; gap: 1px; font: 400 0.8rem var(--font-body); }
.medal-cap b { font: 500 0.82rem var(--font-body); }
.medal-cap span { color: var(--muted); font-variant-numeric: tabular-nums; }
.medal.earned .medal-cap span { color: var(--good); font-weight: 700; }
.medal-track { fill: none; stroke: var(--border); stroke-width: 3; }
.medal-prog { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.medal-face { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.medal-rim { fill: none; stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.2; }
.medal.locked .medal-rim { stroke: var(--line); stroke-dasharray: 2 3; }
.medal-icon { fill: currentColor; stroke: currentColor; stroke-width: 0; }
.medal.locked .medal-icon { color: var(--muted); opacity: 0.55; }
.medal.earned .medal-icon { color: #fff; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.medal.earned.tier-silver .medal-icon { color: #3e4b56; filter: none; }
.medal.earned.tier-gold .medal-icon { color: #6b4a00; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.5)); }
.medal.earned .medal-svg { filter: drop-shadow(0 3px 6px rgba(0, 41, 65, 0.22)); }
.medal-shine { fill: rgba(255, 255, 255, 0.55); animation: medal-shine 4.5s ease-in-out infinite; }
.tier-silver .medal-shine { animation-delay: 0.5s; }
.tier-gold .medal-shine { animation-delay: 1s; }
.fame-detail { border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 7px; }
.fame-goal { margin: 0; font-size: 0.95rem; }
.fame-tier-name { font-weight: 600; margin-right: 4px; }
.fame-status { margin: 0; display: flex; justify-content: space-between; color: var(--muted); }
.fame-done { color: var(--good); font-weight: 600; }

/* icon animations – only on earned medals */
.medal.earned .medal-icon .a, .medal.earned .medal-icon .a1, .medal.earned .medal-icon .a2 { transform-box: fill-box; transform-origin: center; }
.medal.earned .ic-flame .a { transform-origin: 50% 100%; animation: fame-flicker 1.6s ease-in-out infinite; }
.medal.earned .ic-steps .a1 { animation: fame-step 1.6s ease-in-out infinite; }
.medal.earned .ic-steps .a2 { animation: fame-step 1.6s ease-in-out 0.8s infinite; }
.medal.earned .ic-target .a { animation: fame-pulse 2s ease-in-out infinite; }
.medal.earned .ic-moon .a { animation: fame-sway 4s ease-in-out infinite; }
.medal.earned .ic-moon .a2 { animation: fame-twinkle 2s ease-in-out infinite; }
.medal.earned .ic-scale .a { transform-box: view-box; transform-origin: 12px 10px; animation: fame-needle 2.4s ease-in-out infinite; }
.medal.earned .ic-apple .a { transform-origin: 50% 100%; animation: fame-bounce 2.2s ease-in-out infinite; }
.medal.earned .ic-dumbbell .a { animation: fame-lift 1.8s ease-in-out infinite; }
.medal.earned .ic-plate .a { animation: fame-spin 6s linear infinite; }
.medal.earned .ic-trophy .a { transform-origin: 50% 100%; animation: fame-sway 2.6s ease-in-out infinite; }
.medal.earned .ic-check .a { stroke-dasharray: 12; animation: fame-draw 2.8s ease-in-out infinite; }
.medal.new .medal-svg { animation: fame-pop 0.7s cubic-bezier(0.2, 1.5, 0.4, 1) both, fame-glow 1.8s ease-in-out 0.7s 3; }
.medal.new:nth-child(2) .medal-svg { animation-delay: 0.15s, 0.85s; }
.medal.new:nth-child(3) .medal-svg { animation-delay: 0.3s, 1s; }

@keyframes medal-shine { 0%, 62% { transform: rotate(25deg) translateX(0); } 100% { transform: rotate(25deg) translateX(110px); } }
@keyframes fame-flicker { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(0.94, 1.08); } 60% { transform: scale(1.05, 0.95) skewX(-3deg); } }
@keyframes fame-step { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-2px); opacity: 0.55; } }
@keyframes fame-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.3); opacity: 0.4; } }
@keyframes fame-sway { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes fame-twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
@keyframes fame-needle { 0%, 100% { transform: rotate(-35deg); } 50% { transform: rotate(45deg); } }
@keyframes fame-bounce { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-2.5px) scale(1.03, 0.97); } 55% { transform: translateY(0) scale(1.05, 0.95); } }
@keyframes fame-lift { 0%, 100% { transform: translateY(1.5px); } 45%, 60% { transform: translateY(-2.5px); } }
@keyframes fame-spin { to { transform: rotate(360deg); } }
@keyframes fame-draw { 0% { stroke-dashoffset: 12; } 40%, 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -12; } }
@keyframes fame-pop { 0% { transform: scale(0.3) rotate(-25deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes fame-glow { 50% { filter: drop-shadow(0 0 10px rgba(253, 110, 110, 0.75)); } }
@media (prefers-reduced-motion: reduce) {
  .medal-shine, .medal .medal-icon *, .medal.new .medal-svg, .fame-new-banner { animation: none !important; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .medal.earned .medal-svg { filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5)); }
}
:root[data-theme="dark"] .medal.earned .medal-svg { filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5)); }
.medal.earned .medal-face { stroke: none; }
.medal.earned.tier-bronze .medal-face { fill: url(#hof-bronze); }
.medal.earned.tier-silver .medal-face { fill: url(#hof-silver); }
.medal.earned.tier-gold .medal-face { fill: url(#hof-gold); }

/* "What's new" after an update */
dialog.whats-new { width: min(520px, calc(100vw - 32px)); padding: 26px 24px 20px; border-radius: 22px; }
dialog.whats-new[open] { animation: fame-pop 0.4s cubic-bezier(0.2, 1.2, 0.4, 1); }
.wn-head { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.wn-head h2 { margin: 0; }
.wn-badge { background: var(--accent); color: var(--accent-text); font: 600 0.78rem var(--font-body); padding: 4px 11px; border-radius: var(--r-pill); }
.wn-list { list-style: none; margin: 0 0 18px; padding: 0; }
.wn-list li { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.wn-list li:last-child { border-bottom: 0; }
.wn-icon { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; background: var(--surface-2); font-size: 1.2rem; }
.wn-list strong { font: 400 1.05rem var(--font-display); }
.wn-list p { margin: 3px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.wn-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.wn-actions button { flex: 1 1 160px; }
@media (prefers-reduced-motion: reduce) { dialog.whats-new[open] { animation: none; } }
@media (max-width: 720px) {
  dialog.whats-new { padding: 22px 18px 16px; }
  .wn-list li { padding: 10px 0; gap: 12px; }
  .wn-icon { width: 34px; height: 34px; font-size: 1.05rem; }
  .wn-list p { font-size: 0.88rem; }
}

/* ==========================================================================
   Logo: track ring with a coral dot. Tile and ring shift slightly in dark mode.
   ========================================================================== */
:root { --lm-tile: #002941; --lm-ring: #b6dfed; --lm-dot: #fd6e6e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --lm-tile: #0d3f5e; --lm-ring: #cfeaf4; --lm-dot: #ff7b7b; }
}
:root[data-theme="dark"] { --lm-tile: #0d3f5e; --lm-ring: #cfeaf4; --lm-dot: #ff7b7b; }
.logo-mark { display: block; flex-shrink: 0; }
.lm-tile { fill: var(--lm-tile); }
.lm-ring { stroke: var(--lm-ring); }
.lm-dot { fill: var(--lm-dot); }
.brand .logo-mark { width: 38px; height: 38px; }
.brand span { font-weight: 500; letter-spacing: -0.02em; }
.splash-logo {
  width: 120px; height: 120px; border-radius: 34px;
  box-shadow: 0 18px 50px rgba(0, 41, 65, 0.22);
  animation: splash-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) both, splash-breathe 2.4s ease-in-out 0.6s infinite;
}
.splash-logo .lm-ring { stroke-dashoffset: 86; animation: lm-draw 1s cubic-bezier(0.4, 0, 0.2, 1) 0.15s forwards; }
.splash-logo .lm-dot { transform-box: fill-box; transform-origin: center; transform: scale(0); animation: lm-dot 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) 0.95s forwards; }
@keyframes lm-draw { to { stroke-dashoffset: 0; } }
@keyframes lm-dot { to { transform: scale(1); } }
.page-loading .logo-mark { width: 44px; height: 44px; animation: splash-breathe 1.6s ease-in-out infinite; }
.login-logo { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; border-radius: 0; }
.login-logo .logo-mark { width: 72px; height: 72px; }
.login-wordmark { font: 400 2.2rem/1 var(--font-display); letter-spacing: -0.04em; }
.login-wordmark b { font-weight: 400; color: var(--accent-display); }
@media (prefers-reduced-motion: reduce) {
  .splash-logo .lm-ring { animation: none; stroke-dashoffset: 0; }
  .splash-logo .lm-dot { animation: none; transform: none; }
}

/* ==========================================================================
   Settings: language, appearance, Liquid Glass
   ========================================================================== */
.pref-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 1px solid var(--border); }
.pref-label { font: 500 0.95rem var(--font-body); }
.pref-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.pref-choices button {
  min-height: 40px; padding: 8px 14px; border-radius: var(--r-pill); font-size: 0.92rem;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.pref-choices button:hover { border-color: var(--field); background: var(--surface-2); color: var(--text); }
.pref-choices button[aria-checked="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.pref-glass { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.pref-glass p { margin: 2px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ==========================================================================
   Hall of Fame sub menu
   ========================================================================== */
.hof-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.hof-head p { margin: 4px 0 0; }
.hof-nav { display: inline-flex; background: var(--surface); border-radius: var(--r-pill); padding: 4px; gap: 2px; }
.hof-nav a {
  padding: 9px 16px; min-height: 40px; display: inline-flex; align-items: center; border-radius: var(--r-pill);
  color: var(--steel); text-decoration: none; font: 400 0.95rem var(--font-display);
}
.hof-nav a:hover { color: var(--text); background: var(--surface-2); }
.hof-nav a[aria-current="page"] { background: var(--text); color: var(--surface); }
@media (max-width: 720px) { .hof-nav { width: 100%; } .hof-nav a { flex: 1; justify-content: center; padding: 9px 6px; } }

/* ==========================================================================
   Fridge: camera approaches, door swings open, camera glides inside
   ========================================================================== */
.pixel { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.fridge-stage {
  position: relative; height: min(560px, calc(100dvh - 190px)); min-height: 440px; border-radius: var(--r-data); overflow: hidden;
  perspective: 900px; perspective-origin: 50% 50%;
  background:
    linear-gradient(to bottom, transparent 70%, rgba(0, 41, 65, 0.08) 70%),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(0, 41, 65, 0.05) 31px 32px),
    linear-gradient(#f6fbfd, #e3eff5);
}
.fridge-cam {
  position: absolute; left: 50%; top: 50%; width: 224px; height: 400px; margin: -200px 0 0 -112px;
  transform-style: preserve-3d; transform: translateZ(-1500px) rotateY(24deg);
}
.fridge { position: absolute; inset: 0; transform-style: preserve-3d; }
.fridge-freezer { position: absolute; left: 0; top: 0; width: 224px; height: 112px; }
.fridge-inside, .fridge-door { position: absolute; left: 0; top: 112px; width: 224px; height: 288px; }
.fridge-door { transform-style: preserve-3d; transform-origin: 0 50%; }
.door-front, .door-back { position: absolute; inset: 0; backface-visibility: hidden; }
.door-back { transform: rotateY(180deg); }
.fridge-side {
  position: absolute; top: 0; left: 224px; width: 64px; height: 400px; transform-origin: 0 50%; transform: rotateY(90deg);
  background: linear-gradient(90deg, #a8bccb, #8ea4b3); box-shadow: inset 0 0 0 8px #1d3446;
}
.fridge-shadow {
  position: absolute; left: -20px; right: -20px; bottom: -22px; height: 26px; border-radius: 50%;
  background: radial-gradient(rgba(0, 26, 43, 0.35), transparent 70%); transform: translateZ(-40px);
}
.fridge-view {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-evenly; padding: 28px 22px 22px;
  background: linear-gradient(#fffbe6, #f3fbff 120px, #eaf5fa);
  box-shadow: inset 0 0 0 12px #cfe2ec, inset 0 0 0 16px #1d3446;
  image-rendering: pixelated;
}
.fridge-light {
  position: absolute; left: 50%; top: 16px; width: 120px; height: 10px; margin-left: -60px;
  background: #fff6c9; box-shadow: 0 0 40px 22px rgba(255, 246, 201, 0.75);
}
.shelf {
  position: relative; display: flex; align-items: flex-end; gap: 10px; min-height: 76px; padding: 0 10px;
  border-bottom: 8px solid #a9c6d4; box-shadow: 0 6px 0 #8fb0c0;
}
.shelf-can { width: 40px; height: 72px; display: block; transform-origin: 50% 100%; }
.fridge-empty {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(320px, 80%);
  margin: 0; padding: 14px 16px; text-align: center; background: rgba(255, 255, 255, 0.92); color: #002941;
  border: 4px solid #1d3446; font: 400 0.95rem var(--font-display);
}
.fridge-empty a { color: #002941; }
.fridge-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

.fridge-stage.play .fridge-cam { animation: fr-approach 1s cubic-bezier(0.2, 0.7, 0.2, 1) forwards, fr-dive 0.95s cubic-bezier(0.6, 0, 0.8, 0.4) 2s forwards; }
.fridge-stage.play .fridge-door { animation: fr-door 0.85s cubic-bezier(0.3, 0.1, 0.2, 1) 1.05s forwards; }
.fridge-stage.play .fridge-view { animation: fr-view 0.5s ease-out 2.65s forwards; }
.fridge-stage.play .fridge-light { animation: fr-flicker 0.6s steps(2) 2.7s 2; }
.fridge-stage.play .shelf-can { animation: fr-can 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) calc(2.9s + var(--i) * 0.06s) both; }
@keyframes fr-approach { from { transform: translateZ(-1500px) rotateY(24deg); } to { transform: translateZ(0) rotateY(-8deg); } }
@keyframes fr-door { from { transform: rotateY(0); } to { transform: rotateY(-118deg); } }
@keyframes fr-dive {
  from { transform: translateZ(0) rotateY(-8deg); opacity: 1; }
  80% { opacity: 1; }
  to { transform: translateY(-56px) translateZ(860px) rotateY(0); opacity: 0; }
}
@keyframes fr-view { to { opacity: 1; pointer-events: auto; } }
@keyframes fr-flicker { 50% { opacity: 0.3; } }
@keyframes fr-can { from { transform: translateY(-14px) scale(0.6); opacity: 0; } }
.fridge-stage.skip .fridge-cam { display: none; }
.fridge-stage.skip .fridge-view { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  .fridge-stage .fridge-cam { display: none; }
  .fridge-stage .fridge-view { opacity: 1; pointer-events: auto; animation: none !important; }
  .fridge-stage .shelf-can { animation: none !important; }
}

/* ==========================================================================
   Shop
   ========================================================================== */
.shop-balance { border-radius: var(--r-data); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.shop-balance p { margin: 0; }
.shop-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
@media (max-width: 720px) { .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.shop-item { border-radius: var(--r-data); display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 18px 14px 14px; }
.shop-can {
  width: 100%; height: 120px; display: grid; place-items: center; border-radius: 14px;
  background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--can) 35%, transparent), transparent 70%);
}
.shop-can .can { width: 50px; height: 90px; }
.shop-item:hover .wobble { animation: can-wobble 0.6s ease-in-out; }
.shop-item h3 { margin: 0; font: 400 1rem var(--font-display); }
.shop-price { display: flex; align-items: center; gap: 4px; margin: 0; font: 400 0.95rem var(--font-display); }
.shop-price span { margin-left: 4px; }
.coin { width: 14px; height: 14px; border-radius: 50%; display: inline-block; background: linear-gradient(135deg, #fff1a8, #b8860b); box-shadow: inset 0 0 0 1.5px rgba(122, 88, 0, 0.5); }
@keyframes can-wobble { 25% { transform: rotate(-8deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); } }
@media (prefers-reduced-motion: reduce) { .shop-item:hover .wobble { animation: none; } }

/* ==========================================================================
   Liquid Glass (optional, Settings): glass only on the floating functional layer –
   top bar, tab bar, menus, dialogs, sheet, save bar, toasts. Content stays opaque.
   Brand colour moves into the content layer as a soft ambient background the glass picks up.
   ========================================================================== */
:root { --glass-fill: rgba(255, 255, 255, 0.7); --glass-strong: rgba(255, 255, 255, 0.78); --glass-edge: rgba(255, 255, 255, 0.85); --glass-shadow: 0 10px 34px rgba(0, 41, 65, 0.16); --glass-pill: rgba(255, 255, 255, 0.75); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --glass-fill: rgba(10, 52, 79, 0.66); --glass-strong: rgba(8, 44, 68, 0.78); --glass-edge: rgba(255, 255, 255, 0.16); --glass-shadow: 0 12px 36px rgba(0, 0, 0, 0.45); --glass-pill: rgba(255, 255, 255, 0.14); }
}
:root[data-theme="dark"] { --glass-fill: rgba(10, 52, 79, 0.66); --glass-strong: rgba(8, 44, 68, 0.78); --glass-edge: rgba(255, 255, 255, 0.16); --glass-shadow: 0 12px 36px rgba(0, 0, 0, 0.45); --glass-pill: rgba(255, 255, 255, 0.14); }
html.glass body {
  background:
    radial-gradient(60vmax 40vmax at 8% 0%, color-mix(in srgb, var(--ivory) 85%, transparent), transparent 60%),
    radial-gradient(40vmax 30vmax at 100% 25%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 65%),
    radial-gradient(60vmax 40vmax at 40% 100%, color-mix(in srgb, var(--ivory) 70%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
html.glass .nav, html.glass .user-menu, html.glass dialog, html.glass .save-bar,
html.glass .toast, html.glass .saved-box, html.glass body.sheet-open .entry-sheet, html.glass .topbar::before {
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  backdrop-filter: blur(26px) saturate(1.6);
}
/* top bar: glass with a scroll-edge fade instead of a solid colour. The blur sits on a pseudo layer:
   a backdrop-filter on the bar itself would make it the containing block of the fixed tab bar inside it. */
html.glass .topbar { background: transparent; border-bottom-color: transparent; }
html.glass .topbar::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--glass-fill);
  box-shadow: inset 0 -1px 0 var(--glass-edge), 0 8px 24px -18px rgba(0, 41, 65, 0.4);
}
/* desktop navigation capsule */
html.glass .nav { background: var(--glass-pill); box-shadow: inset 0 0 0 1px var(--glass-edge); }
html.glass .nav a[aria-current="page"] { background: var(--glass-strong); box-shadow: 0 2px 10px rgba(0, 41, 65, 0.12), inset 0 0 0 1px var(--glass-edge); }
/* menus, dialogs, sheet, save bar, toasts */
html.glass .user-menu, html.glass .save-bar, html.glass .saved-box, html.glass .toast {
  background: var(--glass-strong); box-shadow: var(--glass-shadow), inset 0 0 0 1px var(--glass-edge);
}
html.glass .user-menu { border-radius: 22px; }
html.glass .save-bar { border-radius: 26px; }
html.glass dialog { background: var(--glass-strong); border-radius: 28px; box-shadow: var(--glass-shadow), inset 0 0 0 1px var(--glass-edge); }
html.glass dialog::backdrop { background: rgba(0, 26, 43, 0.3); }
html.glass body.sheet-open .entry-sheet { background: var(--glass-strong) !important; border-radius: 30px 30px 0 0 !important; box-shadow: 0 -12px 40px rgba(0, 41, 65, 0.2), inset 0 1px 0 var(--glass-edge) !important; }
html.glass .btn-primary, html.glass .btn-secondary, html.glass .pref-choices button, html.glass .hof-nav a { border-radius: var(--r-pill); }
@media (max-width: 720px) {
  /* floating tab bar capsule, inset from the edges like iOS */
  html.glass .nav {
    left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 6px; border-radius: 32px; border-top: 0;
    background: var(--glass-fill);
    box-shadow: var(--glass-shadow), inset 0 0 0 1px var(--glass-edge), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  }
  html.glass .nav a { border-radius: 26px; }
  html.glass .nav a[aria-current="page"] { background: var(--glass-pill); box-shadow: inset 0 0 0 1px var(--glass-edge); }
  html.glass .nav a[aria-current="page"] .nav-icon { background: transparent; }
  html.glass .save-bar { bottom: calc(92px + env(safe-area-inset-bottom)); }
  html.glass .container { padding-bottom: calc(118px + env(safe-area-inset-bottom)); }
}
/* accessibility: opaque fallbacks */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  html.glass .topbar::before, html.glass .nav, html.glass .user-menu, html.glass dialog, html.glass .save-bar,
  html.glass .toast, html.glass .saved-box, html.glass body.sheet-open .entry-sheet {
    -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface) !important;
  }
  html.glass body { background: var(--bg); }
}

.tp-last-label { display: none; }
@media (max-width: 720px) { .tp-last-label { display: inline; } }

/* ==========================================================================
   Exercise how-to: "i" button and info dialog with photos
   ========================================================================== */
.info-btn {
  width: 24px; height: 24px; min-height: 0; padding: 0; margin-left: 4px; border-radius: 50%; vertical-align: 2px;
  display: inline-grid; place-items: center; background: transparent; color: var(--steel);
  border: 1.5px solid var(--field); font: italic 700 0.78rem/1 Georgia, 'Times New Roman', serif; letter-spacing: 0;
  position: relative;
}
.info-btn::after { content: ''; position: absolute; inset: -10px; } /* 44 px touch target */
.info-btn:hover { background: var(--text); color: var(--surface); border-color: var(--text); }
.wo-head h2 .info-btn, .hist-head h2 .info-btn { vertical-align: 4px; }
dialog:has(.ex-info) { width: min(560px, calc(100vw - 24px)); }
.ex-info-head { align-items: center; margin-bottom: 12px; }
.ex-info-head h2 { margin: 0; }
.ex-close { display: inline-flex; align-items: center; justify-content: center; }
.ex-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; }
.ex-photos figure { margin: 0; position: relative; border-radius: 12px; overflow: hidden; background: #fff; }
.ex-photos img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
.ex-photos figcaption {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: var(--r-pill);
  background: rgba(0, 41, 65, 0.78); color: #fff; font: 500 0.75rem var(--font-body);
}
.ex-muscles { margin: 0 0 10px; }
.ex-steps { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 6px; }
.ex-tip { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 0.93rem; }

/* ==========================================================================
   Cans: rarity gem (animated), cold condensation drops, bigger on desktop
   ========================================================================== */
.r-common { --rar: #8fa1ad; --rar-dark: #5d6f7b; }
.r-rare { --rar: #3a8ee8; --rar-dark: #1f5ea8; }
.r-epic { --rar: #a463e0; --rar-dark: #6c33a3; }
.r-legendary { --rar: #f2c230; --rar-dark: #b8860b; }
.cold-can { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; height: 100%; }
.gem-wrap { display: block; height: 16px; }
.gem { width: 16px; height: 14px; display: block; overflow: visible; animation: gem-bob 2.2s ease-in-out infinite; }
.g-body { fill: var(--rar); }
.g-top { fill: var(--rar-dark); opacity: 0.55; }
.g-hi { fill: #fff; opacity: 0.75; }
.r-epic .gem { animation: gem-bob 2.2s ease-in-out infinite, gem-glow 1.8s ease-in-out infinite; }
.r-legendary .gem { animation: gem-bob 2.2s ease-in-out infinite, gem-glow 1.4s ease-in-out infinite, gem-spin 3.2s ease-in-out infinite; }
.shelf-can:nth-child(2n) .gem { animation-delay: -0.7s, -0.4s, -1s; }
@keyframes gem-bob { 50% { transform: translateY(-3px); } }
@keyframes gem-glow { 50% { filter: drop-shadow(0 0 5px var(--rar)) brightness(1.15); } }
@keyframes gem-spin { 0%, 70% { transform: rotateY(0) translateY(0); } 85% { transform: rotateY(180deg) translateY(-3px); } 100% { transform: rotateY(360deg); } }

.can-body { position: relative; flex: 1; width: 100%; display: block; overflow: hidden; }
.can-body .can { width: 100%; height: 100%; }
/* fine condensation on the can */
.frost {
  position: absolute; inset: 8% 10% 6%; pointer-events: none; opacity: 0.55; mix-blend-mode: screen;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.9) 0 1px, transparent 1.6px),
    radial-gradient(circle at 70% 45%, rgba(255,255,255,0.85) 0 1px, transparent 1.6px),
    radial-gradient(circle at 40% 70%, rgba(255,255,255,0.8) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.8) 0 1px, transparent 1.6px),
    radial-gradient(circle at 30% 55%, rgba(255,255,255,0.7) 0 0.8px, transparent 1.4px);
  background-size: 14px 18px, 17px 15px, 19px 21px, 13px 16px, 11px 13px;
}
/* drops running down */
.drop {
  position: absolute; top: 14%; width: 3px; height: 5px; border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: radial-gradient(circle at 35% 35%, #fff 0 30%, rgba(214, 238, 248, 0.85) 60%, rgba(160, 200, 220, 0.6));
  box-shadow: 0 0 1px rgba(0, 41, 65, 0.35); opacity: 0; pointer-events: none;
  animation: drip 4.6s cubic-bezier(0.55, 0, 0.9, 0.5) infinite;
}
.drop.d1 { left: 28%; animation-delay: 0.4s; }
.drop.d2 { left: 58%; animation-delay: 2.1s; animation-duration: 5.4s; }
.drop.d3 { left: 42%; top: 40%; animation-delay: 3.4s; animation-duration: 3.8s; }
.shelf-can:nth-child(3n+1) .drop.d1 { animation-delay: 1.3s; }
.shelf-can:nth-child(2n) .drop.d2 { animation-delay: 0.2s; }
@keyframes drip {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  45% { transform: translateY(6px); }
  85% { opacity: 0.9; }
  100% { transform: translateY(46px) scaleY(1.25); opacity: 0; }
}

/* fridge sizes: phone 5 per shelf, desktop 8 and bigger cans */
.shelf-can { width: 44px; height: 98px; }
.shelf { min-height: 108px; gap: 12px; }
@media (min-width: 721px) {
  .fridge-stage { height: 620px; }
  .shelf-can { width: 66px; height: 140px; }
  .shelf { min-height: 150px; gap: 22px; padding: 0 22px; }
  .gem-wrap { height: 20px; }
  .gem { width: 20px; height: 17px; }
  .drop { width: 4px; height: 6px; }
}

/* shop card */
.shop-can .cold-can { width: 56px; height: 120px; }
.shop-item:hover [data-wobble] .can-body { animation: can-wobble 0.6s ease-in-out; }
.rarity-tag {
  font: 600 0.72rem var(--font-body); letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--rar-dark); background: color-mix(in srgb, var(--rar) 18%, transparent); padding: 2px 9px; border-radius: var(--r-pill);
}
:root[data-theme="dark"] .rarity-tag { color: var(--rar); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rarity-tag { color: var(--rar); } }

/* ==========================================================================
   Empty fridge: cobwebs and two flies
   ========================================================================== */
.fridge-empty-fx { position: absolute; inset: 16px; pointer-events: none; overflow: hidden; }
.cobweb { position: absolute; top: 0; width: 120px; height: 120px; fill: none; stroke: rgba(29, 52, 70, 0.32); stroke-width: 0.9; }
.cobweb.tl { left: 0; }
.cobweb.tr { right: 0; transform: scaleX(-1); }
.cobweb path:first-child { stroke: rgba(29, 52, 70, 0.4); }
.fly { position: absolute; left: 0; top: 0; width: 20px; height: 14px; }
.fly svg { display: block; width: 100%; height: 100%; overflow: visible; }
.wing { fill: rgba(220, 235, 245, 0.85); stroke: rgba(29, 52, 70, 0.4); stroke-width: 0.5; transform-box: fill-box; transform-origin: 50% 100%; animation: flap 0.07s linear infinite alternate; }
.wing.w2 { animation-delay: 0.035s; }
@keyframes flap { to { transform: scaleY(0.25); } }
.fly.f1 { animation: fly-a 9s ease-in-out infinite; }
.fly.f2 { animation: fly-b 11s ease-in-out infinite; }
@keyframes fly-a {
  0% { left: 10%; top: 20%; transform: rotate(10deg); }
  20% { left: 60%; top: 10%; transform: rotate(-20deg); }
  35% { left: 75%; top: 45%; transform: rotate(40deg); }
  50% { left: 40%; top: 60%; transform: rotate(160deg); }
  65% { left: 15%; top: 40%; transform: rotate(200deg) scaleX(-1); }
  80% { left: 30%; top: 15%; transform: rotate(-30deg); }
  100% { left: 10%; top: 20%; transform: rotate(10deg); }
}
@keyframes fly-b {
  0% { left: 80%; top: 70%; transform: rotate(-150deg); }
  25% { left: 50%; top: 35%; transform: rotate(-60deg); }
  45% { left: 20%; top: 65%; transform: rotate(120deg); }
  60% { left: 35%; top: 80%; transform: rotate(30deg); }
  80% { left: 70%; top: 50%; transform: rotate(-20deg); }
  100% { left: 80%; top: 70%; transform: rotate(-150deg); }
}
@media (prefers-reduced-motion: reduce) {
  .gem, .drop, .wing, .fly { animation: none !important; }
  .drop { opacity: 0.8; }
  .fly.f1 { left: 30%; top: 30%; }
  .fly.f2 { left: 65%; top: 60%; }
}
/* desktop: fridge-shaped interior in the middle of the kitchen, big cans, visible flies */
.fly { width: 26px; height: 18px; }
@media (min-width: 721px) {
  .fridge-stage { height: 700px; }
  .fridge-view { left: 50%; right: auto; width: min(100%, 760px); transform: translateX(-50%); }
  .shelf-can { width: 84px; height: 182px; }
  .shelf { min-height: 196px; gap: 26px; padding: 0 26px; }
  .gem-wrap { height: 24px; }
  .gem { width: 24px; height: 21px; }
  .drop { width: 5px; height: 7px; }
  .fly { width: 34px; height: 24px; }
  .cobweb { width: 160px; height: 160px; }
}

/* ==========================================================================
   Nutrition plan request: multiple-choice form, summary for client and coach
   ========================================================================== */
dialog:has(.pr-q) { width: min(600px, calc(100vw - 24px)); }
.pr-q { border: 0; margin: 0 0 16px; padding: 14px 0 0; border-top: 1px solid var(--border); min-width: 0; }
.pr-q legend { font: 500 1rem var(--font-body); padding: 0; margin-bottom: 8px; float: left; width: 100%; }
.pr-q legend + * { clear: both; }
.pr-q .hint { margin: 0 0 8px; clear: both; }
.pr-choices { display: flex; flex-wrap: wrap; gap: 6px; clear: both; }
.pr-choice { position: relative; margin: 0; cursor: pointer; }
.pr-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pr-choice span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 0.93rem; transition: background 0.12s, border-color 0.12s;
}
.pr-choice:hover span { border-color: var(--field); }
.pr-choice input:checked + span { background: var(--text); border-color: var(--text); color: var(--surface); }
.pr-choice input[type="checkbox"]:checked + span::before { content: '✓'; font-weight: 700; }
.pr-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pr-q input[name="avoidOther"] { margin-top: 8px; }
.plan-request { border-radius: var(--r-data); max-width: 640px; }
.plan-request:not(.sent) { text-align: center; padding: 36px 24px !important; }
.plan-request:not(.sent) .muted { max-width: 420px; margin: 6px auto 18px; }
.pr-icon { font-size: 2.2rem; margin: 0 0 6px; }
.pr-summary { margin: 12px 0 16px; display: grid; gap: 8px; }
.pr-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.pr-row dt { font-size: 0.84rem; color: var(--muted); }
.pr-row dd { margin: 0; font-weight: 500; }
@media (min-width: 721px) { .pr-row { grid-template-columns: 240px minmax(0, 1fr); gap: 12px; } }

/* ==========================================================================
   AI cards (coach): check-in summary and nutrition plan draft
   ========================================================================== */
.ai-card { border-radius: var(--r-data); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--brass) 45%, transparent); }
.ai-head { align-items: center; gap: 10px; margin-bottom: 10px; }
.ai-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.ai-spark { color: var(--accent); font-size: 1.1em; }
.ai-overview { margin: 0 0 12px; font-size: 1.02rem; }
.ai-cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.ai-block h4 { margin: 0 0 4px; font: 600 0.82rem var(--font-body); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.ai-block.good h4 { color: var(--good); }
.ai-block.warn h4 { color: var(--warn); }
.ai-block ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.ai-meta { margin: 12px 0 0; }
.ai-loading { display: flex; gap: 6px; padding: 10px 0; }
.ai-loading span { width: 9px; height: 9px; border-radius: 50%; background: var(--brass); animation: ai-dot 1s ease-in-out infinite; }
.ai-loading span:nth-child(2) { animation-delay: 0.15s; }
.ai-loading span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot { 50% { transform: translateY(-5px); opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) { .ai-loading span { animation: none; } }
.ai-meal { border-top: 1px solid var(--border); padding: 10px 0; }
.ai-meal-head { gap: 10px; }
.ai-meal-name { font: 500 1rem var(--font-display) !important; border-width: 0 0 1px !important; padding-left: 0 !important; background: transparent !important; min-height: 36px; max-width: 70%; }
.ai-meal ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.ai-meal li { display: grid; grid-template-columns: minmax(0, 1fr) 120px 76px 32px; gap: 8px; align-items: center; }
.ai-amount input { min-height: 38px; padding: 6px 44px 6px 10px; }
.ai-kcal { text-align: right; color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.ai-total { margin: 10px 0; text-align: right; }
.ai-actions { gap: 8px; }
@media (max-width: 720px) {
  .ai-meal li { grid-template-columns: minmax(0, 1fr) 96px 30px; }
  .ai-meal li .ai-kcal { display: none; }
}
.fame-tokens { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font: 500 0.95rem var(--font-body); }
.ai-hint { margin: 0 0 12px; }
.ai-hint p { margin: 4px 0 0; }
#ai-guidelines textarea { font-size: 0.95rem; line-height: 1.5; }

/* Mythic rarity: shifting colours, strongest glow */
.r-mythic { --rar: #ff3d6e; --rar-dark: #b0124a; }
.r-mythic .gem { animation: gem-bob 2.2s ease-in-out infinite, gem-glow 1.2s ease-in-out infinite, gem-prism 3s linear infinite; }
@keyframes gem-prism { to { filter: hue-rotate(360deg) drop-shadow(0 0 4px var(--rar)); } }
.rarity-tag.r-mythic {
  color: #fff; background: linear-gradient(90deg, #ff3d6e, #a463e0, #3a8ee8, #ff3d6e); background-size: 300% 100%;
  animation: mythic-tag 4s linear infinite;
}
@keyframes mythic-tag { to { background-position: 300% 0; } }
.shop-item:has(.r-mythic) { box-shadow: inset 0 0 0 2px color-mix(in srgb, #ff3d6e 55%, transparent); }
/* vial: a glint sweeps over the glass instead of condensation */
.glint {
  position: absolute; top: 30%; left: -60%; width: 40%; height: 60%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  animation: glint 3.2s ease-in-out infinite;
}
@keyframes glint { 0%, 55% { left: -60%; } 100% { left: 120%; } }
@media (prefers-reduced-motion: reduce) {
  .r-mythic .gem, .rarity-tag.r-mythic, .glint { animation: none !important; }
}

/* ==========================================================================
   Purchase celebration (full screen, grows with rarity)
   ========================================================================== */
body.fx-open { overflow: hidden; }
.buy-fx {
  --fx: #c3ced5; --pre: 0s;
  position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; cursor: pointer;
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}
.r-rare.buy-fx { --fx: #3a8ee8; }
.r-epic.buy-fx { --fx: #a463e0; }
.r-legendary.buy-fx { --fx: #f2c230; }
.r-mythic.buy-fx { --fx: #ff3d6e; }
.buy-fx.fx-out { animation: fx-fade-out 0.35s ease forwards; }
.fx-backdrop { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--fx) 30%, #0b2233), #001a2b 70%); animation: fx-fade 0.3s ease both; }
.r-legendary .fx-backdrop, .r-mythic .fx-backdrop { background: #000a12; animation: fx-fade 0.3s ease both, fx-bg-reveal 0.6s ease var(--pre) both; }
.r-mythic .fx-backdrop { animation: fx-fade 0.3s ease both, fx-bg-mythic 0.8s ease var(--pre) both; }
.fx-stage { position: relative; width: min(90vw, 560px); height: min(90vw, 560px); display: grid; place-items: center; }
.fx-stage > * { position: absolute; }
/* light rays */
.fx-rays {
  inset: -60%; opacity: 0; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--fx) 55%, transparent) 0deg 7deg, transparent 7deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 62%); mask: radial-gradient(circle, #000 0%, transparent 62%);
}
.r-rare .fx-rays { animation: fx-fade-to 0.6s ease 0.2s forwards, fx-spin 14s linear infinite; }
.r-epic .fx-rays { animation: fx-fade-to 0.5s ease 0.15s forwards, fx-spin 8s linear infinite; }
.r-legendary .fx-rays { animation: fx-fade-to 0.4s ease var(--pre) forwards, fx-spin 7s linear infinite; }
.r-mythic .fx-rays {
  background: repeating-conic-gradient(from 0deg, #ff3d6e88 0deg 6deg, transparent 6deg 15deg, #3a8ee888 15deg 21deg, transparent 21deg 30deg, #f2c23088 30deg 36deg, transparent 36deg 45deg);
  animation: fx-fade-to 0.4s ease var(--pre) forwards, fx-spin 5s linear infinite, fx-hue 3s linear infinite;
}
/* glow behind the item */
.fx-glow { width: 70%; height: 70%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--fx) 70%, transparent), transparent 65%); opacity: 0; animation: fx-glow 2.4s ease-in-out var(--pre) infinite; }
.r-common .fx-glow { background: radial-gradient(circle, rgba(255,255,255,0.35), transparent 65%); }
/* shock waves */
.fx-rings i { position: absolute; left: 50%; top: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 4px solid var(--fx); opacity: 0; }
.r-epic .fx-rings i:first-child { animation: fx-ring 1s ease-out 0.35s both; }
.r-legendary .fx-rings i:first-child, .r-mythic .fx-rings i:first-child { animation: fx-ring 1.1s ease-out var(--pre) both; }
.r-mythic .fx-rings i:last-child { border-color: #3a8ee8; animation: fx-ring 1.3s ease-out calc(var(--pre) + 0.25s) both; }
/* particles bursting out */
.fx-particles { left: 50%; top: 50%; }
.fx-particles i {
  position: absolute; width: var(--s); height: var(--s); margin: calc(var(--s) / -2); background: var(--c); border-radius: 2px;
  box-shadow: 0 0 8px var(--c); opacity: 0; animation: fx-burst 1.3s cubic-bezier(0.15, 0.7, 0.3, 1) calc(var(--pre) + 0.25s + var(--t)) both;
}
.r-legendary .fx-particles i:nth-child(3n), .r-mythic .fx-particles i:nth-child(3n) { border-radius: 50%; }
.r-mythic .fx-particles { animation: fx-hue 2s linear infinite; }
/* the item */
.fx-item { width: 120px; height: 236px; animation: fx-drop 0.8s cubic-bezier(0.2, 1.4, 0.4, 1) 0.1s both, fx-float 3s ease-in-out 1s infinite; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45)); }
.fx-item .cold-can { width: 100%; height: 100%; }
.fx-item .gem-wrap { height: 30px; }
.fx-item .gem { width: 30px; height: 26px; }
.r-epic .fx-item { animation: fx-drop-spin 1.1s cubic-bezier(0.2, 1.2, 0.4, 1) 0.1s both, fx-float 3s ease-in-out 1.3s infinite; }
.r-legendary .fx-item, .r-mythic .fx-item {
  animation: fx-charge var(--pre) ease-in both, fx-reveal 0.8s cubic-bezier(0.2, 1.4, 0.4, 1) var(--pre) forwards, fx-float 3s ease-in-out calc(var(--pre) + 0.8s) infinite;
}
.r-mythic .fx-item { animation: fx-heartbeat var(--pre) ease-in-out both, fx-reveal 0.9s cubic-bezier(0.2, 1.5, 0.4, 1) var(--pre) forwards, fx-float 3s ease-in-out calc(var(--pre) + 0.9s) infinite; }
/* shake on impact */
.r-epic .fx-stage { animation: fx-shake 0.4s ease 0.45s both; --shake: 6px; }
.r-legendary .fx-stage { animation: fx-shake 0.5s ease var(--pre) both; --shake: 10px; }
.r-mythic .fx-stage { animation: fx-shake 0.7s ease var(--pre) both; --shake: 16px; }
/* flash */
.fx-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.r-epic .fx-flash { animation: fx-flash 0.5s ease 0.4s both; --flash: 0.35; }
.r-legendary .fx-flash { animation: fx-flash 0.7s ease var(--pre) both; --flash: 0.85; }
.r-mythic .fx-flash { animation: fx-flash 0.9s ease var(--pre) both; --flash: 1; }
/* coin rain */
.fx-coins { position: absolute; inset: 0; pointer-events: none; }
.fx-coin {
  position: absolute; top: -40px; width: 22px; height: 22px; border-radius: 50%; transform: scale(var(--z));
  background: radial-gradient(circle at 35% 30%, #fff8cf, #f2c230 45%, #b8860b); box-shadow: inset 0 0 0 2px rgba(122, 88, 0, 0.5);
  animation: fx-coin 1.8s cubic-bezier(0.4, 0, 0.8, 0.6) calc(var(--pre) + var(--t)) both;
}
/* mythic: stars appear in the dark before the reveal */
.fx-stars { position: absolute; inset: 0; }
.fx-stars i { position: absolute; width: 3px; height: 3px; background: #fff; border-radius: 50%; opacity: 0; animation: fx-twinkle 1.6s ease-in-out var(--t) infinite; }
/* text */
.fx-text { position: absolute; left: 0; right: 0; bottom: max(12vh, 90px); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 0 20px; color: #fff; animation: fx-text 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) calc(var(--pre) + 0.45s) both; }
.fx-rarity { font: 700 0.85rem var(--font-body); letter-spacing: 0.28em; text-transform: uppercase; color: var(--fx); }
.r-common .fx-rarity { color: #c3ced5; }
.fx-name { font: 400 clamp(1.6rem, 6vw, 2.6rem)/1.1 var(--font-display); letter-spacing: -0.02em; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5); }
.r-legendary .fx-rarity, .r-mythic .fx-rarity { font-size: clamp(1.4rem, 5vw, 2.2rem); letter-spacing: 0.22em; }
.r-legendary .fx-rarity { background: linear-gradient(90deg, #fff1a8, #f2c230, #fff1a8); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 200% 100%; animation: fx-sheen 2s linear infinite; }
.r-mythic .fx-rarity { background: linear-gradient(90deg, #ff3d6e, #a463e0, #3a8ee8, #7ed957, #f2c230, #ff3d6e); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 300% 100%; animation: fx-sheen 2.5s linear infinite; }
.fx-sub { font: 400 0.95rem var(--font-body); color: rgba(255, 255, 255, 0.75); }
.fx-skip { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; margin: 0; text-align: center; font-size: 0.8rem; color: rgba(255, 255, 255, 0.55); animation: fx-fade 0.4s ease 1.2s both; }

@keyframes fx-fade { from { opacity: 0; } }
@keyframes fx-fade-to { to { opacity: 1; } }
@keyframes fx-fade-out { to { opacity: 0; } }
@keyframes fx-bg-reveal { to { background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--fx) 40%, #0b2233), #001a2b 72%); } }
@keyframes fx-bg-mythic { to { background: radial-gradient(circle at 50% 45%, #5a1440, #1a0b33 45%, #000a12 80%); } }
@keyframes fx-spin { to { transform: rotate(360deg); } }
@keyframes fx-hue { to { filter: hue-rotate(360deg); } }
@keyframes fx-glow { 0% { opacity: 0; transform: scale(0.8); } 30% { opacity: 1; } 50% { transform: scale(1.08); } 100% { opacity: 0.8; transform: scale(0.95); } }
@keyframes fx-ring { 0% { opacity: 0.95; transform: scale(0.2); border-width: 8px; } 100% { opacity: 0; transform: scale(6); border-width: 1px; } }
@keyframes fx-burst {
  0% { opacity: 1; transform: rotate(var(--a)) translateX(0) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--d)) scale(0.3) rotate(180deg); }
}
@keyframes fx-drop { 0% { opacity: 0; transform: translateY(-60vh) rotate(-25deg) scale(0.6); } 100% { opacity: 1; transform: none; } }
@keyframes fx-drop-spin { 0% { opacity: 0; transform: translateY(-60vh) rotateY(0) scale(0.6); } 100% { opacity: 1; transform: rotateY(720deg); } }
@keyframes fx-float { 50% { transform: translateY(-10px) rotate(1.5deg); } }
@keyframes fx-charge {
  0% { opacity: 0; transform: scale(0.5); filter: brightness(0); }
  25% { opacity: 1; }
  45% { transform: scale(0.62) rotate(-3deg); filter: brightness(0) drop-shadow(0 0 10px var(--fx)); }
  65% { transform: scale(0.58) rotate(3deg); }
  85% { transform: scale(0.75) rotate(-2deg); filter: brightness(0) drop-shadow(0 0 26px var(--fx)); }
  100% { transform: scale(0.8); filter: brightness(0) drop-shadow(0 0 40px var(--fx)); }
}
@keyframes fx-heartbeat {
  0% { opacity: 0; transform: scale(0.5); filter: brightness(0); }
  15% { opacity: 1; transform: scale(0.55); filter: brightness(0) drop-shadow(0 0 6px #ff3d6e); }
  22% { transform: scale(0.66); } 30% { transform: scale(0.56); } 36% { transform: scale(0.64); }
  55% { transform: scale(0.58); filter: brightness(0) drop-shadow(0 0 16px #a463e0); }
  62% { transform: scale(0.72); } 70% { transform: scale(0.6); } 76% { transform: scale(0.7); }
  100% { transform: scale(0.82); filter: brightness(0) drop-shadow(0 0 44px #ff3d6e); }
}
@keyframes fx-reveal { 0% { transform: scale(0.8); filter: brightness(4); } 60% { transform: scale(1.18); } 100% { transform: none; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45)); } }
@keyframes fx-shake {
  0%, 100% { transform: none; }
  15% { transform: translate(calc(var(--shake) * -1), calc(var(--shake) * 0.5)); }
  30% { transform: translate(var(--shake), calc(var(--shake) * -0.6)); }
  45% { transform: translate(calc(var(--shake) * -0.7), calc(var(--shake) * 0.4)); }
  60% { transform: translate(calc(var(--shake) * 0.5), calc(var(--shake) * -0.3)); }
  80% { transform: translate(calc(var(--shake) * -0.2), 0); }
}
@keyframes fx-flash { 0% { opacity: 0; } 15% { opacity: var(--flash); } 100% { opacity: 0; } }
@keyframes fx-coin { 0% { opacity: 1; transform: translateY(0) scale(var(--z)) rotate(0); } 100% { opacity: 0.9; transform: translateY(115vh) scale(var(--z)) rotate(var(--r)); } }
@keyframes fx-twinkle { 0%, 100% { opacity: 0; } 50% { opacity: 0.9; } }
@keyframes fx-text { 0% { opacity: 0; transform: translateY(20px) scale(0.85); } 100% { opacity: 1; transform: none; } }
@keyframes fx-sheen { to { background-position: 200% 0; } }

/* reduced motion: a calm card, no movement */
.buy-fx.calm *, .buy-fx.calm { animation: none !important; }
.buy-fx.calm .fx-rays, .buy-fx.calm .fx-rings, .buy-fx.calm .fx-flash { display: none; }
.buy-fx.calm .fx-glow { opacity: 1; }
.buy-fx.calm .fx-item { filter: none; }

/* ==========================================================================
   Motion system: brief, purposeful, cancellable. Tokens first, then each moment.
   Reduce Motion: movement is replaced by short fades (HIG accessibility › Motion).
   ========================================================================== */
:root {
  --ease-out: cubic-bezier(0.22, 0.8, 0.24, 1);
  --ease-spring: cubic-bezier(0.2, 1.25, 0.35, 1);
  --dur-fast: 140ms;
  --dur-med: 240ms;
  --dur-slow: 380ms;
}

/* 1 · screen change: content rises in, cards one after another (max. ~300 ms delay) */
#app.view-enter > * { animation: view-in var(--dur-slow) var(--ease-out) both; }
#app.view-enter > :nth-child(2) { animation-delay: 40ms; }
#app.view-enter > :nth-child(3) { animation-delay: 80ms; }
#app.view-enter > :nth-child(4) { animation-delay: 120ms; }
#app.view-enter > :nth-child(n + 5) { animation-delay: 160ms; }
#app.view-enter :is(.metric-list, .shop-grid, .fame-grid, .tp-overview, .dash-grid, .hist-grid, .split-grid, .client-grid) > * { animation: view-in var(--dur-slow) var(--ease-out) both; }
#app.view-enter :is(.metric-list, .shop-grid, .fame-grid, .tp-overview, .dash-grid, .hist-grid, .split-grid, .client-grid) > :nth-child(2) { animation-delay: 60ms; }
#app.view-enter :is(.metric-list, .shop-grid, .fame-grid, .tp-overview, .dash-grid, .hist-grid, .split-grid, .client-grid) > :nth-child(3) { animation-delay: 100ms; }
#app.view-enter :is(.metric-list, .shop-grid, .fame-grid, .tp-overview, .dash-grid, .hist-grid, .split-grid, .client-grid) > :nth-child(4) { animation-delay: 140ms; }
#app.view-enter :is(.metric-list, .shop-grid, .fame-grid, .tp-overview, .dash-grid, .hist-grid, .split-grid, .client-grid) > :nth-child(5) { animation-delay: 180ms; }
#app.view-enter :is(.metric-list, .shop-grid, .fame-grid, .tp-overview, .dash-grid, .hist-grid, .split-grid, .client-grid) > :nth-child(n + 6) { animation-delay: 220ms; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }

/* 2 · dialogs and sheets: grow in from slightly smaller, backdrop fades */
dialog[open] { animation: dialog-in var(--dur-med) var(--ease-spring); }
dialog[open]::backdrop { animation: fade-in var(--dur-med) ease; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* 3 · toast and "saved" feedback slide up */
.toast:not([hidden]) { animation: toast-in var(--dur-med) var(--ease-spring); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* 4 · menus */
.user-menu:not([hidden]) { animation: menu-in var(--dur-fast) var(--ease-out); transform-origin: top right; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.97); } }

/* 5 · progress fills up instead of appearing finished */
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }
.today-ring { animation: ring-fill 700ms var(--ease-out) 120ms both; }
@keyframes ring-fill { from { --p: 0; } }
.fame-bar span, .bar-fill { animation: bar-grow 700ms var(--ease-out) 150ms both; }
@keyframes bar-grow { from { width: 0; } }
.medal-prog { animation: medal-prog 900ms var(--ease-out) 200ms both; }
@keyframes medal-prog { from { stroke-dasharray: 0 999; } }

/* 6 · expanding a metric row reveals the chart gently */
.metric.open .metric-detail { animation: detail-in var(--dur-med) var(--ease-out); }
@keyframes detail-in { from { opacity: 0; transform: translateY(-6px); } }

/* 7 · tactile press feedback (very short, no bounce) */
button:not(:disabled), .btn, .nav a, .hof-nav a, .medal, .metric-row { transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast); }
button:not(:disabled):active, .btn:active, .nav a:active, .hof-nav a:active { transform: scale(0.97); }
.nav-icon, .pref-choices button, .segmented button, .pr-choice span, .days-picker button { transition: background-color var(--dur-med) var(--ease-out), color var(--dur-med), border-color var(--dur-med); }

/* 8 · pointer devices: interactive cards lift a little */
@media (hover: hover) {
  .shop-item:not(.sold-out), .client-card, .split-card, button.metric-row { transition: transform var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out); }
  .shop-item:not(.sold-out):hover, .split-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(0, 41, 65, 0.12); }
}

/* ==========================================================================
   Sold out (shop)
   ========================================================================== */
.shop-item.sold-out .shop-can { position: relative; }
.shop-item.sold-out .shop-can .cold-can { filter: grayscale(0.85) opacity(0.55); }
.shop-item.sold-out h3, .shop-item.sold-out .shop-price { opacity: 0.6; }
.sold-stamp {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-14deg);
  padding: 4px 12px; border: 3px solid var(--bad); border-radius: 6px; color: var(--bad);
  font: 700 0.95rem/1 var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}
.shop-item.just-sold .sold-stamp { animation: stamp-in 420ms var(--ease-spring) 80ms both; }
.shop-item.just-sold .cold-can { animation: sold-fade 500ms ease both; }
@keyframes stamp-in { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(2.2); } 60% { opacity: 1; } 100% { transform: translate(-50%, -50%) rotate(-14deg) scale(1); } }
@keyframes sold-fade { from { filter: none; } }

/* Reduce Motion: no movement, only short fades; progress shows its final state */
@media (prefers-reduced-motion: reduce) {
  #app.view-enter > *, #app.view-enter :is(.metric-list, .shop-grid, .fame-grid, .tp-overview, .dash-grid, .hist-grid, .split-grid, .client-grid) > * { animation: fade-in var(--dur-fast) ease both !important; animation-delay: 0ms !important; }
  dialog[open], .toast:not([hidden]), .user-menu:not([hidden]), .metric.open .metric-detail { animation: fade-in var(--dur-fast) ease !important; }
  .today-ring, .fame-bar span, .bar-fill, .medal-prog, .shop-item.just-sold .sold-stamp, .shop-item.just-sold .cold-can { animation: none !important; }
  button:not(:disabled):active, .btn:active, .nav a:active, .hof-nav a:active { transform: none; }
  .shop-item:hover, .split-card:hover { transform: none !important; }
}

/* ---------- Macros, food diary, barcode scanner ---------- */
:root { --m-protein: #c2410c; --m-carbs: #2f6f8f; --m-fat: #8a6d00; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --m-protein: #ff9f6b; --m-carbs: #7cc4e4; --m-fat: #e8c95a; }
}
:root[data-theme="dark"] { --m-protein: #ff9f6b; --m-carbs: #7cc4e4; --m-fat: #e8c95a; }
.macro-inline { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; vertical-align: baseline; }
.macro-inline .mi { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.macro-inline .mi b { font-weight: 700; margin-right: 1px; }
.mi-protein b { color: var(--m-protein); }
.mi-carbs b { color: var(--m-carbs); }
.mi-fat b { color: var(--m-fat); }
.meal-macros { margin: -4px 0 8px; font-size: 0.82rem; }
.macro-col { white-space: nowrap; font-variant-numeric: tabular-nums; }
.plan-macros { flex-basis: 100%; }
.plan-summary { flex-wrap: wrap; }
.macro-bars { display: grid; gap: 10px; }
.macro-bar .row-between { font-size: 0.86rem; margin-bottom: 4px; }
.mb-track { height: 8px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--line) 70%, transparent); overflow: hidden; }
.mb-track i { display: block; height: 100%; border-radius: inherit; transition: width var(--dur-slow) var(--ease-out); }
.mb-protein .mb-track i { background: var(--m-protein); }
.mb-carbs .mb-track i { background: var(--m-carbs); }
.mb-fat .mb-track i { background: var(--m-fat); }
.mb-track.over { outline: 2px solid var(--bad); outline-offset: 1px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.diary-date { display: flex; align-items: center; justify-content: center; gap: 14px; margin: -6px 0 16px; }
.diary-date strong { min-width: 12ch; text-align: center; font: 500 1.05rem var(--font-display); }
.diary-date .icon-btn { width: 44px; height: 44px; font-size: 1.4rem; }
.diary-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .diary-grid { grid-template-columns: 340px minmax(0, 1fr); } .diary-summary { position: sticky; top: 84px; } }
.diary-summary { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
@media (min-width: 900px) { .diary-summary { flex-direction: column; align-items: stretch; } .diary-summary .kcal-ring { align-self: center; } }
.diary-sum-side { flex: 1 1 200px; min-width: 0; }
.kcal-left { font: 400 1.05rem var(--font-display); margin: 0 0 4px; }
.kcal-left.bad strong { color: var(--bad); }
.kcal-ring { position: relative; width: 132px; height: 132px; flex: none; }
.kcal-ring svg { width: 100%; height: 100%; }
.kr-track { fill: none; stroke: var(--line); stroke-width: 10; }
.kr-fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dasharray var(--dur-slow) var(--ease-out); }
.kcal-ring.over .kr-fill { stroke: var(--bad); }
.kr-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.kr-text strong { font: 600 1.6rem var(--font-display); letter-spacing: var(--track); font-variant-numeric: tabular-nums; }
.kr-text span { font-size: 0.8rem; color: var(--muted); }
.diary-meal .meal-head { margin-bottom: 6px; }
.diary-items { list-style: none; margin: 0 0 8px; padding: 0; }
.diary-items li + li { border-top: 1px solid var(--border); }
.diary-item { all: unset; box-sizing: border-box; display: flex; width: 100%; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 4px; cursor: pointer; border-radius: 6px; }
div.diary-item { cursor: default; }
button.diary-item:hover { background: var(--surface-2); }
button.diary-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.di-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.di-sub { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.di-kcal { font: 500 1rem var(--font-display); white-space: nowrap; font-variant-numeric: tabular-nums; }
.di-kcal small { color: var(--muted); font-weight: 400; }
.diary-empty { margin: 0 0 10px; }
.diary-add { gap: 6px; }
.diary-note { margin-top: 16px; text-align: center; }
.coach-diary .diary-grid { grid-template-columns: minmax(0, 1fr); }
.coach-diary .diary-summary { position: static; flex-direction: row; }
.coach-diary .kcal-ring { width: 104px; height: 104px; }
.coach-diary .card { padding: 0; border: 0; background: none; }
.coach-diary .diary-date { margin: 0 0 10px; }

.add-food-top { display: flex; gap: 8px; }
.add-food-top input { flex: 1; min-width: 0; }
.add-food-list { position: static; max-height: min(46vh, 380px); overflow: auto; margin: 10px 0 4px; box-shadow: none; border: 1px solid var(--border); }
.add-food-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.add-food-list li > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.add-food-list .list-label { cursor: default; padding-bottom: 2px; }
.add-food-list .list-label:hover { background: none; }
.link-btn { all: unset; color: var(--brass); text-decoration: underline; cursor: pointer; }
.link-btn:focus-visible { outline: 2px solid var(--accent); }
.chip-row { gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.amount-preview { padding: 10px 12px; background: var(--surface-2); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; font-variant-numeric: tabular-nums; }

.scanner { position: fixed; inset: 0; z-index: 1000; background: #000; color: #fff; animation: fade-in var(--dur-fast) ease; }
.scanner.out { opacity: 0; transition: opacity 0.2s ease; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--dur-med) ease; }
.scanner.live video { opacity: 1; }
.scan-frame { position: absolute; left: 50%; top: 42%; width: min(80vw, 420px); aspect-ratio: 16 / 9; transform: translate(-50%, -50%);
  border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5); border: 2px solid rgba(255, 255, 255, 0.9); }
.scan-frame i { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: scan-line 1.8s ease-in-out infinite alternate; }
@keyframes scan-line { from { transform: translateY(-38px); } to { transform: translateY(38px); } }
.scan-top { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; }
.scan-close { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 1.2rem; cursor: pointer; }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, 0.85) 35%); }
.scan-status { text-align: center; margin: 0 0 12px; font-weight: 500; }
.scan-manual { display: flex; gap: 8px; max-width: 460px; margin: 0 auto; }
.scan-manual input { flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.95); color: #002941; }
@media (prefers-reduced-motion: reduce) { .scan-frame i { animation: none; } .mb-track i, .kr-fill { transition: none; } }
.macro-goals .field-row.three { grid-template-columns: 1fr; gap: 6px; }
.macro-goals .field { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 10px; margin: 0; }
.macro-goals .field label { margin: 0; }
.macro-goals [data-mg-kcal] { margin: 10px 0; }

/* ---------- E-mail: login, reset, confirm ---------- */
.login-wrap.single { grid-template-columns: minmax(0, 420px); justify-content: center; }
.login-forgot { text-align: center; margin: 12px 0 0; }
.verify-card { text-align: center; }
.verify-icon { width: 56px; height: 56px; margin: 4px auto 8px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.verify-card .btn { margin-top: 12px; }
.email-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 6px; word-break: break-all; }

/* ---------- Head2Head ---------- */
:root { --duel-me: #e85656; --duel-them: #2a7fb0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --duel-me: #e85656; --duel-them: #2f8ac2; }
}
:root[data-theme="dark"] { --duel-me: #e85656; --duel-them: #2f8ac2; }
.h2h-intro { text-align: center; max-width: 620px; margin: 0 auto; }
.h2h-hero { font-size: 2.6rem; margin: 0; }
.h2h-privacy { text-align: left; margin: 16px auto 20px; padding-left: 1.2em; color: var(--muted); max-width: 480px; }
.h2h-privacy li + li { margin-top: 6px; }
.h2h-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.h2h-record { display: flex; gap: 18px; color: var(--muted); font-size: 0.9rem; }
.h2h-record strong { font: 600 1.5rem var(--font-display); color: var(--text); margin-right: 4px; font-variant-numeric: tabular-nums; }
.h2h-section { margin: 24px 0 10px; font: 500 0.82rem var(--font-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.h2h-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.h2h-card { display: flex; flex-direction: column; gap: 10px; }
.h2h-card h3 { font-size: 1rem; margin: 0; }
.h2h-card p { margin: 0; }
.h2h-card.s-declined, .h2h-card.s-cancelled, .h2h-card.s-expired { opacity: 0.7; }
.h2h-vs { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 4px 0; }
.h2h-av { width: 52px; height: 52px; font-size: 1.2rem; }
.h2h-av:first-child { box-shadow: 0 0 0 3px var(--duel-me); }
.h2h-av:last-child { box-shadow: 0 0 0 3px var(--duel-them); }
.h2h-initial { font: 600 1.2rem var(--font-display); }
.h2h-vs-x { font: 700 0.95rem var(--font-display); letter-spacing: 0.08em; color: var(--muted); }
.h2h-msg { font-style: italic; color: var(--steel); }
.h2h-score { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.h2h-side { display: flex; flex-direction: column; }
.h2h-side.them { text-align: right; }
.h2h-side strong { font: 600 1.45rem var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: var(--track); }
.h2h-side.lead strong::after { content: ' ▲'; font-size: 0.7em; color: var(--good); }
.h2h-side.them.lead strong::after { content: ''; }
.h2h-side.them.lead strong::before { content: '▲ '; font-size: 0.7em; color: var(--good); }
.h2h-who { font-size: 0.82rem; color: var(--muted); }
.h2h-tug { grid-column: 1 / -1; height: 10px; border-radius: var(--r-pill); background: var(--duel-them); overflow: hidden; }
.h2h-tug i { display: block; height: 100%; background: var(--duel-me); border-right: 2px solid var(--surface); transition: width var(--dur-slow) var(--ease-out); }
.h2h-actions { gap: 8px; flex-wrap: wrap; }
.h2h-live { background: var(--accent-soft); }
.h2h-players { list-style: none; padding: 6px 16px; margin: 0; }
.h2h-players li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.h2h-players li + li { border-top: 1px solid var(--border); }
.h2h-players .h2h-av { width: 40px; height: 40px; box-shadow: none; }
.h2h-pname { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.h2h-off { margin-top: 24px; text-align: center; }
.h2h-metrics { display: grid; gap: 6px; }
.h2h-metric { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; margin: 0; }
.h2h-metric:has(input:checked) { border-color: var(--text); background: var(--surface-2); }
.h2h-metric input { margin-top: 3px; width: auto; }
.h2h-metric span { display: flex; flex-direction: column; }
.h2h-metric small { color: var(--muted); }
.h2h-chart-wrap { position: relative; }
.h2h-chart { display: block; width: 100%; height: auto; touch-action: pan-y; }
.h2h-gridline { stroke: var(--line); stroke-width: 1; }
.h2h-axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.h2h-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.h2h-line.me { stroke: var(--duel-me); }
.h2h-line.them { stroke: var(--duel-them); }
.h2h-dot { stroke: var(--surface); stroke-width: 2; }
.h2h-dot.me { fill: var(--duel-me); }
.h2h-dot.them { fill: var(--duel-them); }
.h2h-endlabel { fill: var(--text); font-size: 12px; font-weight: 600; font-family: var(--font-body); }
.h2h-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.h2h-hit { fill: transparent; cursor: crosshair; }
.h2h-tip { position: absolute; top: 6px; min-width: 140px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 0.82rem; pointer-events: none; box-shadow: 0 4px 16px rgba(0, 41, 65, 0.12); }
.h2h-tip i, .h2h-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.h2h-tip i.me, .h2h-legend i.me { background: var(--duel-me); }
.h2h-tip i.them, .h2h-legend i.them { background: var(--duel-them); }
.h2h-legend { display: flex; gap: 16px; font-size: 0.85rem; margin-top: 6px; }
.h2h-home h2 { font-size: 1.1rem; }
.h2h-home-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 0; color: inherit; text-decoration: none; border-top: 1px solid var(--border); }
.h2h-home-row:first-of-type { margin-top: 8px; }
.h2h-home-score { margin-left: auto; font: 600 1rem var(--font-display); font-variant-numeric: tabular-nums; }
.h2h-home-score.me { color: var(--good); }
@media (prefers-reduced-motion: reduce) { .h2h-tug i { transition: none; } }
.coin-inline { white-space: nowrap; font-weight: 600; color: var(--text); }
.coin-inline .coin { vertical-align: -2px; }
.code-input { font: 600 1.6rem/1 var(--font-display); letter-spacing: 0.45em; text-align: center; font-variant-numeric: tabular-nums; padding-left: 0.45em; }
.code-input::placeholder { letter-spacing: 0.45em; color: var(--line); }
.mail-status { display: grid; gap: 6px; margin: 10px 0; }
.mail-status div { display: flex; gap: 12px; flex-wrap: wrap; }
.mail-status dt { min-width: 80px; color: var(--muted); font-size: 0.88rem; }
.mail-status dd { margin: 0; word-break: break-all; }
.mail-warning { padding: 10px 12px; border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); margin: 8px 0; }
.mail-test { gap: 8px; flex-wrap: nowrap; }
.mail-test input { flex: 1; min-width: 0; }
.pdf-row { margin: -8px 0 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.coach-pdf { margin: 0; }
.google-scopes { list-style: none; padding: 0; margin: 10px 0; display: flex; gap: 18px; }
.google-scopes li.ok span { color: var(--good); font-weight: 700; }
.google-scopes li.off { color: var(--muted); }
.google-privacy { margin: 8px 0 14px; }
.google-privacy summary { cursor: pointer; font-size: 0.9rem; color: var(--brass); }
.login-legal { text-align: center; margin: 14px 0 0; color: var(--muted); }
.login-legal a { color: var(--muted); }
