/* Liam's Lifts
   Rubber-floor charcoal, chalk text, and the four bumper-plate colours
   marking each training day. */

:root {
  --floor: #1f2226;
  --surface: #2a2e33;
  --surface-2: #33383e;
  --line: #3e444b;
  --chalk: #ecebe6;
  --muted: #9a9fa6;
  --faint: #6c727a;

  --plate-red: #d8413a;
  --plate-blue: #3a6fd0;
  --plate-yellow: #e9b927;
  --plate-green: #34995a;

  --day: var(--plate-red);
  --on-day: #fff;

  --radius-lg: 18px;
  --radius-sm: 10px;
  --font: "Karla", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --floor: #eeeee9;
    --surface: #ffffff;
    --surface-2: #f4f4f0;
    --line: #d9d9d2;
    --chalk: #1c1f23;
    --muted: #5d636a;
    --faint: #8a9097;
    color-scheme: light;
  }
}

[data-day="upper1"] { --day: var(--plate-red); --on-day: #fff; }
[data-day="legs"]   { --day: var(--plate-blue); --on-day: #fff; }
[data-day="upper2"] { --day: var(--plate-yellow); --on-day: #1c1f23; }
[data-day="full"]   { --day: var(--plate-green); --on-day: #fff; }

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

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

body {
  margin: 0;
  background: var(--floor);
  color: var(--chalk);
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--day);
  outline-offset: 2px;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 20px)
    max(16px, env(safe-area-inset-right, 0px))
    calc(env(safe-area-inset-bottom, 0px) + 40px)
    max(16px, env(safe-area-inset-left, 0px));
}

/* Header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.brand {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Week tally: four small plates, filled when that day was logged this week */
.week {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
}
.week-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--day);
  background: transparent;
}
.week-dot.done { background: var(--day); }
.week-text { font-size: 0.85rem; font-weight: 700; color: var(--muted); margin-left: 4px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--chalk); }
.icon-btn svg { width: 20px; height: 20px; }

/* Day selector: the plates */

.days {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 10px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  transition: background-color .15s ease;
}

.plate {
  position: relative;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--day);
  opacity: .45;
  filter: saturate(.7);
  transition: opacity .15s ease, transform .2s ease;
}
/* collar hole */
.plate::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--day) 70%, #000);
}
.day-btn-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.day-btn[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--day); }
.day-btn[aria-selected="true"] .plate { opacity: 1; filter: none; transform: scale(1.08); }
.day-btn[aria-selected="true"] .day-btn-label { color: var(--chalk); }

/* Day heading */

.day-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.day-title {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}
.day-sub { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-day { background: var(--day); color: var(--on-day); }
.btn-solid { background: var(--chalk); color: var(--floor); }
.btn-quiet { background: var(--surface-2); color: var(--chalk); }
.btn-danger { background: transparent; color: var(--plate-red); box-shadow: inset 0 0 0 2px var(--plate-red); }
.btn:disabled { background: var(--surface-2); color: var(--faint); box-shadow: none; cursor: default; }

/* Exercise cards */

.exercises { display: grid; gap: 12px; }

.ex {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  border-left: 5px solid var(--day);
}

.ex-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}
.ex-name { margin: 0; font-size: 1.15rem; font-weight: 800; line-height: 1.2; padding-top: 4px; }

.ex-remove {
  width: 32px; height: 32px;
  background: transparent;
  color: var(--faint);
  font-size: 1.4rem;
  line-height: 1;
}

.last {
  margin: 6px 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
.last strong { color: var(--chalk); font-weight: 500; }

.sets { display: grid; gap: 8px; }

.set {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 32px;
  align-items: center;
  gap: 8px;
}
.set-num {
  font-weight: 800;
  color: var(--faint);
  text-align: center;
}
.set-num.filled { color: var(--day); }

.field {
  position: relative;
  display: block;
}
.field input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 14px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
}
.field input::placeholder { color: var(--faint); font-weight: 500; }
.field input:focus { outline: none; border-color: var(--day); }
.field .unit {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  color: var(--muted);
  pointer-events: none;
}

.set-remove {
  width: 32px; height: 32px;
  background: transparent;
  color: var(--faint);
  font-size: 1.2rem;
}
.set-remove[hidden] { visibility: hidden; display: inline-grid; }

.add-set {
  margin-top: 10px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.add-set:hover { color: var(--chalk); }

/* Add exercise */

.add-ex {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.add-ex input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  border: 2px dashed var(--line);
  border-radius: 999px;
  background: transparent;
}
.add-ex input:focus { outline: none; border-style: solid; border-color: var(--day); }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius-lg);
}

/* Log bar pinned to the bottom on phones */

.logbar {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  margin-top: 24px;
  display: flex;
  justify-content: center;
}
.logbar .btn {
  min-height: 54px;
  padding: 0 32px;
  font-size: 1.05rem;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--day) 35%, transparent);
}

/* Sheets (dialogs) */

.sheet {
  width: min(440px, calc(100% - 32px));
  border: 0;
  border-radius: var(--radius-lg);
  padding: 22px;
  background: var(--surface);
  color: var(--chalk);
}
.sheet::backdrop { background: rgb(0 0 0 / .55); }
.sheet h2 { margin: 0 0 8px; font-size: 1.3rem; }
.sheet p { margin: 0 0 16px; color: var(--muted); }
.sheet-stack { display: grid; gap: 10px; margin-bottom: 18px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--chalk);
  color: var(--floor);
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 560px) {
  .day-title { font-size: 2.75rem; }
}

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