/* Potgieter Fitness: Night/Day Glass, the wall's tokens at phone scale. */

:root {
  --radius: 22px;
  --radius-sm: 14px;
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --tap: 48px;
  --accent: #8fd4a8;
  --accent-on: #07160d;
  --member: #7fd3e6;
}

[data-theme="night"] {
  color-scheme: dark;
  --bg: #0a101d;
  --text: #e8edf7;
  --muted: #9aa7bd;
  --faint: #6f7c93;
  --tile: rgba(255, 255, 255, 0.06);
  --tile-strong: rgba(255, 255, 255, 0.10);
  --tile-border: rgba(255, 255, 255, 0.10);
  --line: rgba(255, 255, 255, 0.14);
  --sheet: #121a2b;
  --shadow: none;
  --good: #8fd4a8;
  --warn: #f2b880;
  --bad: #ffb3a1;
  --info: #8fb8ff;
  --heat0: rgba(255, 255, 255, 0.07);
  --tabbar: rgba(10, 16, 29, 0.92);
}

[data-theme="day"] {
  color-scheme: light;
  --bg: #e9eff7;
  --text: #142033;
  --muted: #55627a;
  --faint: #6b778c;
  --tile: rgba(255, 255, 255, 0.72);
  --tile-strong: rgba(255, 255, 255, 0.95);
  --tile-border: rgba(255, 255, 255, 0.95);
  --line: rgba(20, 32, 51, 0.14);
  --sheet: #f7f9fc;
  --shadow: 0 12px 32px rgba(40, 60, 100, 0.08);
  --good: #2f7d50;
  --warn: #a5561a;
  --bad: #b23a22;
  --info: #2f5fb3;
  --heat0: rgba(20, 32, 51, 0.07);
  --tabbar: rgba(247, 249, 252, 0.94);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; font-family: var(--font); color: var(--text); background: var(--bg);
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
[data-theme="night"] .sky {
  background-color: #0a101d;
  background-image: radial-gradient(70vmax 50vmax at 90% 0%, rgba(120, 140, 255, 0.22), transparent 70%),
    radial-gradient(60vmax 60vmax at 0% 100%, rgba(80, 200, 170, 0.12), transparent 70%);
}
[data-theme="day"] .sky {
  background-color: #e9eff7;
  background-image: radial-gradient(70vmax 50vmax at 90% 0%, rgba(255, 200, 130, 0.45), transparent 70%),
    radial-gradient(60vmax 60vmax at 0% 100%, rgba(130, 200, 230, 0.35), transparent 70%);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--member); }
:focus-visible { outline: 2px solid var(--member); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
#app.full { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); }
.eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.center { text-align: center; }

.header { display: flex; align-items: center; gap: 12px; padding-top: env(safe-area-inset-top); }
.header h1 { font-size: 26px; font-weight: 600; }
.avatar { width: 44px; height: 44px; border-radius: 22px; border: 2px solid var(--member); background: color-mix(in srgb, var(--member) 15%, transparent);
  color: var(--member); font-weight: 600; display: grid; place-items: center; flex: none; text-decoration: none; }

.card { background: var(--tile); border: 1px solid var(--tile-border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; }
.card.tight { padding: 12px 14px; }
.card h2 { font-size: 21px; font-weight: 600; }
.section-title { font-size: 13px; color: var(--muted); margin: 6px 2px -4px; }

/* ---------- buttons ---------- */
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 16px; border: 1px solid var(--line); background: transparent; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; font-weight: 500; font-size: 15px; text-decoration: none; color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-on); border-color: transparent; font-weight: 600; font-size: 17px; min-height: 56px; }
.btn.soft { background: var(--tile-strong); border-color: transparent; }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 12px; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { width: var(--tap); height: var(--tap); border-radius: var(--radius-sm); border: 0; background: var(--tile); display: grid; place-items: center; flex: none; color: var(--text); }
.icon-btn svg, .btn svg { width: 20px; height: 20px; }

.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 20%, transparent); border-color: var(--accent); }
.pill { padding: 4px 10px; border-radius: 999px; background: var(--tile-strong); font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex: none; }

/* ---------- habits ---------- */
.habits { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.habit { min-height: 52px; border-radius: 16px; border: 1px solid var(--line); background: transparent; font-weight: 500; font-size: 14px; padding: 6px 10px; }
.habit[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent); }
.habit[aria-pressed="true"]::before { content: "✓ "; }

/* ---------- week strip + heat map ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border-radius: 14px; border: 1px solid transparent; background: var(--tile); }
.week button[aria-current="date"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.week .dow { font-size: 11px; color: var(--muted); }
.week .num { font-size: 15px; font-weight: 600; }
.week .marks { display: flex; gap: 3px; min-height: 6px; }
.week .marks span { width: 6px; height: 6px; border-radius: 3px; }
.heat { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; }
.heat.month { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.heat span { aspect-ratio: 1; border-radius: 4px; background: var(--heat0); }
.heat span[data-s="1"] { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.heat span[data-s="2"] { background: color-mix(in srgb, var(--accent) 60%, transparent); }
.heat span[data-s="3"] { background: var(--accent); }
.heat span.today { outline: 2px solid var(--text); outline-offset: 1px; }
.heat.month span { display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.heat.month span[data-s="3"], .heat.month span[data-s="2"] { color: var(--accent-on); }

/* ---------- today ---------- */
.plan-line { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--tile); }
.plan-line .role { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); width: 62px; flex: none; }
.plan-line.done { opacity: 0.6; }
.plan-line.done .title::after { content: " ✓"; color: var(--good); }

