:root {
  --bg: #121214;
  --card: #1d1d21;
  --card2: #26262b;
  --line: #33333a;
  --text: #f2f2f4;
  --muted: #9a9aa3;
  --accent: #ff9f0a;
  --accent-ink: #1a1200;
  --warm: #64d2ff;
  --fail: #ff453a;
  --drop: #bf5af2;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 640px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(90px + env(safe-area-inset-bottom));
}
h1 { font-size: 26px; margin: 4px 0 14px; letter-spacing: -0.02em; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--fail); }

/* buttons & inputs */
.btn, .ib {
  font: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.btn { min-height: 44px; padding: 0 16px; font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--fail); background: transparent; border-color: #5a2a28; margin-top: 28px; width: 100%; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn:disabled, .ib:disabled { opacity: .35; cursor: default; }
.ib { min-width: 36px; height: 36px; padding: 0 8px; font-size: 14px; background: transparent; border-color: transparent; color: var(--muted); }
.ib:active { background: var(--card2); }
input, select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; min-height: 44px; padding: 0 12px; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { min-height: 0; width: 22px; height: 22px; accent-color: var(--accent); }
.row { display: flex; gap: 8px; margin-top: 14px; }
.row input { flex: 1; }

/* layout bits */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.head h1 { margin-bottom: 8px; overflow-wrap: anywhere; }
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; }
.card.link { display: block; color: var(--text); }
.card.link:active { background: var(--card2); }
.card-title { font-weight: 650; font-size: 17px; margin-bottom: 2px; }
.card-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

.daybar { display: flex; gap: 8px; margin-bottom: 14px; }
.daybar input { flex: 1; }
.daybar .btn { padding: 0 14px; }

/* exercise card */
.ex { margin-bottom: 12px; scroll-margin-top: 12px; }
.ex.flash { box-shadow: 0 0 0 2px var(--accent); }
.ex-name { color: var(--text); font-weight: 650; font-size: 17px; }
.prev { margin-top: 4px; }
.sets { margin-top: 8px; }
.set {
  display: grid; grid-template-columns: 30px 1fr auto auto; align-items: center; gap: 6px;
  min-height: 40px; border-top: 1px solid var(--line);
}
.set .lbl {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card2); font-size: 13px; font-weight: 700;
}
.set .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.set .tag { font-size: 12px; color: var(--muted); }
.set .acts { display: flex; }
.set.k-warmup .lbl { color: var(--warm); }
.set.k-warmup .val { color: var(--muted); font-weight: 500; }
.set.k-warmup .tag { color: var(--warm); }
.set.k-failure .lbl, .set.k-failure .tag { color: var(--fail); }
.set.k-drop { padding-left: 18px; grid-template-columns: 30px 1fr auto auto; }
.set.k-drop .lbl { background: transparent; color: var(--drop); }
.set.k-drop .tag { color: var(--drop); }

.add { display: grid; grid-template-columns: 76px auto 60px minmax(0, 1fr) auto; gap: 6px; align-items: center; margin-top: 10px; }
.add .x { color: var(--muted); }
.add input { text-align: center; padding: 0 6px; width: 100%; }
.add select { padding: 0 6px; width: 100%; }
.add .btn { padding: 0 14px; font-size: 20px; }
.add.inline { grid-template-columns: 76px auto 60px minmax(0, 1fr) auto auto; margin: 6px 0; }
.add.inline.drop { margin-left: 18px; }

/* superset */
.superset { border-left: 3px solid var(--accent); padding-left: 10px; margin-bottom: 14px; }
.superset .ex { margin-bottom: 8px; }
.ss-label {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
  margin: 0 0 6px 2px; display: flex; align-items: center; justify-content: space-between;
}

/* edit */
.eblock { background: var(--card); border-radius: var(--radius); padding: 6px 6px 6px 12px; display: flex; flex-direction: column; }
.eblock.superset { border-left: 3px solid var(--accent); margin-bottom: 0; padding-left: 12px; }
.eitem { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.eitem label { flex: 1; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.mv { display: flex; justify-content: flex-end; gap: 2px; border-top: 1px solid var(--line); margin-top: 2px; padding-top: 2px; }

/* chart */
.chart { width: 100%; height: auto; display: block; margin: 6px 0 2px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.stats { display: flex; gap: 10px; margin: 0 0 12px; }
.stat { flex: 1; background: var(--card); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }

/* login */
.login { margin: 18vh auto 0; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { text-align: center; }

/* nav */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: rgba(18,18,20,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
#nav[hidden] { display: none; }
#nav a, #nav button {
  flex: 1; text-align: center; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 4px; background: none; border: 0; cursor: pointer;
}
#nav a.active { color: var(--accent); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom));
  background: #3a1d1c; color: #ffd6d3; border: 1px solid #6b2c28; padding: 10px 14px; border-radius: 10px;
  max-width: calc(100% - 32px); font-size: 14px; z-index: 10;
}
#toast.ok { background: #1c3324; color: #d3ffe0; border-color: #2c6b3e; }
