:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --accent-press: #3b73e0;
  --good: #36c98a;
  --warn: #f0a93b;
  --error: #ff6b6b;
  --radius: 14px;
}

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

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

body {
  /* Respect iPhone safe areas (notch / home indicator) */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); min-height: 1.2em; margin: 8px 0 0; }
.link {
  background: none; border: none; color: var(--accent);
  font-size: 14px; padding: 8px; cursor: pointer;
}

.screen { min-height: 100vh; }

/* ---------- Auth ---------- */
#auth { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 22px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
label { display: block; margin: 18px 0 0; font-size: 14px; color: var(--muted); }
input {
  width: 100%; margin-top: 6px; padding: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 17px;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }

button.primary {
  width: 100%; margin-top: 18px; padding: 14px;
  background: var(--accent); color: white; border: none;
  border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer;
}
button.primary:active { background: var(--accent-press); }
button.primary:disabled { opacity: .5; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 12px 10px;
}
.topbar-title { flex: 1; text-align: center; }
.day-label { font-weight: 700; font-size: 17px; }
.nav {
  width: 44px; height: 44px; flex: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 22px; cursor: pointer;
}
.today-btn {
  display: block; margin: 10px auto 0;
  background: var(--surface-2); color: var(--accent);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 6px 14px; font-size: 13px; cursor: pointer;
}

/* ---------- Session ---------- */
.session { padding: 14px 12px 120px; max-width: 560px; margin: 0 auto; }

.banner {
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}
.banner.deload { background: rgba(240,169,59,.12); border: 1px solid var(--warn); color: var(--warn); }
.banner.rest { background: rgba(54,201,138,.12); border: 1px solid var(--good); color: var(--good); }
.banner.test { background: rgba(79,140,255,.14); border: 1px solid var(--accent); color: var(--accent); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 2px; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.card.main h3::after { content: " · main"; color: var(--accent); font-size: 12px; font-weight: 500; }
.card .note { color: var(--warn); font-size: 13px; margin: 6px 0 0; }
.section-title { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* set rows */
.set-row {
  display: grid; grid-template-columns: 26px 1fr 1fr 1fr; gap: 6px;
  align-items: center; margin-top: 8px;
}
.set-row .set-n { color: var(--muted); font-size: 13px; text-align: center; }
.set-row input { margin-top: 0; padding: 10px; font-size: 16px; text-align: center; }
.set-head { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.set-head span { text-align: center; }

/* run + rest + felt */
.run-desc { font-size: 14px; margin: 4px 0 10px; }
textarea {
  width: 100%; min-height: 70px; padding: 12px; resize: vertical;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font: inherit;
}
.chk { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.chk input { width: 22px; height: 22px; margin: 0; }

/* ---------- Footer ---------- */
.footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, var(--bg) 28%);
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.footer .save { max-width: 560px; }

/* ---------- Spinner ---------- */
#loading { display: flex; align-items: center; justify-content: center; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
