/* Gym-floor palette: slate rubber, chalk, competition-plate yellow. */
@font-face { font-family: "Plate"; src: url("/fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plate"; src: url("/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plate"; src: url("/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --floor: #1b1f24;      /* rubber floor */
  --panel: #252b32;
  --panel-2: #2f363e;
  --line: #3a424b;
  --chalk: #ecebe6;
  --steel: #8d98a3;
  --plate: #e8b931;      /* this set / primary action */
  --plate-ink: #1b1f24;
  --drop: #d9473b;       /* down rating, destructive */
  --up: #6fbf73;         /* up rating */
  --radius-s: 8px;
  --radius-l: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --display: "Plate", "Arial Narrow", sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--floor); color: var(--chalk); }
body {
  font: 17px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--plate); outline-offset: 2px; }
a { color: var(--plate); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
#app { max-width: 480px; margin: 0 auto; padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 96px); }
.topline { display: flex; justify-content: space-between; align-items: baseline; color: var(--steel); font-size: 15px; }
.title { font: 700 44px/0.95 var(--display); margin: 6px 0 4px; letter-spacing: 0.2px; }
.subtitle { color: var(--steel); font-size: 15px; margin: 0 0 16px; }
.note { color: var(--steel); font-size: 14px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(27, 31, 36, 0.96); border-top: 1px solid var(--line);
  padding: 6px 8px calc(var(--safe-b) + 6px);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--steel); text-decoration: none; font-size: 12px; padding: 6px 0; border-radius: var(--radius-s);
}
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a[aria-current="page"] { color: var(--chalk); }
.tabbar a[aria-current="page"] svg { color: var(--plate); }

/* ---------- day header controls ---------- */
.daynav { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; align-items: center; margin: 8px 0 14px; }
.iconbtn { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn:disabled { opacity: 0.35; }
.focusbtn {
  height: 48px; border-radius: 24px; border: 1px solid var(--line); background: var(--panel);
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px;
}
.focusbtn svg { width: 16px; height: 16px; color: var(--steel); }
.banner { border-radius: var(--radius-s); background: var(--panel); border-left: 4px solid var(--plate); padding: 10px 12px; margin: 0 0 14px; font-size: 15px; }
.banner.warn { border-left-color: var(--drop); }

/* ---------- exercise blocks ---------- */
.ex { background: var(--panel); border-radius: var(--radius-l); padding: 14px 14px 12px; margin-bottom: 12px; }
.ex.paired { border-radius: var(--radius-l) var(--radius-l) 4px 4px; margin-bottom: 3px; }
.ex.partner { border-radius: 4px 4px var(--radius-l) var(--radius-l); }
.pairtag { font-size: 13px; color: var(--plate); margin: 0 0 6px; }
.ex-head { display: flex; gap: 10px; align-items: flex-start; }
.ex-name { flex: 1; min-width: 0; }
.ex-cat { color: var(--steel); font-size: 14px; }
.ex-title { font: 600 26px/1.05 var(--display); margin: 2px 0 0; background: none; border: 0; padding: 0; text-align: left; }
.ex-title svg { width: 14px; height: 14px; color: var(--steel); margin-left: 4px; vertical-align: 2px; }
.video { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); color: var(--chalk); }
.video svg { width: 20px; height: 20px; }

.target { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 8px; }
.target .wt { font: 700 56px/0.9 var(--display); font-variant-numeric: tabular-nums; }
.target .unit { font: 500 22px var(--display); color: var(--steel); }
.target .x { font: 600 24px var(--display); color: var(--steel); }
.target .goal { font: 600 26px var(--display); }
.target .set-rm { font-size: 15px; height: 44px; padding: 0 14px; border-radius: 22px; border: 1px dashed var(--plate); background: none; color: var(--plate); }
.goal-long { color: var(--steel); font-size: 14px; margin: -2px 0 10px; }

.sets { display: grid; gap: 6px; }
.set { display: grid; grid-template-columns: 34px 1fr 1fr 52px; gap: 6px; align-items: center; }
.set .n { font: 600 20px var(--display); color: var(--steel); text-align: center; }
.set label { position: relative; display: block; }
.set label span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--steel); font-size: 13px; pointer-events: none; }
.set input {
  width: 100%; height: 52px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--floor);
  font: 600 26px var(--display); font-variant-numeric: tabular-nums; padding: 0 40px 0 12px;
}
.set input::placeholder { color: #5d6771; }
.set .done {
  height: 52px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--floor); display: grid; place-items: center;
}
.set .done svg { width: 24px; height: 24px; color: #5d6771; }
.set.is-done .done { background: var(--plate); border-color: var(--plate); }
.set.is-done .done svg { color: var(--plate-ink); }
.set.is-next input { border-color: var(--plate); }

.rate { margin-top: 12px; }
.rate-q { font-size: 14px; color: var(--steel); margin: 0 0 6px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--floor); border-radius: var(--radius-s); padding: 3px; gap: 3px; }
.seg button { height: 44px; border: 0; border-radius: 6px; background: none; color: var(--steel); font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--chalk); }
.seg button.down[aria-pressed="true"] { background: var(--drop); color: #fff; }
.seg button.up[aria-pressed="true"] { background: var(--up); color: var(--plate-ink); }

.rest-pill {
  position: fixed; left: 0; right: 0; bottom: 70px; z-index: 19;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; height: 46px; border: 0; background: var(--plate); color: var(--plate-ink); font-size: 15px;
}
.rest-pill b { font: 700 28px var(--display); font-variant-numeric: tabular-nums; min-width: 60px; text-align: center; }
.rest-pill small { font-size: 13px; opacity: 0.75; }
body.resting #app { padding-bottom: calc(var(--safe-b) + 150px); }

/* ---------- generic ---------- */
.card { background: var(--panel); border-radius: var(--radius-l); padding: 16px; margin-bottom: 12px; }
.card h2 { font: 600 24px var(--display); margin: 0 0 10px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 14px; color: var(--steel); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; height: 52px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--floor); padding: 0 14px; font-size: 17px;
}
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border-radius: 26px; border: 1px solid var(--line); background: var(--panel-2); font-size: 17px; font-weight: 600; }
.btn + .btn { margin-top: 10px; }
.btn.primary { background: var(--plate); color: var(--plate-ink); border-color: var(--plate); }
.btn.danger { background: none; color: var(--drop); border-color: var(--drop); }
.btn.quiet { background: none; }
.btn svg { width: 20px; height: 20px; }
.btn:disabled { opacity: 0.5; }
.err { color: #ff8a80; font-size: 15px; margin: 8px 0 0; min-height: 1px; }
.ok { color: var(--up); font-size: 15px; margin: 8px 0 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .meta { color: var(--steel); font-size: 14px; }
.linkbtn { background: none; border: 0; color: var(--plate); padding: 8px 0; font-size: 16px; }
.linkbtn.danger { color: var(--drop); }

/* login */
.login { min-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 120px); display: flex; flex-direction: column; justify-content: center; }
.login .title { font-size: 64px; }
.login .or { text-align: center; color: var(--steel); margin: 14px 0; font-size: 14px; }

/* plan */
.meso-tabs, .week-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.meso-tabs::-webkit-scrollbar, .week-tabs::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); font-size: 15px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--chalk); color: var(--floor); border-color: var(--chalk); }
.dayrow { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; background: var(--panel); border-radius: var(--radius-l); padding: 12px 14px; margin-bottom: 8px; text-decoration: none; color: inherit; }
.dayrow .dnum { font: 700 34px var(--display); color: var(--steel); text-align: center; }
.dayrow .dfocus { font: 600 22px var(--display); }
.dayrow .dmeta { color: var(--steel); font-size: 14px; }
.dayrow .dstate { font-size: 14px; color: var(--steel); }
.dayrow .dstate.done { color: var(--plate); }
.restnote { color: var(--steel); font-size: 13px; margin: -2px 0 10px 70px; }
.coverage { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 15px; }
.coverage .bar { height: 8px; background: var(--plate); border-radius: 4px; margin-top: 6px; }
.coverage .muscle { display: grid; grid-template-columns: 120px 1fr 28px; gap: 10px; align-items: center; grid-column: 1 / -1; }
.coverage .muscle b { font: 600 18px var(--display); text-align: right; }

