/* FORGE — dark theme */
:root {
  --page: #0f1014;
  --surface: #17181c;
  --surface-2: #1e2026;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f2f2f0;
  --text-2: #a9a8a1;
  --muted: #898781;
  --grid: #2a2b30;
  --accent: #ff6b2c;
  --accent-press: #e55a1f;
  --good: #0ca30c;
  --danger: #d03b3b;
  --series-1: #3987e5;
  --series-2: #199e70;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 100%; max-width: 360px; text-align: center; }
.logo { font-size: 42px; font-weight: 900; letter-spacing: 2px; }
.logo-dot { color: var(--accent); }
.logo-small { font-size: 20px; letter-spacing: 1.5px; }
.tagline { color: var(--text-2); margin-top: 2px; margin-bottom: 28px; letter-spacing: 3px; font-size: 12px; text-transform: uppercase; }
.login-hint { color: var(--text-2); font-size: 13px; min-height: 18px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---------- app shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: baseline; gap: 12px;
  padding: 12px 16px calc(10px);
  background: rgba(15, 16, 20, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-sub { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.view {
  flex: 1; width: 100%; max-width: 680px; margin: 0 auto;
  padding: 16px 14px calc(84px + env(safe-area-inset-bottom));
}
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(15, 16, 20, 0.95); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 10px; padding: 4px 10px; border-radius: 8px;
}
.nav-item svg { width: 22px; height: 22px; fill: currentColor; }
.nav-item.active { color: var(--accent); }

/* ---------- common components ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-title h2, .card-title h3 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: #262830; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent-press); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

input, select, textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255, 107, 44, 0.5); border-color: transparent; }
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--text-2); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.right { text-align: right; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
}
.chip.active { background: rgba(255, 107, 44, 0.16); border-color: var(--accent); color: var(--accent); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-accent { background: rgba(255, 107, 44, 0.15); color: var(--accent); }
.badge-good { background: rgba(12, 163, 12, 0.15); color: #3fca3f; }

.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12.5px; }
.list-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 14px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .value { font-size: 24px; font-weight: 800; margin-top: 2px; }
.tile .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; }
.tile .sub { color: var(--text-2); font-size: 12px; margin-top: 2px; }

/* ---------- strength ---------- */
.datebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.datebar .date-label { font-weight: 700; font-size: 16px; text-align: center; flex: 1; }
.datebar .date-label .small { display: block; font-weight: 400; }
.set-row {
  display: grid; grid-template-columns: 26px 1fr 1fr auto; gap: 8px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.set-row:last-child { border-bottom: none; }
.set-row .set-num { color: var(--muted); font-size: 12px; font-weight: 700; }
.set-row.warmup { opacity: 0.55; }
.set-row .pr-star { color: var(--accent); font-size: 12px; font-weight: 800; }
.set-entry { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 10px; }
.stepper { display: flex; align-items: stretch; }
.stepper button {
  width: 34px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  font-size: 17px; cursor: pointer;
}
.stepper button:first-child { border-radius: 10px 0 0 10px; border-right: none; }
.stepper button:last-child { border-radius: 0 10px 10px 0; border-left: none; }
.stepper input { border-radius: 0; text-align: center; padding: 10px 4px; }
.last-session { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ---------- WOD ---------- */
.subtabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin-bottom: 14px; }
.subtabs button {
  flex: 1; padding: 8px; background: transparent; border: none; color: var(--text-2);
  font-size: 13.5px; font-weight: 600; border-radius: 7px; cursor: pointer;
}
.subtabs button.active { background: var(--surface-2); color: var(--text); }
.movement-line { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.movement-line .check { color: var(--good); font-weight: 700; }
.movement-line .check.miss { color: var(--muted); }
.wod-desc { white-space: pre-wrap; color: var(--text-2); font-size: 13.5px; }
.score-big { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- modal & toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 560px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px 16px 0 0; width: 100%; max-width: 560px;
  max-height: 86dvh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 560px) { .modal { border-radius: 16px; } }
.modal-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-title h2 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; padding: 4px 8px; }

#toast-root { position: fixed; bottom: calc(78px + env(safe-area-inset-bottom)); left: 0; right: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); animation: toast-in 0.2s ease;
  max-width: 90%;
}
.toast.pr { border-color: var(--accent); color: var(--accent); }
.toast.error { border-color: var(--danger); color: #ff8a8a; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* charts */
.chart-wrap { position: relative; height: 240px; margin-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-top: 6px; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* activity icons */
.act-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--surface-2);
}
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