/* ---------- session ---------- */
.progress { display: grid; grid-auto-flow: column; gap: 4px; }
.progress span { height: 4px; border-radius: 2px; background: var(--tile-strong); }
.progress span.on { background: var(--accent); }
.group { background: var(--tile); border: 1px solid var(--tile-border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.group.done { opacity: 0.65; }
.group.collapsed .group-body { display: none; }
.group-head { display: flex; align-items: center; gap: 10px; }
.group-head .title { font-weight: 600; font-size: 16px; }
.letter { width: 28px; height: 28px; border-radius: 9px; background: var(--member); color: var(--bg); font-weight: 700; display: grid; place-items: center; flex: none; font-size: 14px; }
.letter.b { background: #ff9fc6; }
.slot { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.slot + .slot { border-top: 1px solid var(--line); padding-top: 12px; }
.slot-name { font-size: 17px; font-weight: 600; background: none; border: 0; padding: 0; text-align: left; color: var(--text); text-decoration: underline dotted var(--faint); text-underline-offset: 4px; }
.rx { font-size: 13px; color: var(--muted); line-height: 1.35; }
.set-row { display: grid; grid-template-columns: 26px 1fr 1fr 52px; gap: 8px; align-items: center; }
.set-row.head { font-size: 11px; color: var(--muted); }
.set-row .n { font-family: var(--mono); font-size: 13px; color: var(--muted); text-align: center; }
.stepper { display: flex; align-items: center; justify-content: space-between; height: var(--tap); border-radius: var(--radius-sm); background: var(--tile-strong); padding: 0 2px; }
.stepper button { width: 38px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.stepper input { width: 100%; min-width: 0; text-align: center; border: 0; background: transparent; font-size: 18px; font-weight: 600; padding: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.check { width: 52px; height: var(--tap); border-radius: var(--radius-sm); border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 20px; font-weight: 700; }
.check[aria-pressed="true"] { background: var(--accent); color: var(--accent-on); border-color: transparent; }
.move-row { display: flex; align-items: flex-start; gap: 10px; }
.move-row .check { flex: none; }
.ts { font-family: var(--mono); font-size: 12px; color: var(--member); background: none; border: 1px solid color-mix(in srgb, var(--member) 40%, transparent); border-radius: 8px; padding: 2px 6px; }
.suggest { font-size: 12px; padding: 6px 10px; border-radius: 10px; background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--text); }
.suggest.heavier { background: color-mix(in srgb, var(--good) 18%, transparent); }
.suggest.lighter { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.note-line { font-size: 12px; padding: 6px 10px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 12%, transparent); }
.timer { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px;
  background: color-mix(in srgb, var(--info) 22%, var(--sheet)); border: 1px solid color-mix(in srgb, var(--info) 45%, transparent); }
.timer .clock { font-family: var(--mono); font-size: 28px; color: var(--info); min-width: 80px; }
.timer.ending .clock { color: var(--warn); }
.timer .bar { height: 4px; border-radius: 2px; background: var(--info); transition: width 1s linear; }

/* ---------- sheets + toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; background: var(--sheet); border-radius: 28px 28px 0 0; border-top: 1px solid var(--line);
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; animation: rise 0.2s ease; }
.sheet .grab { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
.sheet h2 { font-size: 21px; font-weight: 600; }
.option { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 56px; padding: 10px 14px; border-radius: 16px; border: 2px solid transparent;
  background: var(--tile); text-align: left; width: 100%; }
.option[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.option .t { font-weight: 600; font-size: 15px; }
.option .s { font-size: 12px; color: var(--muted); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 30; background: var(--sheet); border: 1px solid var(--line);
  border-radius: 16px; padding: 10px 12px 10px 16px; display: flex; gap: 12px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,0.3); max-width: calc(100% - 32px); }
.toast .btn { min-height: 36px; }
@keyframes rise { from { transform: translateY(40px); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], select, textarea {
  min-height: var(--tap); border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--tile); padding: 0 14px; font-size: 16px; color: var(--text); }
textarea { padding: 10px 14px; min-height: 80px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: transparent; font-size: 14px; padding: 0 10px; }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.days button { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: transparent; font-size: 13px; }
.days button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); font-weight: 600; }

/* ---------- program picker ---------- */
.program { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; border-radius: 18px; border: 1px solid var(--tile-border); background: var(--tile); padding: 14px; }
.program .stripe { width: 6px; align-self: stretch; border-radius: 3px; flex: none; }
.program .name { font-weight: 600; font-size: 16px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--tabbar); border-top: 1px solid var(--line); backdrop-filter: blur(12px);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabbar nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.tabbar a { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 14px; color: var(--muted); text-decoration: none; font-size: 11px; }
.tabbar a[aria-current="page"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tabbar svg { width: 24px; height: 24px; }
.hidden { display: none !important; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 140px; }
.chart path.line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart circle { fill: var(--accent); }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart line { stroke: var(--line); }

.empty { text-align: center; padding: 28px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.sync-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--warn); }
.info-block h3 { font-size: 14px; margin-top: 6px; }
.info-block ol, .info-block ul { margin: 4px 0; padding-left: 20px; font-size: 14px; line-height: 1.45; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
