/* Forge — dark athletic. One molten-amber accent on near-black. */
:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #141417;
  --panel-2: #1a1a1f;
  --line: #26262b;
  --txt: #f5f5f7;
  --muted: #a1a1aa;
  --faint: #71717a;
  --amber: #ff9a3c;
  --amber-2: #ffce8a;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --r: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--txt); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--amber); }
.hidden { display: none !important; }
.view { min-height: 100vh; }

/* ---------- loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.loader-spark { width: 64px; height: 64px; animation: pulse 1.4s ease-in-out infinite; filter: drop-shadow(0 0 22px rgba(255,138,40,.5)); }
.loader-title { font-weight: 800; letter-spacing: .02em; font-size: 18px; }
.loader-sub { color: var(--faint); font-size: 13px; min-height: 18px; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.14); opacity: 1; } }

/* ---------- login ---------- */
#login { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; gap: 24px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.brand-mark { width: 54px; height: 54px; filter: drop-shadow(0 0 18px rgba(255,138,40,.45)); }
.brand-mark.sm { width: 24px; height: 24px; filter: none; }
.brand-word { font-size: 34px; font-weight: 800; letter-spacing: .16em; margin: 10px 0 4px; }
.brand-tag { color: var(--muted); margin: 0 0 26px; font-size: 14px; }
.auth-step { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-step label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
input {
  width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--txt);
  border-radius: 12px; padding: 14px 16px; font-size: 17px; outline: none; transition: border-color .15s;
}
input:focus { border-color: var(--amber); }
#code { text-align: center; letter-spacing: .5em; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn {
  width: 100%; border: 0; cursor: pointer; border-radius: 12px; padding: 15px 18px; margin-top: 4px;
  font-size: 16px; font-weight: 700; color: #1a1206;
  background: linear-gradient(135deg, #ff7a18, #ffce8a);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-link { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 8px; }
.auth-msg { min-height: 20px; font-size: 14px; margin: 14px 0 0; }
.auth-msg.err { color: var(--bad); }
.auth-msg.ok { color: var(--good); }

/* ---------- app chrome ---------- */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--safe-t)) 18px 12px; background: rgba(10,10,11,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .14em; font-size: 15px; }
.top-right { display: flex; align-items: center; gap: 6px; }
.top-date { color: var(--faint); font-size: 12px; margin-right: 4px; }
.icon-btn { background: var(--panel); border: 1px solid var(--line); color: var(--txt); width: 38px; height: 38px; border-radius: 10px; font-size: 17px; cursor: pointer; }
.icon-btn:active { background: var(--panel-2); }
.wrap { max-width: 720px; margin: 0 auto; padding: 18px 16px calc(40px + var(--safe-b)); }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 26px 4px 12px; }

/* ---------- readiness ---------- */
.readiness { padding: 6px 4px 2px; }
.readiness .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); }
.readiness .headline { font-size: 26px; font-weight: 800; line-height: 1.18; margin: 6px 0 0; }
.readiness .bar { height: 4px; width: 54px; border-radius: 3px; margin-top: 12px; background: var(--amber); }
.readiness.high .bar { background: var(--good); }
.readiness.moderate .bar { background: var(--amber); }
.readiness.low .bar { background: var(--bad); }
.readiness .src { font-size: 11px; color: var(--faint); margin-top: 8px; }

/* ---------- coach / workouts ---------- */
.coach { display: grid; gap: 12px; margin-top: 18px; }
.wkt { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; position: relative; overflow: hidden; }
.wkt::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(#ff7a18, #ffce8a); }
.wkt.done { opacity: .62; }
.wkt-head { display: flex; align-items: center; gap: 10px; }
.wkt-num { font-size: 12px; font-weight: 800; color: var(--faint); letter-spacing: .1em; }
.wkt-title { font-size: 18px; font-weight: 750; margin: 0; flex: 1; }
.wkt-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.chip { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 4px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.chip.outdoor { color: #1a1206; background: linear-gradient(135deg, #ff7a18, #ffce8a); border: 0; }
.chip.hard { color: var(--bad); } .chip.moderate { color: var(--warn); } .chip.easy { color: var(--good); }
.wkt-details { margin: 12px 0 0; font-size: 15px; line-height: 1.55; }
.wkt-why { margin: 10px 0 0; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.wkt-check { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; border: 1px solid var(--line); color: var(--faint); }
.wkt.done .wkt-check { background: var(--good); color: #06281c; border: 0; }
.steps-note { margin-top: 12px; font-size: 14px; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; }
.cautions { margin-top: 10px; font-size: 13px; color: var(--warn); }

/* ---------- steps ring ---------- */
.steps-card { display: flex; align-items: center; gap: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-top: 18px; }
.ring { width: 104px; height: 104px; flex: 0 0 auto; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: url(#forge-amber); stroke-linecap: round; transition: stroke-dashoffset .9s ease; }
.ring.done .fill { stroke: var(--good); }
.steps-info .big { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.steps-info .goal { color: var(--faint); font-size: 14px; }
.steps-info .rem { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- metrics ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.metric .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.metric .v { font-size: 26px; font-weight: 750; margin-top: 6px; font-variant-numeric: tabular-nums; }
.metric .v .u { font-size: 13px; color: var(--faint); font-weight: 500; margin-left: 2px; }
.metric .d { font-size: 12px; margin-top: 4px; color: var(--faint); }
.metric .d.up { color: var(--bad); } .metric .d.down { color: var(--good); }

/* ---------- panel / chart ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-top: 18px; }
.panel-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.chart { width: 100%; height: 120px; display: block; }

/* ---------- connect-a-source empty state ---------- */
.empty { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; text-align: center; }
.empty h3 { margin: 0 0 6px; }
.empty p { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

/* ---------- footer ---------- */
.foot { text-align: center; color: var(--faint); font-size: 12px; padding: 26px 0 8px; }
.foot a { color: var(--muted); text-decoration: none; }

/* ---------- log sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.sheet-card { position: relative; width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(22px + var(--safe-b)); max-height: 90vh; overflow-y: auto; animation: rise .2s ease; }
@keyframes rise { from { transform: translateY(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-size: 17px; }
.sheet-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 10px; padding: 11px; font-weight: 700; cursor: pointer; }
.tab.on { color: #1a1206; background: linear-gradient(135deg,#ff7a18,#ffce8a); border: 0; }
.sheet-pane { display: flex; flex-direction: column; gap: 12px; }
.sheet-pane label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hint { font-size: 14px; color: var(--amber-2); min-height: 18px; font-weight: 600; }
.lab-row { display: grid; grid-template-columns: 1.5fr 1fr .8fr; gap: 8px; }
.lab-row input { padding: 11px 12px; font-size: 15px; }

/* ---------- labs panel ---------- */
.lab-list { display: grid; gap: 2px; }
.lab-item { display: flex; align-items: baseline; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.lab-item:last-child { border-bottom: 0; }
.lab-name { color: var(--txt); font-weight: 600; }
.lab-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.lab-val .u { color: var(--faint); font-size: 12px; margin-left: 3px; font-weight: 400; }
.lab-date { color: var(--faint); font-size: 12px; margin-left: 8px; font-weight: 400; }
.empty-sm { color: var(--faint); font-size: 13px; }