/* 10RM list */
.rm-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.rm-row:first-of-type { border-top: 0; }
.rm-row .rm-name { font-size: 16px; }
.rm-row .rm-cat { font-size: 13px; color: var(--steel); }
.rm-row input { height: 48px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--floor); padding: 0 12px; font: 600 24px var(--display); width: 100%; text-align: right; }
.rm-row.missing input { border-color: var(--plate); }

/* bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 86dvh; overflow-y: auto;
  background: var(--panel); border-radius: 20px 20px 0 0; padding: 10px 16px calc(var(--safe-b) + 16px);
  max-width: 480px; margin: 0 auto; animation: sheet-in 0.22s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font: 600 28px var(--display); margin: 0 0 4px; }
.sheet .sub { color: var(--steel); font-size: 15px; margin: 0 0 14px; }
.choice { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 54px; padding: 10px 14px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--floor); margin-bottom: 6px; text-align: left; font-size: 17px; }
.choice[aria-pressed="true"] { border-color: var(--plate); }
.choice small { color: var(--steel); font-size: 13px; display: block; }
.choice svg { width: 20px; height: 20px; color: var(--plate); flex: none; }
.scope { margin: 14px 0 6px; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.toast { position: fixed; left: 16px; right: 16px; top: calc(var(--safe-t) + 10px); z-index: 60; max-width: 448px; margin: 0 auto; background: var(--chalk); color: var(--floor); padding: 12px 16px; border-radius: var(--radius-s); font-size: 15px; }
.offline { position: fixed; top: calc(var(--safe-t) + 4px); right: 12px; z-index: 30; font-size: 12px; background: var(--panel-2); color: var(--steel); padding: 4px 10px; border-radius: 12px; }

/* admin table */
.admin-user .meta span + span::before { content: ", "; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--panel-2); color: var(--steel); margin-left: 6px; }
.pill.warn { background: var(--drop); color: #fff; }

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