/* Rack — visual system
   Ground: gym rubber floor under low light. Numbers are the hero: stamped,
   tight, tabular. Colour is functional — plate colours mean plate weights,
   red means the heavy lift, nothing is coloured for decoration. */

:root {
  --floor: #14171c;
  --rack:  #1b2029;
  --rail:  #262d38;
  --edge:  #333c4a;
  --chalk: #f2efe9;
  --steel: #8b94a2;
  --dim:   #5d6673;
  --iron:  #c4342b;
  --brass: #c9922e;
  --go:    #4e9e6a;

  --p25:   #c4342b;
  --p20:   #2d5fa8;
  --p15:   #d9a21b;
  --p10:   #2e7d4f;
  --p5:    #e8e4dc;
  --p2:    #98a1ae;
  --p1:    #646d7a;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --pad: 16px;
  --r: 10px;
  --tabs: calc(58px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--floor);
  color: var(--chalk);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: var(--tabs); }

button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--chalk); }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---- shared bits ------------------------------------------------------- */

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--steel);
}

.num {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.screen { display: none; padding: 0 var(--pad) 28px; }
.screen.on { display: block; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--floor) 72%, transparent);
  padding: calc(env(safe-area-inset-top) + 14px) var(--pad) 12px;
  margin: 0 calc(var(--pad) * -1) 4px;
  display: flex; align-items: baseline; gap: 10px;
}
.topbar h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.topbar .spacer { flex: 1; }

.sync {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--dim);
  display: flex; align-items: center; gap: 6px;
}
.sync::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--dim);
}
.sync[data-s="ok"]::before      { background: var(--go); }
.sync[data-s="pending"]::before { background: var(--brass); }
.sync[data-s="off"]::before     { background: var(--iron); }

.card {
  background: var(--rack);
  border: 1px solid var(--rail);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 12px;
}

.btn {
  display: block; width: 100%;
  padding: 15px; border-radius: var(--r);
  background: var(--rail); border: 1px solid var(--edge);
  font-weight: 650; text-align: center;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--chalk); color: var(--floor); border-color: var(--chalk); }
.btn.quiet { background: none; border-color: var(--rail); color: var(--steel); font-weight: 500; }
.btn.danger { background: none; border-color: var(--iron); color: var(--iron); }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.muted { color: var(--steel); font-size: 14px; }
.tiny { font-size: 12px; color: var(--dim); }

/* ---- session header ---------------------------------------------------- */

.plan-head { padding: 4px 0 14px; }
.plan-head .slot {
  font-size: 40px; line-height: 1;
  display: flex; align-items: baseline; gap: 12px;
}
.plan-head .slot em {
  font-style: normal; font-size: 15px; font-weight: 600;
  letter-spacing: 0; color: var(--steel);
}
.plan-head .meta { margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }

.toggle {
  display: flex; align-items: center; gap: 10px;
  background: var(--rack); border: 1px solid var(--rail);
  border-radius: var(--r); padding: 12px 14px; width: 100%;
  margin-bottom: 12px; text-align: left;
}
.toggle .box {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  border: 1.5px solid var(--edge);
  display: grid; place-items: center;
  font-size: 13px; color: var(--floor);
}
.toggle[aria-pressed="true"] { border-color: var(--iron); }
.toggle[aria-pressed="true"] .box { background: var(--iron); border-color: var(--iron); color: var(--chalk); }
.toggle .lbl { flex: 1; font-weight: 600; font-size: 15px; }

/* ---- exercise rows ----------------------------------------------------- */

.ex {
  border: 1px solid var(--rail);
  border-radius: var(--r);
  margin-bottom: 8px;
  background: var(--rack);
  overflow: hidden;
}
.ex.open { border-color: var(--edge); }
.ex.done { opacity: 0.55; }

.ex-head {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px; text-align: left;
}
.ex-head .idx {
  font-family: var(--mono); font-size: 11px; color: var(--dim);
  width: 14px; flex: none;
}
.ex-head .nm { flex: 1; font-weight: 620; font-size: 15.5px; letter-spacing: -0.01em; }
.ex-head .pres { font-family: var(--mono); font-size: 12px; color: var(--steel); }
.ex-head .dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--edge);
}
.ex.done .ex-head .dot { background: var(--go); border-color: var(--go); }
.ex.part .ex-head .dot { background: var(--brass); border-color: var(--brass); }
.ex.main .ex-head .nm { color: var(--chalk); }
.ex.main .ex-head .idx { color: var(--iron); }

