/* style.css — Lifts. Near-black with a saturated green accent (gym-legible,
   reads clearly under bad lighting). Mobile-first: bottom tab bar, big
   touch targets, square stepper buttons. Dark by default with a light
   prefers-color-scheme palette, same token shape as the other sites here. */

:root {
  --bg: #0e1410;
  --surface: #161d18;
  --surface-2: #1e2620;
  --line: #2c362e;
  --text: #eaf3ec;
  --muted: #8fa397;
  --accent: #39e07a;
  --accent-ink: #052411;

  --danger: #ef6a5f;
  --warn: #e0b339;

  --radius: 14px;
  --pad: 16px;
  --maxw: 560px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f8f6;
    --surface: #ffffff;
    --surface-2: #eef4f0;
    --line: #d7e2da;
    --text: #102015;
    --muted: #55695d;
    --accent: #0e9c4c;
    --accent-ink: #ffffff;
    --danger: #c8302c;
    --warn: #9a6c00;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* The one rule the login-gate / shell switch depends on: never let a class
   alone decide visibility (a bare display:grid/flex rule would beat a class
   toggle and produce an invisible overlay that swallows every click). */
[hidden] { display: none !important; }

/* ---- login ------------------------------------------------------------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--pad);
}
.login-card {
  width: min(100%, 360px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: grid;
  gap: 14px;
}
.login-mark { font-size: 36px; text-align: center; }
.login-card h1 { margin: 0; font-size: 26px; text-align: center; letter-spacing: -0.01em; }
.login-sub { margin: -10px 0 6px; text-align: center; color: var(--muted); font-size: 14px; }
.login-error { margin: 0; color: var(--danger); font-size: 14px; min-height: 1.2em; text-align: center; }

/* ---- shell --------------------------------------------------------------- */
.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--pad) 10px;
}
.brand { font-weight: 700; letter-spacing: -0.01em; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 14px; }

.main { flex: 1; padding: var(--pad); padding-bottom: 90px; display: block; }

/* ---- bottom tab bar -------------------------------------------------------- */
.tabbar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 4px max(4px, env(safe-area-inset-left)) max(4px, env(safe-area-inset-bottom));
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
}
.tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 8px 4px;
  min-height: 52px;
  cursor: pointer;
}
.tabbar .tab-icon { font-size: 20px; line-height: 1; }
.tabbar .tab[aria-selected="true"] { color: var(--accent); }

/* ---- generic bits ---------------------------------------------------------- */
.view-title { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.section-label { margin: 10px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; }
.stack { display: grid; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.empty { color: var(--muted); font-size: 15px; padding: 8px 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---- day header ------------------------------------------------------------ */
.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.day-title { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; text-align: center; }
.day-date { font-size: 18px; font-weight: 700; }

.picker-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.sheet-title-inline { margin: 0; font-size: 18px; font-weight: 700; }

.subtabs { display: flex; gap: 6px; margin-bottom: 4px; }
.subtab {
  flex: 1;
  font: inherit;
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.subtab.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 650; }

/* ---- cards ------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 8px;
}
.exercise-card { cursor: pointer; }
.exercise-card:active { transform: translateY(1px); }
.card-title { font-weight: 650; font-size: 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.set-list { display: flex; gap: 6px; flex-wrap: wrap; }
.set-chip {
  font-size: 13.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
}

.pr-card .pr-value { display: grid; gap: 2px; }
.pr-main { font-size: 22px; font-weight: 700; color: var(--accent); }

.ref-card { background: var(--surface-2); }

.tag {
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

/* ---- buttons & inputs ------------------------------------------------------- */
.btn {
  font: inherit;
  font-size: 15px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  line-height: 1.2;
  min-height: 44px;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-sm { font-size: 13px; padding: 7px 12px; min-height: 36px; }
.btn-lg { font-size: 16px; padding: 13px 18px; min-height: 52px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-danger { color: #fff; border-color: var(--danger); background: var(--danger); font-weight: 600; }
.btn-danger.btn-ghost, .btn-danger:not(.btn-lg):not(.btn-block) { color: var(--danger); background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-icon {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 12px;
  font-size: 20px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.btn-list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: var(--surface);
}
.btn-list.active { border-color: var(--accent); }
.btn-list.archived { opacity: 0.6; }

label { display: grid; gap: 5px; font-size: 14px; }
label > span { color: var(--muted); }
input, select, textarea {
  font: inherit;
  font-size: 16px;               /* 16px stops iOS zooming the page on focus */
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  width: 100%;
  min-height: 44px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.field-hint { font-size: 12.5px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.check input { width: auto; min-height: auto; }

.search-box { margin-bottom: 2px; }

/* ---- steppers --------------------------------------------------------------- */
.stepper-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 380px) { .stepper-row { grid-template-columns: 1fr; } }
.stepper-group { display: grid; gap: 6px; }
.stepper-label { font-size: 13px; color: var(--muted); }
.stepper {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 6px;
  align-items: stretch;
}
.btn-stepper {
  min-height: 56px;
  border-radius: 12px;
  font-size: 26px;
  font-weight: 700;
  padding: 0;
  background: var(--surface-2);
}
.stepper-input {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  min-height: 56px;
  /* Two steppers side by side on a 390px phone leave ~60px for this box:
     drop the generic input padding and the spinner, or "45" renders as "4". */
  min-width: 0;
  padding: 0 4px;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.unit-switch { display: flex; gap: 10px; }
.unit-switch .btn { flex: 1; }

/* ---- sheet (dialog) --------------------------------------------------------- */
.sheet {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(100% - 24px, 480px);
  max-height: 88dvh;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet form { display: flex; flex-direction: column; max-height: 88dvh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-body { padding: 16px; display: grid; gap: 14px; overflow-y: auto; }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sheet-error { margin: 0; color: var(--danger); font-size: 14px; min-height: 0; }
.sheet-error:empty { display: none; }

/* ---- toast ------------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  z-index: 10;
  max-width: calc(100% - 32px);
}
