/* ───────────────────────────── Lift-Log design system ───────────────────────────── */

:root {
  --bg: #0b0e13;
  --surface: #141923;
  --surface-2: #1b2230;
  --surface-3: #232c3d;
  --border: #28324433;
  --border-strong: #2c3850;
  --text: #e9eef6;
  --muted: #8d99ad;
  --faint: #5c6880;
  --accent: #b4f63b;
  --accent-dim: #b4f63b22;
  --accent-text: #1a2204;
  --danger: #ff6b6b;
  --danger-dim: #ff6b6b1a;
  --ok: #4ade80;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

body.no-nav { padding-bottom: 24px; }

[x-cloak] { display: none !important; }

/* ── Layout ── */
.shell { max-width: 680px; margin: 0 auto; padding: 0 16px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand svg { color: var(--accent); }

.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 18px 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 18px; font-size: 14.5px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card.tappable { cursor: pointer; transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease; }
.card.tappable:hover { border-color: var(--border-strong); background: var(--surface-2); }
.card.tappable:active { transform: scale(0.985); }

.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-weight: 700; font-size: 16.5px; letter-spacing: -0.01em; }
.card-meta { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.section-label {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 26px 0 10px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-decoration: none;
}

.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-danger { background: var(--danger-dim); border-color: transparent; color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 7px 13px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; border-radius: 12px; line-height: 0; }

/* ── Forms ── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }

.input, select.input, textarea.input {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input::placeholder { color: #5e6a7e; }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 22px;
  border-radius: 12px;
  transition: color 0.15s ease;
}

.bottom-nav a.active { color: var(--accent); }
.bottom-nav a:not(.active):hover { color: var(--text); }
.bottom-nav svg { width: 23px; height: 23px; }

/* ── Pills / chips ── */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ── Modal / sheet ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 560px) {
  .overlay { align-items: center; }
}

.sheet {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  animation: sheet-up 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@media (min-width: 560px) {
  .sheet { border-radius: 22px; max-height: 80dvh; }
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  font-weight: 800;
  font-size: 18px;
}

.sheet-body { padding: 4px 20px 20px; overflow-y: auto; }

/* ── Toast ── */
.toast-wrap {
  position: fixed;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
}

body.no-nav .toast-wrap { bottom: 32px; }

.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.toast.error { border-color: var(--danger); color: var(--danger); }

@keyframes toast-in {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Empty state ── */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 44px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty .big { font-size: 38px; margin-bottom: 8px; }

/* ── List rows (exercise library, pickers) ── */
.row-list { display: flex; flex-direction: column; gap: 8px; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.list-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.list-row .name { font-weight: 600; font-size: 15px; }
.list-row .sub { color: var(--muted); font-size: 12.5px; }

/* ─────────────────────────── Session screen ─────────────────────────── */

.session-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  margin: 0 -16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-bar .title { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-bar .elapsed { font-family: var(--mono); font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ex-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
  overflow: hidden;
}

.ex-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ex-head .ex-name { font-weight: 800; font-size: 16.5px; letter-spacing: -0.01em; flex: 1; min-width: 0; }
.ex-head .ex-progress { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.ex-head .ex-progress.done { color: var(--ok); }

.chev { transition: transform 0.2s ease; color: var(--muted); flex-shrink: 0; }
.chev.open { transform: rotate(90deg); }

.last-time {
  padding: 0 16px 10px;
  font-size: 13px;
  color: var(--muted);
}
.last-time b { color: var(--text); font-weight: 700; }

/* Set table */
.set-table { width: 100%; border-collapse: collapse; }

.set-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  font-weight: 800;
  text-align: center;
  padding: 4px 4px 8px;
}

.set-table td { padding: 4px; text-align: center; }

.set-table .set-num {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  width: 36px;
}

.set-table .prev {
  font-size: 13px;
  color: #5c6880;
  font-family: var(--mono);
  white-space: nowrap;
  width: 84px;
}

.set-input {
  width: 100%;
  max-width: 92px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  padding: 9px 4px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.set-input:focus { border-color: var(--accent); }
.set-input::placeholder { color: #515d72; font-weight: 500; }

tr.done .set-input { background: var(--accent-dim); color: var(--accent); }

.check-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.check-btn:active { transform: scale(0.9); }
.check-btn.checked { background: var(--accent); border-color: var(--accent); color: var(--accent-text); animation: pop 0.25s cubic-bezier(0.3, 1.6, 0.6, 1); }

@keyframes pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.del-set {
  background: none;
  border: none;
  color: #465062;
  cursor: pointer;
  padding: 6px;
  line-height: 0;
  border-radius: 8px;
}
.del-set:hover { color: var(--danger); }

.ex-body { padding: 2px 12px 14px; }
.add-set { margin: 8px 4px 0; }

/* Rest timer pill */
.rest-pill {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 9px 12px 9px 16px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.rest-pill .timer-text { font-family: var(--mono); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rest-pill .timer-label {
  font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rest-pill.finished { border-color: var(--accent); }
.rest-pill.finished .timer-text { color: var(--accent); }

.ring { transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .fill { stroke: var(--accent); transition: stroke-dashoffset 0.5s linear; stroke-linecap: round; }

/* Summary overlay */
.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }

.stat {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
}

.stat .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat .k { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

/* Confetti canvas */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ── Login ── */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card { width: 100%; max-width: 380px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth-logo svg { color: var(--accent); }
.auth-logo .name { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.auth-logo .tag { color: var(--muted); font-size: 14px; margin-top: -6px; }

.auth-tabs { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  padding: 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgb(0 0 0 / 0.3); }

.form-error {
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
}

/* ── Workout editor ── */
.editor-ex-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.editor-ex-row.dragging { opacity: 0.4; }
.editor-ex-row .name { flex: 1; font-weight: 600; font-size: 14.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-ex-row .grip { color: #465062; cursor: grab; touch-action: none; line-height: 0; }

.reorder-btns { display: flex; flex-direction: column; gap: 2px; }
.reorder-btns button {
  background: none; border: none; color: var(--muted); cursor: pointer; padding: 1px 6px; line-height: 0.8; border-radius: 6px; font-size: 13px;
}
.reorder-btns button:hover { color: var(--accent); }
.reorder-btns button:disabled { opacity: 0.25; cursor: default; }

/* misc */
.spin { animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

a { color: var(--accent); }

::selection { background: var(--accent); color: var(--accent-text); }
