:root {
  --bg: #101317;
  --card: #1a1f26;
  --card2: #232a33;
  --line: #2e3640;
  --text: #e8ecf1;
  --muted: #8b97a6;
  --accent: #4fb3ff;
  --accent-ink: #06121c;
  --good: #4cd98b;
  --warn: #f2b84b;
  --danger: #ff6b6b;
  --t1: #ff7a59;
  --t2: #b58cff;
  --t3: #4fd1c5;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(88px + env(safe-area-inset-bottom));
}

h1 { font-size: 26px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 10px; }
p { margin: 8px 0; }
.sub, .meta, .hint { color: var(--muted); font-size: 13px; }
.hint { font-weight: normal; }
.muted { color: var(--muted); }
.meta { display: block; }

button, .btn, input, select, textarea {
  font: inherit;
  color: inherit;
}
button, .btn {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:active { transform: scale(0.98); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.big { width: 100%; min-height: 56px; font-size: 18px; margin-top: 12px; }
button.small, a.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
a.small { color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; }
button.link { background: none; border: none; color: var(--accent); padding: 0 4px; min-height: 0; text-decoration: underline; }
button.icon { min-width: 44px; padding: 0; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.num { width: 72px; text-align: center; padding: 8px 4px; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }

.card, section.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card.row { width: 100%; text-align: left; justify-content: space-between; }

.banner.bad { background: #3a1717; border-color: #7a2c2c; color: #ffd3d3; }
.banner {
  background: #2b2413;
  border: 1px solid #5a4a1f;
  color: #f5dfa8;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.field > label .hint { text-transform: none; letter-spacing: 0; }

.seg { display: flex; gap: 5px; }
.seg button { flex: 1 1 0; min-width: 0; padding: 10px 2px; }
.seg button.on, .chip.on, .row.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 15px; }
.toggle input { width: 22px; height: 22px; min-height: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.chip {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 36px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
label.chip input { display: none; }

.list { display: flex; flex-direction: column; gap: 6px; }
.row { width: 100%; justify-content: space-between; text-align: left; }
.row .meta { text-align: right; margin-left: 12px; }
.row.on .meta { color: inherit; opacity: 0.75; }
.row.dim { opacity: 0.55; }
.row.add { color: var(--accent); justify-content: flex-start; }

.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--card2); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.badge.swapped { color: var(--warn); }
.badge.custom { color: var(--t2); }

.tier { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; color: #111; }
.tier.T1 { background: var(--t1); }
.tier.T2 { background: var(--t2); }
.tier.T3 { background: var(--t3); }

.bhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.bhead .chip { font-weight: 600; font-size: 15px; }
.dose { font-size: 13px; color: var(--muted); margin: 6px 0; }
.dose.met { color: var(--good); }
.dose.warn { color: var(--warn); }

.sets { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.set { display: flex; align-items: center; gap: 6px; }
.set .n { width: 20px; color: var(--muted); font-size: 14px; }
.set .u, .set .x { color: var(--muted); font-size: 14px; }
.set .meta { font-size: 12px; flex: 1; }
.set .check {
  margin-left: auto;
  width: 48px; height: 48px; padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
  font-size: 20px;
}
.set.done .check { background: var(--good); border-color: var(--good); color: #062512; }
.set.done input { opacity: 0.6; }

.brow { display: flex; gap: 8px; flex-wrap: wrap; }
details.cues, details.why { margin-top: 8px; color: var(--muted); font-size: 14px; }
details summary { cursor: pointer; }
details.why { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
details.why ul { padding-left: 18px; margin: 8px 0 0; }
details.why li { margin-bottom: 6px; }
details.why li.picked b { color: var(--text); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions > * { flex: 1 1 auto; }

.setlog { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.setlog:last-child { border-bottom: none; }
.setlog { flex-wrap: wrap; }
.setlog .grow { flex-basis: 100%; }
.setlog .meta { display: inline; }
.setlog select { width: 100%; min-height: 36px; padding: 4px 8px; font-size: 14px; }
.grow { flex: 1; min-width: 0; }
.pips { display: flex; gap: 4px; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.pip.on { background: var(--good); border-color: var(--good); }
.dayhead { font-weight: 700; margin-bottom: 4px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; font-size: 14px; }
.kv select { width: auto; }
.kv b { text-align: right; }

.search { margin-bottom: 12px; }
.exrow { display: flex; gap: 4px; align-items: stretch; margin-bottom: 6px; }
.exrow .name { flex: 1; flex-direction: column; align-items: flex-start; text-align: left; }
.exrow .name .meta { font-size: 12px; }

.planitem { display: flex; flex-direction: column; gap: 8px; }
.row2 { display: flex; gap: 6px; }
.row2 select:first-child { width: 80px; flex: none; }


#nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: rgba(16, 19, 23, 0.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
#nav button { flex: 1; background: none; border: none; border-radius: 0; min-height: 56px; color: var(--muted); font-size: 13px; }
#nav button.on { color: var(--accent); font-weight: 700; }

body.has-timer #app { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }

#timer {
  position: fixed; left: 0; right: 0;
  bottom: calc(57px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  background: var(--card2);
  border-top: 1px solid var(--line);
  overflow: hidden;
  z-index: 11;
}
#timer[hidden] { display: none; }
#timer .fill { position: absolute; inset: 0 auto 0 0; background: rgba(79, 179, 255, 0.18); transition: width 0.25s linear; }
#timer.over { background: #12361f; border-top-color: var(--good); }
#timer.over .fill { background: transparent; }
#timer .tbody { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
#timer .tmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#timer .tclock { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
#timer.over .tclock { color: var(--good); }
#timer .tlabel { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#timer .tbtns { display: flex; gap: 6px; }
#timer .tbtns button { min-width: 52px; padding: 8px 10px; }

.restchip {
  display: inline-flex; min-height: 30px; padding: 2px 10px; margin-top: 4px;
  font-size: 13px; border-radius: 999px; color: var(--accent);
}
.restbig { font-size: 44px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; margin: 8px 0 12px; }

#sheet {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 20;
}
#sheet[hidden] { display: none; }
#sheet .panel {
  position: relative;
  background: var(--card);
  width: 100%; max-width: 560px; max-height: 85vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}
#sheet .close { position: absolute; top: 10px; right: 10px; min-width: 40px; min-height: 40px; padding: 0; background: none; border: none; color: var(--muted); }
#sheet h3 { padding-right: 40px; }
#sheet details { margin: 8px 0; }

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  z-index: 30;
}
button.danger.solid { background: var(--danger); border-color: var(--danger); color: #2a0606; font-weight: 600; }
#sheet textarea { font: 12px/1.4 ui-monospace, Consolas, monospace; }

/* ---------- grouped lists (Settings, Week goals) ---------- */
.menu, .card.flush {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  padding: 0;
}
.menurow, .frow, .slotrow {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 58px;
  padding: 10px 14px;
  background: none; border: 0; border-radius: 0;
  border-bottom: 1px solid var(--line);
  text-align: left; justify-content: flex-start;
  cursor: pointer;
}
.menu > :last-child, .card.flush > :last-child { border-bottom: 0; }
.menurow .name, .frow .name, .slotrow .name { display: block; font-size: 16px; }
.menurow .meta, .frow .meta, .slotrow .meta { margin-top: 2px; }
.menurow.danger .name { color: var(--danger); }
.chev { color: var(--muted); font-size: 22px; line-height: 1; }
.frow select { width: auto; max-width: 52%; }
.frow input.num { width: 84px; flex: none; }

.switch {
  appearance: none; -webkit-appearance: none;
  flex: none; position: relative;
  width: 50px; height: 30px; min-height: 0; padding: 0;
  border-radius: 999px; border: 0;
  background: var(--line);
  transition: background 0.15s;
  cursor: pointer;
}
.switch::before {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(20px); background: var(--accent-ink); }

.label { display: flex; align-items: center; gap: 8px; margin: 18px 4px 8px; }
.pad { padding: 0 4px; }
header.top.sub { margin-bottom: 0; }
.back { background: none; border: 0; color: var(--accent); padding: 0; min-height: 40px; font-size: 16px; }
.pagetitle { margin: 0 0 14px; font-size: 24px; }
.sectionhead { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 8px; }
.sectionhead h3 { margin: 0; }
.muted.pad { padding: 14px; }
.titleinput { font-size: 18px; font-weight: 600; margin-bottom: 8px; }

/* ---------- session additions ---------- */
.addblock {
  width: 100%; min-height: 52px; margin-bottom: 12px;
  background: transparent; color: var(--accent);
  border: 1px dashed var(--line);
}
button.tier { border: 0; min-height: 32px; padding: 4px 10px; border-radius: 6px; color: #111; font-size: 12px; font-weight: 700; }
button.quiet { color: var(--muted); }
.tierseg { margin-bottom: 4px; }

.stepper { display: flex; align-items: center; gap: 16px; }
.stepper button { width: 52px; font-size: 22px; }
.stepper span { min-width: 2ch; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row2.fields { gap: 8px; }
.row2.fields .field { flex: 1; margin-bottom: 8px; }
.row2.fields input.num { width: 100%; }
.frow input.list { width: 130px; flex: none; text-align: right; }

/* ---------- adding exercises and equipment ---------- */
.chipinput {
  width: 104px; min-height: 36px; padding: 6px 12px;
  border-radius: 999px; border: 1px dashed var(--line);
  background: transparent; font-size: 14px;
}
.seg.radio label {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 6px 4px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-weight: normal; text-transform: none; letter-spacing: 0; color: var(--text);
  cursor: pointer;
}
.seg.radio input { display: none; }
.seg.radio label:has(input:checked) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.qahint { font-size: 14px; color: var(--muted); margin: -8px 0 12px; }
.qahint:empty { display: none; }

/* ---------- technique tier and readiness ---------- */
.tier.TECH { background: #e9c46a; }
.sub.ready { color: var(--warn); margin-top: 2px; }
.sub.ready.good { color: var(--good); }

/* ---------- FitNotes import ---------- */
.fnrow .menurow .meta { display: block; }
.fnrow.open { background: var(--card2); }
.fnedit { padding: 4px 14px 14px; border-bottom: 1px solid var(--line); }
.fnedit .field { margin-bottom: 10px; }
label.btn.fnpick { width: 100%; min-height: 56px; font-size: 18px; margin-top: 12px; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.libarch { margin: -4px 0 12px; }

/* ---------- suggested goals ---------- */
.sectionhead .brow { gap: 6px; }
.gsline { display: flex; align-items: stretch; }
.gsline .gsinc { width: 22px; height: 22px; min-height: 0; margin: 0 0 0 14px; align-self: center; flex: none; }
.gsline .menurow { flex: 1; min-width: 0; }
.fnrow.off .name, .fnrow.off .tier { opacity: 0.5; }
.kv.over b { color: var(--warn); }

/* ---------- supersets, pause/resume ---------- */
.hbtns { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.block.haspair { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.block.paired { margin-top: 0; border-top: 1px dashed var(--line); border-top-left-radius: 0; border-top-right-radius: 0; border-left: 3px solid var(--accent); }
.sslabel { font-size: 13px; color: var(--accent); margin-bottom: 6px; }
.pairidea { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 14px; }
.pairidea .meta { display: block; }
.card.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- mobility ---------- */
.tier.MOB { background: #7fd1c2; color: #111; border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.block.mob .bhead { align-items: center; }
.mobname { font-weight: 600; }
.block.mob input.num { width: 56px; flex: none; }
.block.mob input.num.wide { width: auto; flex: 1 1 0; min-width: 0; }
.block.mob .set .check { flex: none; margin-left: auto; }
.mobnote { width: 100%; margin: 8px 0 4px; font-size: 14px; }
.addrow { display: flex; gap: 8px; }
.addrow .addblock { flex: 1; }
.libmode { margin-bottom: 10px; }
.badge.mobility { background: #7fd1c2; color: #111; }

/* ---------- hold timer ---------- */
.set .go {
  flex: none; width: 40px; height: 40px; min-height: 0; padding: 0;
  border-radius: 50%; color: var(--accent); font-size: 15px;
}
.set .go.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.block.mob .set .go { margin-left: 2px; }
#timer.prep { border-top-color: var(--warn); }
#timer.prep .fill { background: rgba(242, 184, 75, 0.18); }
#timer.prep .tclock { color: var(--warn); }
#timer.work { border-top-color: var(--accent); }
#timer.work .tclock { color: var(--accent); }

/* ---------- history ---------- */
.histhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.histex { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.histex .tier { flex: none; min-width: 42px; text-align: center; }
.histex .grow { min-width: 0; display: flex; flex-direction: column; }
.histex .meta { overflow-wrap: anywhere; }

/* ---------- warm-up sets ---------- */
.set.warm .n { color: var(--warn); font-weight: 700; }
.set.warm .check { border-style: dashed; }
.set.warm.done .check { background: var(--card2); border: 2px solid var(--warn); color: var(--warn); }

/* ---------- focused workouts ---------- */
.focusgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.focusgrid button { min-height: 48px; }
.focusgrid button.lean { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.focusoffer { border-color: var(--accent); }
.focusoffer .focusgrid { margin-top: 10px; }
.badge.focus { color: var(--accent); }

/* ---------- programs (Air Alert) ---------- */
.card.prog { border-color: var(--t3); display: flex; flex-direction: column; gap: 6px; }
.card.prog .good { color: var(--good); }
.card.prog .brow select, .card .brow select { width: auto; min-height: 40px; padding: 4px 8px; font-size: 14px; }
.tablewrap { overflow-x: auto; }
.progchart { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.progchart th, .progchart td { padding: 6px 2px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.progchart thead th { color: var(--muted); font-weight: 600; font-size: 12px; }
.progchart tr.cur { background: rgba(79, 179, 255, 0.14); }
.progchart tr.full td:nth-last-child(2) { color: var(--good); }
.progchart input.vert { width: 38px; min-height: 30px; padding: 2px 4px; font-size: 13px; text-align: center; }

/* Onboarding: compact times-a-week steppers in a row */
.stepper.small { gap: 8px; }
.stepper.small button { width: 40px; padding: 6px 0; font-size: 18px; }
.stepper.small span { font-size: 18px; }

/* Onboarding hides the tab bar */
nav[hidden] { display: none !important; }
