*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --louis: #3b82f6;
  --louis-dim: rgba(59,130,246,0.12);
  --louis-border: rgba(59,130,246,0.3);
  --jaline: #ec4899;
  --jaline-dim: rgba(236,72,153,0.12);
  --jaline-border: rgba(236,72,153,0.3);
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #222;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --muted: #666;
  --success: #22c55e;
  --success-dim: rgba(34,197,94,0.12);
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ── SCREENS ── */
.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* ── SETUP ── */
.setup-screen {
  padding: 3rem 1.5rem 2rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.logo { font-size: 2.2rem; font-weight: 700; letter-spacing: -1px; }
.setup-sub { color: var(--muted); margin-bottom: 2rem; }
.card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.text-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  outline: none;
}
.text-input:focus { border-color: var(--louis); }
.field-hint { font-size: 0.78rem; color: var(--muted); line-height: 1.5; }
.field-hint a { color: var(--louis); }
.field-hint code { background: var(--surface2); padding: 0.1em 0.3em; border-radius: 3px; font-size: 0.85em; }
.status-msg { font-size: 0.85rem; min-height: 1.2em; }
.status-msg.error { color: var(--danger); }
.status-msg.success { color: var(--success); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--louis); color: #fff; width: 100%; }
.btn-success { background: var(--success); color: #fff; width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); width: 100%; }
.btn-ghost:hover { color: var(--text); border-color: var(--text); }
.btn-lg { padding: 1rem; font-size: 1.05rem; }

/* ── HOME ── */
.home-screen { padding: 2rem 1.25rem 1.5rem; gap: 0.25rem; }
.home-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.home-header .logo { font-size: 1.6rem; }
.users-row { display: flex; gap: 0.5rem; }
.user-chip {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  letter-spacing: 0.03em;
}
.user-chip.louis { background: var(--louis-dim); color: var(--louis); border: 1px solid var(--louis-border); }
.user-chip.jaline { background: var(--jaline-dim); color: var(--jaline); border: 1px solid var(--jaline-border); }
.home-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.25rem; }
.day-list { display: flex; flex-direction: column; gap: 0.75rem; flex: 1; }
.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
}
.day-card:active { background: var(--surface2); border-color: var(--louis); }
.day-label { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.day-name { font-size: 1rem; font-weight: 600; }
.day-count { font-size: 0.78rem; color: var(--muted); text-align: right; }
.settings-btn { margin-top: 1.5rem; font-size: 0.85rem; }

/* ── WORKOUT ── */
.workout-screen { padding: 0; }
.workout-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.back-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  min-width: 32px;
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
}
.workout-progress { flex: 1; min-width: 0; }
.workout-day-name { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exercise-progress { font-size: 0.85rem; font-weight: 600; color: var(--text); }

.exercise-card {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.exercise-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.4rem; }
.cue-details summary {
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  list-style: none;
}
.cue-details summary::before { content: '▶ '; font-size: 0.65rem; }
.cue-details[open] summary::before { content: '▼ '; }
.cue-text { font-size: 0.85rem; color: var(--text); line-height: 1.5; margin-top: 0.5rem; }

/* ── SETS GRID ── */
.sets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
}
.col-header {
  padding: 0.6rem 0.75rem 0.5rem;
  border-bottom: 2px solid;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.col-header.louis-header { border-color: var(--louis); background: var(--louis-dim); }
.col-header.jaline-header { border-color: var(--jaline); background: var(--jaline-dim); border-left: 1px solid var(--border); }
.col-name { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.louis-text { color: var(--louis); }
.jaline-text { color: var(--jaline); }
.col-target { font-size: 0.72rem; color: var(--muted); }

.set-cell {
  padding: 0.6rem 0.65rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.set-cell:nth-child(even) { border-left: 1px solid var(--border); }
.set-cell.done { background: rgba(34,197,94,0.04); }
.set-cell.disabled { opacity: 0.35; pointer-events: none; justify-content: center; align-items: center; min-height: 80px; }
.cell-null { color: var(--muted); font-size: 1.2rem; }

.set-num { font-size: 0.72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Done row */
.set-done-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
}
.set-summary { flex: 1; font-size: 0.9rem; font-weight: 600; }
.done-tick { color: var(--success); font-size: 1rem; font-weight: 700; }

/* Active set */
.set-row { display: flex; flex-direction: column; gap: 0.4rem; }
.input-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.adj-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  width: 32px;
  min-height: 40px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.adj-btn:active { background: var(--border); }
.num-input {
  flex: 1;
  min-width: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  padding: 0.4rem 0.2rem;
  min-height: 40px;
  outline: none;
  -moz-appearance: textfield;
}
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.num-input:focus { border-color: var(--louis); }
.num-input.jaline-input:focus { border-color: var(--jaline); }
.num-input::placeholder { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.optional-row { display: flex; gap: 0.3rem; }
.opt-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.3rem 0.2rem;
  min-height: 34px;
  outline: none;
  -moz-appearance: textfield;
}
.opt-input::-webkit-outer-spin-button,
.opt-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.opt-input:focus { color: var(--text); border-color: var(--border); }
.opt-input::placeholder { font-size: 0.72rem; }
.btn-done {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem;
  min-height: 36px;
  cursor: pointer;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.btn-done:active { background: var(--success-dim); border-color: var(--success); }

/* ── WORKOUT FOOTER ── */
.workout-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.rest-timer { font-size: 0.95rem; font-weight: 700; color: var(--muted); min-width: 60px; }
.footer-actions { display: flex; gap: 0.5rem; flex: 1; justify-content: flex-end; }
.footer-actions .btn { width: auto; padding: 0.65rem 1.25rem; }

/* ── FINISH ── */
.finish-screen {
  padding: 3rem 1.5rem 2rem;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.finish-header { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.finish-icon { font-size: 3rem; }
.finish-header h2 { font-size: 1.4rem; font-weight: 700; }
.finish-sub { color: var(--muted); }
.finish-stats { display: flex; gap: 1rem; margin: 0.5rem 0 1rem; }
.stat-box {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat-val { font-size: 1.8rem; font-weight: 700; }
.stat-lbl { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }
