/* LIFT — steel & chalk. Kanagawa-derived dark palette, Anton display, mono numerals. */

:root {
  --bg: #16161d;
  --card: #1f1f28;
  --raised: #2a2a37;
  --border: #363646;
  --fg: #dcd7ba;
  --dim: #727169;
  --faint: #54546d;
  --acc: #7e9cd8;
  --acc2: #7fb4ca;
  --autumn: #dca561;
  --ok: #98bb6c;
  --bad: #e46876;
  --gold: #e6c384;
  --blue: #7fb4ca;
  --purple: #957fb8;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, monospace;
  --display: "Anton", "Arial Narrow", system-ui, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { height: 100%; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

#view {
  max-width: 560px;
  margin: 0 auto;
  padding: 0.75rem 0.9rem calc(9.5rem + var(--safe-bottom));
}

h1.wordmark {
  font-family: var(--display);
  font-size: 2.6rem;
  letter-spacing: 0.04em;
  color: var(--fg);
  line-height: 1;
}
h1.wordmark .dot { color: var(--acc); }

.screen-title {
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0.6rem 0 1rem;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

button { font-family: var(--sans); color: var(--fg); background: none; border: none; cursor: pointer; font-size: 1rem; }
input, select, textarea {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
  border-color: var(--acc);
}
input::placeholder { color: var(--faint); }

/* ---------- shared components ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--acc); border-color: var(--acc); color: #16161d; }
.btn-ghost { background: none; border-color: var(--border); color: var(--dim); }
.btn-danger { background: none; border-color: var(--bad); color: var(--bad); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.7rem; min-height: 34px; font-size: 0.85rem; border-radius: 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  margin-bottom: 0.7rem;
}

.row { display: flex; align-items: center; gap: 0.6rem; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.stack { display: flex; flex-direction: column; gap: 0.7rem; }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 1.3rem; flex: none;
}
.icon-btn:active { background: var(--raised); }

.empty {
  text-align: center; color: var(--dim); padding: 2.5rem 1rem;
  border: 1px dashed var(--border); border-radius: 12px; margin-top: 0.5rem;
}
.empty .big { font-size: 2rem; margin-bottom: 0.5rem; }

/* ---------- auth ---------- */

.auth-wrap { max-width: 340px; margin: 14vh auto 0; display: flex; flex-direction: column; gap: 1rem; }
.auth-tagline { color: var(--dim); margin-top: -0.5rem; }
.auth-error { color: var(--bad); font-size: 0.9rem; min-height: 1.2em; }
.auth-switch { color: var(--dim); text-align: center; }
.auth-switch button { color: var(--acc); font-weight: 600; }

/* ---------- tab bar ---------- */

#tabbar[hidden] { display: none; }

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex;
  background: rgba(31, 31, 40, 0.97);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  backdrop-filter: blur(8px);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0.55rem 0 0.5rem; color: var(--faint); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.04em;
}
.tab svg { width: 22px; height: 22px; fill: currentColor; }
.tab.active { color: var(--acc); }

/* ---------- workout-in-progress banner ---------- */

#banner:empty { display: none; }
#banner {
  position: sticky; top: 0; z-index: 25;
}
.resume-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  background: var(--acc); color: #16161d;
  padding: 0.55rem 1rem; padding-top: max(0.55rem, env(safe-area-inset-top));
  font-weight: 700; font-size: 0.92rem; cursor: pointer;
}
.resume-banner .mono { font-weight: 700; }

/* ---------- routines (train tab) ---------- */

.routine-card .r-name { font-weight: 700; font-size: 1.05rem; }
.routine-card .r-line { color: var(--dim); font-size: 0.85rem; margin-top: 0.25rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.routine-card .r-foot { margin-top: 0.7rem; display: flex; gap: 0.5rem; }

/* ---------- live workout ---------- */

.live-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem;
  margin: 0.3rem 0 1rem;
}
.live-head .t { font-family: var(--display); font-size: 1.45rem; letter-spacing: 0.04em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-clock { font-family: var(--mono); color: var(--acc2); font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.ex-card { padding: 0.8rem 0.7rem; }
.ex-name { font-weight: 700; font-size: 1rem; color: var(--fg); }
.ex-sub { font-size: 0.78rem; color: var(--dim); }
.ex-head { margin-bottom: 0.6rem; }

.set-grid { display: flex; flex-direction: column; gap: 4px; }
.set-cols {
  display: grid; grid-template-columns: 2.4rem 1fr 4.6rem 4rem 3rem; gap: 0.45rem;
  align-items: center;
}
.set-cols.header { color: var(--faint); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; font-family: var(--mono); padding: 0 0.15rem; }
.set-cols.header > div { text-align: center; }
.set-cols.header > div:nth-child(2) { text-align: left; padding-left: 0.2rem; }

.set-row { border-radius: 9px; padding: 3px 0.15rem; transition: background 0.18s; }
.set-row.done { background: rgba(152, 187, 108, 0.13); }
.set-row.done input { color: var(--ok); border-color: transparent; background: transparent; }

.set-pill {
  width: 2.4rem; height: 38px; border-radius: 8px;
  font-family: var(--mono); font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); background: var(--raised);
}
.set-pill.warmup { color: var(--autumn); }
.set-pill.failure { color: var(--bad); }
.set-pill.drop { color: var(--purple); }

.set-prev { font-family: var(--mono); font-size: 0.8rem; color: var(--faint); text-align: left; padding-left: 0.2rem; white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }

.set-row input {
  text-align: center; font-family: var(--mono); font-variant-numeric: tabular-nums;
  padding: 0.45rem 0.2rem; height: 38px; font-size: 1rem; border-radius: 8px;
  background: var(--bg);
}
.set-row input::-webkit-outer-spin-button, .set-row input::-webkit-inner-spin-button { -webkit-appearance: none; }
.set-row input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.set-check {
  width: 100%; height: 38px; border-radius: 8px;
  background: var(--raised); border: 1px solid var(--border);
  color: var(--faint); font-size: 1.05rem; font-weight: 800;
}
.set-row.done .set-check { background: var(--ok); border-color: var(--ok); color: #16161d; }

.ex-foot { display: flex; gap: 0.5rem; margin-top: 0.6rem; }

.live-actions { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }

/* ---------- routine editor ---------- */

.editor-top { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.editor-top input { font-weight: 700; font-size: 1.05rem; }

.edit-set-cols { display: grid; grid-template-columns: 2.4rem 1fr 1fr 2.6rem; gap: 0.45rem; align-items: center; }
.edit-set-cols.header { color: var(--faint); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; font-family: var(--mono); }
.edit-set-cols.header > div { text-align: center; }
.edit-set-cols input { text-align: center; font-family: var(--mono); height: 38px; padding: 0.4rem 0.2rem; border-radius: 8px; }
.del-set { color: var(--faint); font-size: 1.2rem; height: 38px; border-radius: 8px; }
.del-set:active { color: var(--bad); }


/* ---------- history ---------- */

.month-label { margin: 1.1rem 0 0.5rem; }
.wo-card .w-name { font-weight: 700; }
.wo-card .w-meta { display: flex; gap: 0.9rem; margin-top: 0.35rem; color: var(--dim); font-size: 0.85rem; }
.wo-card .w-exs { color: var(--faint); font-size: 0.82rem; margin-top: 0.45rem; line-height: 1.5; }

.detail-sets { font-family: var(--mono); font-size: 0.92rem; margin-top: 0.4rem; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.detail-sets .t { display: inline-block; width: 1.6rem; color: var(--dim); }

.stat-tiles { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; margin-bottom: 1rem; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.6rem; text-align: center; }
.stat-tile .v { font-family: var(--mono); font-size: 1.15rem; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.stat-tile .l { font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); margin-top: 2px; font-family: var(--mono); }

.pr-badge { color: var(--gold); font-family: var(--mono); font-size: 0.8rem; }

/* ---------- exercises ---------- */

.search-bar { position: sticky; top: 0; background: var(--bg); padding: 0.4rem 0 0.6rem; z-index: 5; }
.chips { display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.5rem 0 0.2rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 0.35rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--dim); font-size: 0.82rem; font-weight: 600;
  background: var(--card);
}
.chip.active { background: var(--acc); border-color: var(--acc); color: #16161d; }

.ex-list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.75rem 0.4rem; border-bottom: 1px solid var(--card);
  width: 100%; text-align: left;
}
.ex-list-item .n { font-weight: 600; }
.ex-list-item .m { color: var(--faint); font-size: 0.78rem; }
.custom-tag { color: var(--acc); font-family: var(--mono); font-size: 0.7rem; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(22, 22, 29, 0.85);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); border: 1px solid var(--border); border-bottom: none;
  border-radius: 16px 16px 0 0;
  width: 100%; max-width: 560px; max-height: 86vh;
  display: flex; flex-direction: column;
  padding: 1rem 0.9rem calc(1rem + var(--safe-bottom));
  animation: sheet-up 0.18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.sheet-title { font-family: var(--display); font-size: 1.2rem; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.7rem; }
.sheet-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.sheet .actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; }
.sheet .actions .btn { flex: 1; }

.menu-sheet button {
  display: block; width: 100%; text-align: left; padding: 0.85rem 0.4rem;
  border-bottom: 1px solid var(--raised); font-size: 1rem;
}
.menu-sheet button.danger { color: var(--bad); }
.menu-sheet button:last-child { border-bottom: none; }

/* ---------- toast ---------- */

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(7.5rem + var(--safe-bottom)); z-index: 60;
  background: var(--raised); border: 1px solid var(--border); color: var(--fg);
  padding: 0.6rem 1.1rem; border-radius: 10px; font-size: 0.9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
#toast.ok { border-color: var(--ok); color: var(--ok); }
#toast.bad { border-color: var(--bad); color: var(--bad); }

/* ---------- finish summary ---------- */

.summary-vol { font-family: var(--mono); font-size: 2rem; color: var(--acc); font-variant-numeric: tabular-nums; }
.pr-line { display: flex; justify-content: space-between; padding: 0.45rem 0; border-bottom: 1px solid var(--raised); font-size: 0.95rem; }
.pr-line .mono { color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- plate calculator ---------- */

.plate-row {
  display: flex; align-items: center; gap: 4px;
  min-height: 100px; padding: 0.4rem 0.2rem; overflow-x: auto;
}
.bar-stub { width: 34px; height: 10px; background: var(--faint); border-radius: 3px 0 0 3px; flex: none; }
.plate-slot { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: none; }
.plate { width: 15px; border-radius: 4px; border: 1px solid rgba(22,22,29,0.55); }
.plate-label { font-size: 0.68rem; color: var(--dim); }

/* ---------- progress chart ---------- */

.chart-card { padding: 0.6rem 0.7rem 0.5rem; }
.chart-card .chips { padding-top: 0; margin-bottom: 0.3rem; }
.chart-tip { min-height: 1.2em; text-align: center; font-size: 0.8rem; color: var(--acc2); padding-bottom: 0.2rem; }
