:root {
  --bg: #0e1114;
  --panel: #171c21;
  --panel-2: #1e252c;
  --line: #2a333c;
  --text: #e8edf2;
  --muted: #8a97a3;
  --accent: #f2a33c;
  --accent-ink: #1a1206;
  --good: #4cc38a;
  --warn: #e5a13b;
  --danger: #e5533b;
  --radius: 14px;
}

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

/* Interactive controls: no text selection / long-press callout — rapid tapping
   must never start a selection that swallows the next tap. */
.stepper, .stepbtn, .btn, .pip, .daychip, .card-head, nav button, .ls, .setmeta, .ghost {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  height: 100%;
  overscroll-behavior-y: none;
}

button { font-family: inherit; }

#app { max-width: 560px; margin: 0 auto; padding: 12px 14px calc(84px + env(safe-area-inset-bottom)); }

/* ── Header ── */
.top {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 8px 2px 12px;
}
.top h1 { font-size: 20px; margin: 0; letter-spacing: 0.5px; }
.top h1 b { color: var(--accent); }
.top .date { color: var(--muted); font-size: 13px; }

/* ── Day strip ── */
.daystrip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.daystrip::-webkit-scrollbar { display: none; }
.daychip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); border-radius: 999px; padding: 8px 13px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.daychip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.daychip.today-dot { position: relative; }
.daychip.today-dot::after {
  content: ""; position: absolute; top: 4px; right: 8px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--good);
}
.daychip.active.today-dot::after { background: var(--accent-ink); }

.daytitle { display: flex; align-items: center; gap: 8px; margin: 4px 2px 12px; }
.daytitle h2 { font-size: 17px; margin: 0; }
.kind { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; }
.kind.hard { background: rgba(229, 83, 59, 0.16); color: #ff8a72; }
.kind.easy { background: rgba(76, 195, 138, 0.14); color: var(--good); }
.kind.rest { background: rgba(138, 151, 163, 0.14); color: var(--muted); }

/* ── Exercise cards ── */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  cursor: pointer; user-select: none;
}
.card-head .name { flex: 1; font-weight: 600; font-size: 15px; line-height: 1.3; }
.card-head .rx { color: var(--muted); font-size: 13px; white-space: nowrap; }
.flag { color: var(--warn); font-size: 15px; }
.prog { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.prog.full { color: var(--good); font-weight: 700; }

.card-body { border-top: 1px solid var(--line); padding: 14px; display: none; }
.card.open .card-body { display: block; }

.note {
  background: rgba(229, 161, 59, 0.1); border: 1px solid rgba(229, 161, 59, 0.35);
  color: #ffd9a0; font-size: 13px; line-height: 1.4;
  border-radius: 10px; padding: 9px 11px; margin-bottom: 12px;
}
.note.plain { background: var(--panel-2); border-color: var(--line); color: var(--muted); }

.ghost { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; opacity: 0.8; }
.ghost b { color: var(--muted); }

/* ── Steppers ── */
.steppers { display: flex; gap: 10px; margin-bottom: 12px; }
.stepper { flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.stepper .lab { font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); text-align: center; margin-bottom: 4px; }
.stepper .row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.stepper .val { flex: 1; min-width: 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }
.stepper .val small { font-size: 12px; color: var(--muted); font-weight: 500; }
.stepbtn {
  flex: 0 0 42px; width: 42px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 20px; font-weight: 700;
  cursor: pointer; touch-action: manipulation;
}
.stepbtn:active { background: var(--line); }

.setmeta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.setmeta .which { font-size: 13px; color: var(--muted); font-weight: 600; }

.btn {
  display: block; width: 100%; padding: 14px; border-radius: 12px; border: none;
  background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 700;
  cursor: pointer; touch-action: manipulation;
}
.btn:active { filter: brightness(0.92); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.done-on { background: var(--good); color: #06180f; }
.btn:disabled { opacity: 0.5; }

.loggedsets { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; }
.loggedsets .ls {
  display: flex; justify-content: space-between; font-size: 13.5px;
  color: var(--muted); font-variant-numeric: tabular-nums;
  background: var(--panel-2); border-radius: 8px; padding: 7px 11px; cursor: pointer;
}
.loggedsets .ls b { color: var(--text); font-weight: 600; }

.restcard { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 15px; }

/* ── Check-in ── */
.section-title { font-size: 13px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); margin: 18px 2px 8px; font-weight: 700; }
.ratingrow { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.ratingrow .lab { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.ratingrow .lab span:last-child { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.pips { display: flex; gap: 7px; }
.pip {
  flex: 1; height: 42px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted); font-size: 15px; font-weight: 700; cursor: pointer;
  touch-action: manipulation;
}
.pip.sel { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.savebar { margin-top: 14px; }
.savedmsg { text-align: center; color: var(--good); font-size: 13.5px; margin-top: 10px; min-height: 18px; }

/* ── Progress ── */
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; }
.stat .k { font-size: 11.5px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.chartcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.chartcard h3 { margin: 0 0 10px; font-size: 14px; }
.chartcard svg { width: 100%; height: auto; display: block; }
.axis-label { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

.bestlist { display: flex; flex-direction: column; gap: 7px; }
.best {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.best .n { font-size: 14px; font-weight: 600; flex: 1; line-height: 1.3; }
.best .w { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.best .d { font-size: 11.5px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 14px; }

/* ── Settings ── */
.settingsrow { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.settingsrow h3 { margin: 0 0 4px; font-size: 15px; }
.settingsrow p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.settingsrow .btn + .btn { margin-top: 8px; }
.kv { display: flex; justify-content: space-between; font-size: 14px; }
.kv span:last-child { color: var(--muted); }

/* ── Bottom nav ── */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: rgba(14, 17, 20, 0.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav button {
  flex: 1; max-width: 140px; background: none; border: none; color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 6px 2px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  touch-action: manipulation;
}
nav button .ic { font-size: 20px; line-height: 1; }
nav button.active { color: var(--accent); }

/* ── Login overlay ── */
#login {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#login .box { width: 100%; max-width: 340px; text-align: center; }
#login h1 { font-size: 26px; margin: 0 0 4px; }
#login h1 b { color: var(--accent); }
#login p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
#login input {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 16px; margin-bottom: 10px;
  text-align: center;
}
#login .err { color: var(--danger); font-size: 13.5px; min-height: 18px; margin-top: 10px; }

.toast {
  position: fixed; bottom: calc(92px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 40;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 14px; padding: 9px 18px; font-size: 13.5px;
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
  max-width: min(92vw, 520px); text-align: center;
}
.toast.show { opacity: 1; }
.toast.offline { color: #ffd9a0; border-color: rgba(229, 161, 59, 0.4); }

.hidden { display: none !important; }
