:root {
  color-scheme: dark;
  --bg: #11151c;
  --card: #1a2029;
  --line: #2a3340;
  --text: #eef2f6;
  --muted: #93a0b0;
  --accent: #ffb020;
  --accent-text: #1a1200;
  --ok: #56d38a;
  --bad: #ff7a6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

h1 { font-size: 26px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 17px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 14px; }

button, input, select { font: inherit; color: inherit; }

button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}
button.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
}

input, select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar h1 { overflow-wrap: anywhere; }
.topbar .link { white-space: nowrap; }

.monthbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.monthbar h2 { flex: 1; color: var(--muted); font-weight: 600; }
.monthbar button + h2 { text-align: center; }
button:disabled { opacity: 0.35; cursor: default; }

.banner {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-size: 14px;
}

.card {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: start;
}
.card.session { display: grid; gap: 14px; }
.card.session .primary { width: 100%; }
.card.session .field, .card.session .chips { margin-bottom: 0; }
.banner.past { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.banner.past .link { white-space: nowrap; text-decoration: underline; }
.card h3 + p { margin-top: 4px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { color: var(--muted); font-size: 14px; }
.field input, .field select { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chips button { border-radius: 999px; }

.login { padding-top: 12vh; }
.login h1 { margin-bottom: 28px; }
.login h1 + .muted { margin-top: -20px; }
.login .muted { margin-bottom: 28px; }
/* One rhythm: 8px from a label to its control, 28px between groups, 12px from the field to its button. */
.login .field { gap: 8px; margin-bottom: 28px; }
.login .field .chips { margin-bottom: 0; }
.login form .field { margin-bottom: 12px; }
.login .primary { width: 100%; }
.stack { display: grid; gap: 10px; }

.target { color: var(--accent); font-weight: 600; white-space: nowrap; }
.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.record {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(255, 176, 32, 0.1);
}
.record[hidden] { display: none; }
.record .tag {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.record strong { font-size: 18px; }
.record .age { margin-inline-start: auto; color: var(--muted); font-size: 14px; }
.hint { margin-top: 8px; font-size: 13px; }
.set input::placeholder { color: #566270; font-weight: 400; }

.sets { display: grid; gap: 8px; margin: 12px 0 0; }
.set {
  display: grid;
  grid-template-columns: 26px 1fr 12px 1fr 62px;
  align-items: center;
  gap: 8px;
}
.set .n { color: var(--muted); font-size: 14px; text-align: center; }
.set .x { color: var(--muted); text-align: center; }
.set input { width: 100%; min-width: 0; padding: 0 4px; text-align: center; font-size: 18px; font-weight: 600; }
.set-head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.set-head span { text-align: center; }

.set .mark { color: var(--ok); font-size: 14px; font-weight: 700; white-space: nowrap; }
.set.is-done input { border-color: var(--ok); }

.ex-side { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.badge { color: var(--ok); font-size: 14px; font-weight: 700; }
.progress { margin-bottom: 12px; color: var(--muted); font-weight: 600; }
.progress.all-done { color: var(--ok); }

.exercise + .exercise { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.super-label {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(17, 21, 28, 0.95);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.center { padding-top: 30vh; text-align: center; }
.center button { margin-top: 16px; }

/* New PR celebration */
.record.is-new { border-color: var(--ok); background: rgba(86, 211, 138, 0.12); animation: pulse 0.6s ease-out 2; }
.record.is-new .tag { background: var(--ok); color: #06210f; }
@keyframes pulse { 50% { transform: scale(1.03); } }

.toast {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  z-index: 21;
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border-radius: 14px;
  background: var(--ok);
  color: #06210f;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
  animation: toast 3.5s ease both;
}
.toast strong { font-size: 20px; }
.toast bdi { font-weight: 600; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -20px) scale(0.9); }
  8%, 85% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(1); }
}

.confetti { position: fixed; inset: 0; z-index: 20; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -16px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: fall linear both;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  .record.is-new, .toast { animation: none; }
}
