
/* Power Level. One phone-width column, thumb controls low. Single dark "scouter at night" look, chosen on purpose. */
:root {
  --bg: #0b0d16;
  --surface: #141826;
  --surface-2: #1c2134;
  --line: #2a3048;
  --fg: #eceef7;
  --muted: #8d94ae;
  --ki: #ffb627;        /* gold aura */
  --ki-dim: #ffb62726;
  --scouter: #6ef2a0;   /* readout green */
  --blue: #5cc3ff;
  --hot: #ff6a4d;
  --crimson: #ff4f7b;
  --silver: #d9e2f2;
  /* Branch colours: the same as the skill tree. */
  --push: #ffb627;
  --pull: #5cc3ff;
  --core: #c49bff;
  --legs: #6ef2a0;
  --cardio: #ff8a65;
  --mind: #9db2ff;
  --display: "Chakra Petch", "Rajdhani", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font: 15px/1.45 var(--body); }
* { box-sizing: border-box; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }

.wrap { padding: 0 16px 48px; }
.tabs {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding-block: 10px; margin: 0 -16px 12px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs button {
  border: 0; background: none; padding: 8px 16px; border-radius: 999px;
  font-family: var(--display); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 13px;
  color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--fg); }

/* ---------- Logger ---------- */
.phone { max-width: 430px; margin: 0 auto; display: grid; gap: 12px; }
.label { color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }

.pl-card {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px;
  padding: 8px 12px; text-align: right; display: grid; gap: 0; position: relative;
}
.pl-card .num { font-size: 22px; color: var(--scouter); font-weight: 700; line-height: 1.1; }
.tier { font-family: var(--display); font-weight: 600; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }

.rest {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 16px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--line);
}
#restNum { font-size: 44px; font-weight: 700; line-height: 1; }
.rest.calm #restNum { color: var(--blue); }
.rest.ready #restNum { color: var(--ki); }
.rest.long #restNum { color: var(--hot); }
.rest .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.picks { display: grid; gap: 6px; }
.chiprow { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chiprow::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 9px 14px; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.chip.on { border-color: var(--ki); background: var(--ki-dim); color: var(--ki); }
.chip.more { color: var(--blue); }
.chip .star { color: var(--ki); margin-right: 4px; }
.chip .bd { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.chip .lv { font-family: var(--display); font-size: 11px; color: var(--muted); margin-left: 6px; }

.foot { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; display: grid; gap: 8px; }
.foot-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--line); color: var(--fg); }
.tally { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.tally span { display: inline-flex; align-items: center; gap: 6px; }
.tally b { color: var(--fg); }
.tally .dot { width: 9px; height: 9px; }
[hidden] { display: none !important; }
.treesvg { user-select: none; -webkit-user-select: none; display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto; }
.treesvg text { font-family: var(--display); font-size: 10px; fill: var(--muted); }
.treesvg .fl { fill: var(--fg); font-weight: 600; }
.treesvg .hubt { font-size: 9.5px; font-weight: 700; letter-spacing: .08em; fill: var(--fg); }
.treesvg .lv { font-size: 11px; font-weight: 700; fill: var(--fg); }
.treesvg .lv.on { fill: #140e00; }
.tnode { cursor: pointer; }
.tnode:focus { outline: none; }
.tnode.ghost { opacity: .45; }
.tree-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.tree-tools .addrow { padding: 6px 12px; }
.addform { display: grid; gap: 10px; background: var(--surface-2); border-radius: 14px; padding: 12px; }
.addform input { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.addform .seg { background: var(--bg); }
.seg.branches button { flex: 1; }
.seg.branches button[aria-pressed="true"] { background: var(--c); color: var(--bg); }
.addrow2 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.addrow2 .primary { flex: 1; height: 46px; }
.goal { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.goal input { width: 70px; text-align: right; }
.err { color: var(--hot); }
.tnode:focus-visible .core { stroke: var(--blue); stroke-width: 3; }
#footSvg { cursor: pointer; }
.thub { cursor: pointer; }
.thub:focus { outline: none; }
.thub:focus-visible circle { stroke-width: 3.5; }
.tree-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.entry {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px; display: grid; gap: 12px;
}
.entry-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.entry-head h2 { margin: 0; font-family: var(--display); font-size: 22px; letter-spacing: .02em; }
.entry-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.starbtn { border: 0; background: none; font-size: 22px; color: var(--muted); padding: 0 4px; line-height: 1; }
.starbtn.on { color: var(--ki); }
.steppers { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; }
.stepper { display: grid; gap: 4px; }
.stepper .row { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; background: var(--surface-2); border-radius: 12px; }
.stepper button { border: 0; background: none; height: 52px; font-size: 22px; color: var(--muted); }
.stepper button:active { color: var(--fg); }
.stepper input {
  width: 100%; min-width: 0; border: 0; background: none; text-align: center;
  font-family: var(--display); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.rpe { display: grid; grid-template-columns: auto repeat(5, 1fr); gap: 6px; align-items: center; }
.rpe button { border: 1px solid var(--line); background: none; border-radius: 10px; height: 38px; font-family: var(--display); font-weight: 600; }
.rpe button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.logbtn {
  border: 0; border-radius: 14px; height: 60px; background: var(--ki); color: #1a1100;
  font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: .06em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.logbtn small { font-family: var(--body); font-weight: 600; font-size: 13px; letter-spacing: 0; text-transform: none; opacity: .75; }
.logbtn:active { transform: translateY(1px); }
.logbtn.holding { background: var(--scouter); color: #04190c; animation: holdpulse 1.6s ease-in-out infinite; }
@keyframes holdpulse { 50% { box-shadow: 0 0 0 6px #6ef2a033; } }
.rest.hold { border-color: var(--scouter); }
.rest.hold #restNum { color: var(--scouter); }
.steppers.solo { grid-template-columns: 1fr; }
#exNext { color: var(--fg); opacity: .8; }
#manualBtn, #noteBtn { justify-self: center; }
.notein { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font: inherit; color: inherit; resize: vertical; }
.side summary { cursor: pointer; color: var(--blue); font-size: 13px; font-weight: 600; padding: 4px 0; }
.side[open] { display: grid; gap: 6px; }
.setnote { grid-column: 1 / -1; margin: 4px 0 0; color: var(--fg); opacity: .85; font-size: 13px; white-space: pre-wrap; }

.feed { display: grid; gap: 0; }
.feed-head { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 2px 8px; }
.linkbtn { border: 0; background: none; color: var(--blue); font-weight: 600; font-size: 13px; padding: 4px; }
.set {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 2px;
  border-top: 1px solid var(--line);
}
.set .what { font-weight: 600; }
.set .load { font-family: var(--display); font-variant-numeric: tabular-nums; }
.set .ki { font-family: var(--display); color: var(--ki); text-align: right; font-variant-numeric: tabular-nums; }
.set .sub { color: var(--muted); font-size: 12px; }
.set .sub.r { text-align: right; }
.pr { color: var(--scouter); font-weight: 700; font-size: 11px; letter-spacing: .08em; margin-left: 6px; }

.league { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: grid; gap: 6px; }
.league ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.league li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 8px; }
.league li.me { background: var(--ki-dim); }
.league .rk { color: var(--muted); font-family: var(--display); }
.league .v { font-family: var(--display); font-variant-numeric: tabular-nums; }

.finish { border: 1px solid var(--line); background: none; border-radius: 14px; height: 50px; font-family: var(--display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

.pop {
  position: fixed; left: 50%; top: 38%; transform: translate(-50%, 0); pointer-events: none; z-index: 40;
  font-family: var(--display); font-weight: 700; font-size: 34px; color: var(--ki);
  text-shadow: 0 0 24px #ffb62799; white-space: nowrap; text-align: center;
  animation: rise 1.2s ease-out forwards;
}
.pop small { display: block; font-size: 15px; color: var(--scouter); text-shadow: none; letter-spacing: .1em; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 16px) scale(.9); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -60px) scale(1); } }
.aura { animation: aura 1.4s ease-out; }
@keyframes aura { 0% { box-shadow: 0 0 0 0 #ffb627aa; } 100% { box-shadow: 0 0 0 22px #ffb62700; } }

.sheet-bg { position: fixed; inset: 0; background: #05060cd0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 460px; max-height: 86%; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 12px;
}
.sheet h3 { margin: 0; font-family: var(--display); font-size: 20px; }
.sheet input[type="search"] { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px; }
.exlist { display: grid; gap: 0; }
.exlist div { display: grid; grid-template-columns: 1fr auto auto; gap: 4px; align-items: center; border-top: 1px solid var(--line); }
.exlist button.pick { border: 0; background: none; text-align: left; padding: 12px 2px; font-weight: 600; }
.exlist button.pick span { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--surface-2); border-radius: 12px; padding: 10px; display: grid; }
.stats b { font-family: var(--display); font-size: 20px; font-variant-numeric: tabular-nums; }
.ladder { display: grid; gap: 4px; }
.ladder div { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; font-size: 13px; padding: 4px 6px; border-radius: 8px; }
.ladder div.cur { background: var(--surface-2); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.bwrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bwrow input { width: 90px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 8px; text-align: right; font-family: var(--display); font-size: 18px; }
.strength { display: grid; gap: 2px; font-size: 13px; }
.strength div { display: grid; grid-template-columns: 1fr 70px 44px; gap: 8px; align-items: center; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--scouter); border-radius: 3px; }
.primary { border: 0; border-radius: 14px; height: 52px; background: var(--ki); color: #1a1100; font-family: var(--display); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.note { color: var(--muted); font-size: 12px; margin: 0; }

@media (prefers-reduced-motion: reduce) { .pop, .aura, .logbtn.holding { animation: none; } .pop { display: none; } }

/* ---------- App shell ---------- */
body { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs a {
  text-decoration: none; padding: 8px 16px; border-radius: 999px;
  font-family: var(--display); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 13px;
  color: var(--muted);
}
.tabs a[aria-current="page"] { background: var(--surface-2); color: var(--fg); }
.tabs form { display: contents; }
.tabs button { color: var(--muted); }
.flash { max-width: 430px; margin: 0 auto 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.flash.alert { border-color: var(--hot); }
.flash.notice { border-color: var(--scouter); }
.sync { text-align: center; font-size: 12px; color: var(--muted); min-height: 16px; }
.sync.warn { color: var(--ki); }

/* ---------- Simple pages ---------- */
.page { max-width: 430px; margin: 0 auto; display: grid; gap: 16px; }
.page h1 { font-family: var(--display); font-size: 30px; margin: 8px 0 0; line-height: 1.1; text-wrap: balance; }
.page h1 b { color: var(--scouter); }
.page .lede { color: var(--muted); margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field input { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px; font-size: 16px; min-width: 0; }
.errors { color: var(--hot); margin: 0; padding-left: 18px; }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board-list li { display: grid; grid-template-columns: 24px 1fr auto auto; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; }
.board-list li.me { background: var(--ki-dim); }
.board-list .rk { color: var(--muted); font-family: var(--display); }
.board-list .v { font-family: var(--display); font-variant-numeric: tabular-nums; color: var(--ki); }
.board-list form { display: contents; }
.center { text-align: center; }

/* ---------- Stats ---------- */
.statspage .card { gap: 10px; }
.stat-head { display: flex; justify-content: space-between; align-items: baseline; }
.hero { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.hero b { font-family: var(--body); font-weight: 600; font-size: 48px; line-height: 1; }
.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--scouter); }
.delta.down { color: var(--muted); }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--scouter); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tiles div { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; display: grid; }
.tiles b { font-size: 20px; font-weight: 600; }
.hbars { display: grid; gap: 6px; font-size: 13px; }
.hbars div { display: grid; grid-template-columns: minmax(0, 9em) 1fr auto; gap: 10px; align-items: center; }
.hbars div > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars .bar { height: 8px; border-radius: 4px; }
.hbars .bar i { border-radius: 0 4px 4px 0; }
.hbars .num { min-width: 4.5em; text-align: right; }
.chartbox { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tierline { stroke: var(--muted); stroke-opacity: .5; stroke-width: 1; }
.chart .tick { font-size: 10px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .val { font-size: 11px; font-weight: 600; fill: var(--fg); }
.chart .trend { fill: none; stroke: var(--scouter); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .wash { fill: var(--scouter); fill-opacity: .1; }
.chart .enddot { fill: var(--scouter); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--fg); stroke-opacity: .4; stroke-width: 1; }
.chart .col path { fill: #3a4160; }
.chart .col.on path { fill: var(--ki); }
.chart .col.hover path, .chart .col:focus-visible path { fill: #59618a; }
.chart .col.on.hover path { fill: #ffc85a; }
.chart .col:focus { outline: none; }
.chart .col { cursor: pointer; }
.tip {
  position: absolute; z-index: 5; pointer-events: none; white-space: nowrap;
  background: var(--fg); color: var(--bg); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px;
}
.tableview summary { color: var(--blue); font-size: 13px; font-weight: 600; cursor: pointer; }
.tableview table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.tableview th { text-align: left; color: var(--muted); font-weight: 600; }
.tableview td, .tableview th { padding: 4px 2px; border-top: 1px solid var(--line); }
.tableview td:not(:first-child), .tableview th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.primary.strava { display: flex; align-items: center; justify-content: center; text-decoration: none; background: #fc5200; color: #fff; }
.addrow2 form { display: contents; }