.ex-body { padding: 0 14px 14px; }

/* ---- the target readout (signature) ------------------------------------ */

.target { text-align: center; padding: 6px 0 12px; }
.target .kg {
  font-size: 68px; line-height: 0.9;
  font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -0.05em;
}
.target .kg small { font-size: 20px; letter-spacing: 0; color: var(--steel); margin-left: 6px; font-weight: 600; }
.target .kg.none { font-size: 28px; color: var(--steel); letter-spacing: -0.02em; }
.target .sub { margin-top: 6px; }
.target .cue {
  margin-top: 10px; font-size: 13px; color: var(--brass);
  display: inline-block; padding: 5px 10px;
  border: 1px solid rgba(201,146,46,0.3); border-radius: 100px;
}
.target .cue.up { color: var(--go); border-color: rgba(78,158,106,0.35); }
.target .cue.down { color: var(--iron); border-color: rgba(196,52,43,0.35); }

/* plate strip — real IWF colours, per side */
.plates { display: flex; align-items: flex-end; justify-content: center; gap: 3px; min-height: 46px; margin: 4px 0 2px; }
.plates .bar {
  width: 30px; height: 3px; background: var(--dim); border-radius: 2px;
  align-self: center;
}
.plate {
  width: 20px; border-radius: 3px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  color: rgba(0,0,0,0.72); padding-bottom: 2px;
}
.plate.light { color: rgba(255,255,255,0.85); }
.plates .cap { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-left: 6px; align-self: center; }

.ramp { font-family: var(--mono); font-size: 11.5px; color: var(--dim); text-align: center; margin-bottom: 12px; }

/* ---- set logging ------------------------------------------------------- */

.set {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--rail);
}
.set .no { font-family: var(--mono); font-size: 10px; color: var(--dim); width: 30px; letter-spacing: 0.08em; }
.set input {
  flex: 1; min-width: 0; width: 100%;
  background: var(--floor); border: 1px solid var(--rail);
  border-radius: 8px; padding: 11px 8px;
  font-size: 17px; font-variant-numeric: tabular-nums; font-weight: 650;
  text-align: center; -moz-appearance: textfield;
}
.set input::-webkit-outer-spin-button, .set input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.set input::placeholder { color: var(--dim); font-weight: 400; }
.set .x { color: var(--dim); font-size: 13px; }
.set .tick {
  width: 46px; flex: none; height: 42px; border-radius: 8px;
  border: 1px solid var(--edge); display: grid; place-items: center;
  font-size: 16px; color: var(--dim);
}
.set.logged .tick { background: var(--go); border-color: var(--go); color: var(--floor); }
.set.logged input { border-color: transparent; background: transparent; color: var(--steel); }
.set.flash { animation: flash 0.4s ease; }
@keyframes flash { from { background: rgba(78,158,106,0.18); } to { background: transparent; } }

.last { font-family: var(--mono); font-size: 11px; color: var(--dim); padding: 8px 0 0; }

/* ---- rest timer -------------------------------------------------------- */

.rest {
  position: fixed; left: 0; right: 0; bottom: var(--tabs); z-index: 30;
  background: var(--rail); border-top: 1px solid var(--edge);
  padding: 11px var(--pad);
  display: none; align-items: center; gap: 14px;
}
.rest.on { display: flex; }
.rest .t { font-size: 26px; font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -0.03em; width: 84px; }
.rest .t.over { color: var(--go); }
.rest .track { flex: 1; height: 4px; background: var(--floor); border-radius: 2px; overflow: hidden; }
.rest .fill { height: 100%; background: var(--brass); width: 100%; }
.rest .fill.over { background: var(--go); }
.rest button { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--steel); padding: 6px; }

/* ---- tabs -------------------------------------------------------------- */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: var(--rack); border-top: 1px solid var(--rail);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; padding: 9px 0 8px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--dim);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tabs button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tabs button.on { color: var(--chalk); }

/* ---- history / progress ------------------------------------------------ */

