/* Liftbook: black and gold, as the current app; a warm light theme too. */
:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #0f0f11;
  --surface-2: #17171a;
  --line: rgba(255, 255, 255, 0.09);
  --line-gold: rgba(212, 175, 55, 0.35);
  --text: #fff;
  --muted: #a1a1aa;
  --subtle: #82828b;
  --gold: #d4af37;
  --gold-bright: #f4d03f;
  --gold-soft: rgba(212, 175, 55, 0.12);
  --on-gold: #000;
  --good: #4ade80;
  --bad: #f87171;
  --new: #60a5fa;
  --radius: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f5f3f0;
    --surface: #fcfaf7;
    --surface-2: #efebe5;
    --line: rgba(0, 0, 0, 0.09);
    --line-gold: rgba(166, 132, 48, 0.4);
    --text: #1c1917;
    --muted: #57534e;
    --subtle: #6b6560;
    --gold: #9a7a2c;
    --gold-bright: #b8912f;
    --gold-soft: rgba(154, 122, 44, 0.1);
    --on-gold: #fff;
    --good: #15803d;
    --bad: #b91c1c;
    --new: #1d4ed8;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f3f0;
  --surface: #fcfaf7;
  --surface-2: #efebe5;
  --line: rgba(0, 0, 0, 0.09);
  --line-gold: rgba(166, 132, 48, 0.4);
  --text: #1c1917;
  --muted: #57534e;
  --subtle: #6b6560;
  --gold: #9a7a2c;
  --gold-bright: #b8912f;
  --gold-soft: rgba(154, 122, 44, 0.1);
  --on-gold: #fff;
  --good: #15803d;
  --bad: #b91c1c;
  --new: #1d4ed8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--gold); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: 0.01em; line-height: 1.2; }
h1 { font-size: 1.75rem; margin: 0 0 4px; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); font-size: 0.875rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ---------- frame ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }
.brand img { border-radius: 8px; }
.topnav { display: none; gap: 4px; margin-left: 12px; }
.topnav a, .tabbar a { color: var(--muted); text-decoration: none; }
.topnav a { padding: 6px 12px; border-radius: 999px; font-weight: 500; font-size: 0.95rem; }
.topnav a:hover { color: var(--text); }
.topnav a.active { color: var(--gold); background: var(--gold-soft); }
.sync-pill {
  margin-left: auto; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font: 500 0.8rem var(--font); padding: 5px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.sync-pill.warn { color: var(--gold); border-color: var(--line-gold); }
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 0.72rem; font-weight: 500; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--gold); }
body.signed-out .tabbar, body.signed-out .topnav, body.signed-out .sync-pill { display: none !important; }
body.signed-out { padding-bottom: 0; }
@media (min-width: 760px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 32px; }
}

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 32px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.loading { padding: 48px 0; }

/* ---------- pieces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card.gold { border-color: var(--line-gold); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 1.5rem; font-family: var(--serif); color: var(--gold); }
.stat span { font-size: 0.8rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: 600 0.95rem var(--font); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--line-gold); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn.primary:hover { background: var(--gold-bright); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 0.85rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.linkish { background: none; border: 0; padding: 0; color: var(--gold); font: inherit; cursor: pointer; text-decoration: underline; }

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.hint { font-size: 0.82rem; color: var(--subtle); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: 16px var(--font);
}
textarea { font-family: var(--mono); font-size: 16px; line-height: 1.55; min-height: 220px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--gold); flex: none; }
.error { color: var(--bad); font-size: 0.9rem; }
.errors { margin: 8px 0 0; padding-left: 18px; color: var(--bad); font-size: 0.9rem; }
.ok { color: var(--good); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list a.item, .list .item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px; color: var(--text); text-decoration: none; }
.item .meta { color: var(--muted); font-size: 0.85rem; }
.chev::after { content: "›"; color: var(--subtle); font-size: 1.3rem; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; border: 1px solid var(--line); color: var(--muted); }
.pill.improved { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.pill.new { color: var(--new); border-color: color-mix(in srgb, var(--new) 40%, transparent); }
.pill.error { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

.table-scroll { overflow-x: auto; }
table.summary { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.summary th, table.summary td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
table.summary th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; border-top: 0; }
pre.out { white-space: pre-wrap; word-break: break-word; font: 15px/1.55 var(--mono); margin: 0; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 14px; font: 600 0.88rem var(--font); cursor: pointer; }
.tabs button.on { color: var(--on-gold); background: var(--gold); border-color: var(--gold); }

.exercise { padding: 10px 0; border-top: 1px solid var(--line); }
.exercise:first-child { border-top: 0; }
.exercise .name { font-weight: 600; }
.exercise .sets { font-family: var(--mono); color: var(--muted); font-size: 0.92rem; white-space: pre-wrap; }

.chart { width: 100%; height: 220px; display: block; }
.chart .axis { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--gold-soft); }
.chart .dot { fill: var(--gold); }
.chart text { fill: var(--subtle); font: 11px var(--font); }

.picker { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; }
.picker label { font-weight: 500; display: flex; gap: 10px; align-items: center; padding: 8px 0; margin: 0; border-top: 1px solid var(--line); }
.picker label:first-child { border-top: 0; }
.picker input { width: 20px; height: 20px; accent-color: var(--gold); }

.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line-gold); display: grid; place-items: center; font-family: var(--serif); font-size: 1.5rem; color: var(--gold); }

.auth { max-width: 420px; margin: 6vh auto 0; }
.auth .logo { display: block; margin: 0 auto 12px; border-radius: 18px; }
.auth h1 { text-align: center; }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line-gold);
  padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: calc(100vw - 32px); font-size: 0.92rem;
}
@media (min-width: 760px) { .toast { bottom: 24px; } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- coach ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; max-width: 85%; background: var(--gold-soft); border: 1px solid var(--line-gold); border-radius: var(--radius) var(--radius) 4px var(--radius); padding: 10px 14px; white-space: pre-wrap; }
.msg.coach { margin-bottom: 0; }
.msg-foot { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.btn.on { border-color: var(--gold); background: var(--gold-soft); }
.answer p { margin: 0 0 8px; }
.answer ul { margin: 0 0 8px; padding-left: 20px; }
.answer li + li { margin-top: 4px; }
.answer strong { color: var(--gold); }
.steps { list-style: none; margin: 0 0 10px; padding: 0; font-size: 0.82rem; color: var(--subtle); }
.steps li::before { content: "✓ "; color: var(--good); }
.steps li.error::before { content: "↻ "; color: var(--subtle); }
.starters button { text-align: left; }
textarea.chat-input { min-height: 64px; font-family: var(--font); }
.key-row { flex-wrap: wrap; }
.past summary { cursor: pointer; font-weight: 600; }
.past .list summary { cursor: pointer; font-weight: 500; }
.past .answer { padding: 0 2px 12px; font-size: 0.95rem; }