.hist {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--rail); width: 100%; text-align: left;
}
.hist .d { font-family: var(--mono); font-size: 11px; color: var(--steel); width: 60px; flex: none; letter-spacing: 0.04em; }
.hist .s { font-weight: 800; font-size: 17px; width: 18px; flex: none; }
.hist .info { flex: 1; font-size: 13.5px; color: var(--steel); }
.hist .vol { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.hist .box { color: var(--iron); font-size: 11px; font-family: var(--mono); }

.chart { width: 100%; height: auto; display: block; margin: 6px 0 2px; }
.chart .ln { fill: none; stroke: var(--chalk); stroke-width: 1.75; stroke-linejoin: round; }
.chart .avg { fill: none; stroke: var(--brass); stroke-width: 2; }
.chart .pt { fill: var(--chalk); }
.chart .gr { stroke: var(--rail); stroke-width: 1; }
.chart .lb { fill: var(--dim); font-family: var(--mono); font-size: 9px; }

.pick {
  width: 100%; background: var(--floor); border: 1px solid var(--rail);
  border-radius: 8px; padding: 12px; font-size: 16px; margin-bottom: 12px;
  -webkit-appearance: none; appearance: none;
}

.stat { display: flex; gap: 20px; margin: 10px 0 2px; }
.stat div .v { font-size: 24px; font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -0.03em; }

.empty { text-align: center; padding: 44px 20px; color: var(--dim); }
.empty strong { display: block; color: var(--steel); font-size: 15px; margin-bottom: 6px; font-weight: 600; }

/* ---- gate -------------------------------------------------------------- */

.gate {
  position: fixed; inset: 0; z-index: 100; background: var(--floor);
  display: none; flex-direction: column; justify-content: center;
  padding: 32px 28px calc(32px + env(safe-area-inset-bottom));
}
.gate.on { display: flex; }
.gate h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin: 0 0 6px; }
.gate p { color: var(--steel); font-size: 14.5px; margin: 0 0 26px; }
.gate input {
  width: 100%; background: var(--rack); border: 1px solid var(--rail);
  border-radius: var(--r); padding: 16px; font-size: 22px; text-align: center;
  letter-spacing: 0.4em; font-variant-numeric: tabular-nums; margin-bottom: 12px;
}
.gate .err { color: var(--iron); font-size: 13.5px; min-height: 20px; margin-top: 10px; text-align: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs) + 16px); z-index: 60;
  background: var(--chalk); color: var(--floor);
  padding: 10px 16px; border-radius: 100px; font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.toast.on { opacity: 1; }

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

/* ---- sheet ------------------------------------------------------------- */

.sheet {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(6, 8, 11, 0.7);
  display: none; align-items: flex-end;
}
.sheet.on { display: flex; }
.sheet .panel {
  width: 100%;
  background: var(--rack);
  border-top: 1px solid var(--edge);
  border-radius: 16px 16px 0 0;
  padding: 20px var(--pad) calc(20px + env(safe-area-inset-bottom));
  animation: rise 0.18s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0.6; } }

/* ---- forms -------------------------------------------------------------- */

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--steel); margin-bottom: 6px;
}
.field input, .field select {
  width: 100%; background: var(--floor); border: 1px solid var(--rail);
  border-radius: 8px; padding: 12px; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.field input[type="number"] { font-variant-numeric: tabular-nums; font-weight: 650; }
.field input::placeholder { color: var(--dim); font-weight: 400; }
.row .field { margin-bottom: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 8px 13px; border-radius: 100px;
  border: 1px solid var(--rail); background: var(--floor);
  font-size: 13.5px; color: var(--steel); text-transform: capitalize;
}
.chip.on { border-color: var(--iron); color: var(--chalk); background: rgba(196, 52, 43, 0.14); }

.person {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 0; border-bottom: 1px solid var(--rail);
}
.person:last-of-type { border-bottom: 0; }
.person .av {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: var(--rail); border: 1px solid var(--edge);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.person .pi { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.person .pn { font-weight: 620; font-size: 15px; }

.sheet .panel { max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- restrictions, cues, flags ------------------------------------------ */

.card.alert { border-color: var(--iron); background: rgba(196, 52, 43, 0.07); }

.formcue {
  font-size: 13px; color: var(--brass); line-height: 1.5;
  border-left: 2px solid rgba(201, 146, 46, 0.4);
  padding: 2px 0 2px 10px; margin: 0 0 12px;
}

.pick.warn { border-color: var(--iron); color: var(--brass); }

.hist .pain { color: var(--iron); font-size: 9px; letter-spacing: 1px; flex: none; }

.toggle .lbl .tiny { font-weight: 400; display: block; margin-top: 3px; }
