/* Remember Fitness — palette from Pantone 4102 C, 159 C, 19-3518 Grape Royale,
   20-0200 Gunpowder, 7770 XGC. Montserrat throughout. Mobile portrait first. */

:root {
  --gunpowder: #1B1B20;
  --gunpowder-2: #25252C;
  --gunpowder-3: #30303A;
  --burgundy: #5E1F2F;
  --burgundy-2: #7A2A3E;
  --orange: #CB6015;
  --orange-bright: #F08A2E;
  --orange-soft: #F7A85C;
  --grape: #5D2C57;
  --grape-bright: #A889B0;
  --olive: #4E4A2C;
  --olive-bright: #A5A063;
  --magenta: #B01E5A;
  --magenta-bright: #F25C8A;

  --bg: var(--gunpowder);
  --surface: var(--gunpowder-2);
  --surface-2: var(--gunpowder-3);
  --line: rgba(255,255,255,0.08);
  --text: #F4EFEA;
  --text-2: #C9C2BC;
  --text-3: #8F8781;

  --radius: 18px;
  --radius-sm: 12px;
  --pad: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  padding-bottom: calc(24px + var(--safe-bottom));
}
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) var(--pad) 10px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(27,27,32,0));
}
.wordmark { display: flex; align-items: baseline; gap: 6px; letter-spacing: 0.14em; text-transform: uppercase; font-size: 13px; }
.wordmark-a { font-weight: 900; color: var(--text); }
.wordmark-b { font-weight: 500; color: var(--orange-bright); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- layout ---------- */
.app { padding: 0 var(--pad); max-width: 560px; margin: 0 auto; }
.loading, .error { padding: 40px 0; text-align: center; color: var(--text-3); font-weight: 500; }
.error { color: var(--orange-soft); }

/* ---------- day header ---------- */
.day-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--burgundy) 0%, var(--grape) 100%);
  border-radius: var(--radius);
  padding: 22px 20px 18px;
  margin: 6px 0 16px;
}
.day-hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px;
  border-radius: 50%; background: radial-gradient(circle, rgba(240,138,46,0.35), rgba(240,138,46,0) 70%);
}
.day-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(255,255,255,0.7); }
.day-number { font-size: 64px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; margin: 4px 0 8px; }
.day-number small { font-size: 22px; font-weight: 600; letter-spacing: 0; color: rgba(255,255,255,0.75); margin-left: 6px; }
.day-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
  background: rgba(0,0,0,0.28); color: #fff;
}
.pill-focus { background: var(--orange); color: #1B1B20; }
.progress { margin-top: 16px; display: flex; gap: 6px; }
.progress span { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.18); }
.progress span.done { background: var(--orange-bright); }
.progress span.now { background: rgba(255,255,255,0.6); }

/* ---------- cards ---------- */
.card {
  scroll-margin-top: 72px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px;
  width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer;
}
.card-head .chev { margin-left: auto; color: var(--text-3); transition: transform .2s; flex: none; }
.card.open .card-head .chev { transform: rotate(180deg); }
.card-body { display: none; padding: 0 16px 16px; }
.card.open .card-body { display: block; }

/* warm-up */
.warmup .card-head { padding: 14px 16px; }
.warmup-title { font-weight: 800; font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--olive-bright); }
.warmup-sub { font-size: 13px; color: var(--text-3); font-weight: 500; }
.warmup ul { list-style: none; margin: 0; padding: 0; }
.warmup li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.warmup li:first-child { border-top: 0; }
.warmup .wu-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--olive-bright); margin-top: 8px; flex: none; }
.warmup .wu-name { font-weight: 700; }
.warmup .wu-cue { color: var(--text-2); font-size: 14px; font-weight: 500; }

/* blocks */
.block { transition: opacity .2s; }
.block-num {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font-weight: 900; font-size: 16px;
  background: var(--surface-2); color: var(--text-2);
}
.block-title { font-weight: 800; font-size: 17px; letter-spacing: 0.01em; }
.block-format { font-size: 13px; color: var(--text-2); font-weight: 600; margin-top: 2px; }
.badge-side {
  display: inline-block; vertical-align: 2px; margin-left: 6px;
  padding: 2px 8px; border-radius: 6px;
  background: var(--grape); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
}
.block.current .rest-note.seq { border-left-color: var(--orange-bright); background: rgba(203,96,21,0.16); }
.block-format b { color: var(--orange-bright); font-weight: 800; }

.block.current { border-color: rgba(240,138,46,0.55); box-shadow: 0 0 0 1px rgba(240,138,46,0.25), 0 12px 40px rgba(0,0,0,0.35); }
.block.current .block-num { background: var(--orange); color: #1B1B20; }
.block.done { opacity: 0.85; }
.block.done .block-num { background: var(--olive); color: #E8E4C9; }
.block.done .block-title { color: var(--text-2); }
.block.upcoming { opacity: 0.55; }
.block.upcoming .block-num { background: var(--surface-2); color: var(--text-3); }

.rest-note {
  font-size: 13px; font-weight: 500; color: var(--text-2);
  background: rgba(93,44,87,0.35); border-left: 3px solid var(--grape-bright);
  padding: 10px 12px; border-radius: 10px; margin-bottom: 14px;
}

/* moves */
.move { padding: 16px 0; border-top: 1px solid var(--line); }
.move:first-of-type { border-top: 0; padding-top: 4px; }
.move-top { display: flex; align-items: flex-start; gap: 10px; }
.move-name { font-weight: 800; font-size: 18px; line-height: 1.2; letter-spacing: -0.01em; }
.move-dose { font-weight: 900; font-size: 22px; color: var(--orange-bright); line-height: 1; white-space: nowrap; margin-left: auto; text-align: right; }
.move-dose small { display: block; font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 4px; }
.move-context { font-size: 13px; color: var(--text-3); font-weight: 600; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid var(--line); color: var(--text-2);
}
.chip-w { border: 0; color: #1B1B20; font-weight: 800; }
.chip-w small { font-weight: 600; opacity: 0.8; }
.chip-w.light { background: #D8D3A0; }
.chip-w.medium { background: var(--orange-bright); }
.chip-w.heavy { background: var(--magenta-bright); }
.chip-w.legs-heavy { background: var(--magenta); color: #fff; }
.chip-w.legs-heavy small { opacity: 0.9; }
.chip-w.bodyweight { background: var(--grape-bright); }
.chip-w.band { background: var(--olive-bright); }
.cue { margin: 10px 0 0; font-size: 15px; font-weight: 500; font-style: italic; color: var(--text-2); line-height: 1.45; }

/* images */
.media { margin-top: 12px; position: relative; }
.media-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm);
}
.media-track::-webkit-scrollbar { display: none; }
.media-slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 4 / 3; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.media.empty .media-slide { aspect-ratio: auto; height: 64px; }
.media.empty .placeholder { grid-auto-flow: column; gap: 8px; }
.media.empty .placeholder svg { margin: 0; }
.media-slide img { width: 100%; height: 100%; object-fit: cover; }
.placeholder {
  width: 100%; height: 100%; display: grid; place-items: center; text-align: center;
  color: var(--text-3); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 14px, #2A2A32 14px 28px);
}
.placeholder svg { opacity: 0.5; margin-bottom: 6px; }
.media-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.media-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); opacity: 0.5; }
.media-dots span.on { background: var(--orange-bright); opacity: 1; }
.media-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(27,27,32,0.7); color: #fff; display: grid; place-items: center;
}
.media-arrow.prev { left: 6px; } .media-arrow.next { right: 6px; }

/* substitute */
.sub-toggle {
  margin-top: 12px; width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px dashed rgba(168,137,176,0.5); background: transparent;
  color: var(--grape-bright); font-weight: 700; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase;
  cursor: pointer;
}
.sub-toggle .chev { margin-left: auto; transition: transform .2s; }
.sub-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sub-panel { display: none; margin-top: 8px; padding: 12px; border-radius: 10px; background: rgba(93,44,87,0.22); border: 1px solid rgba(168,137,176,0.25); }
.sub-panel.open { display: block; }
.sub-label { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--grape-bright); }
.sub-name { font-weight: 800; font-size: 16px; margin-top: 2px; }

/* buttons */
.btn {
  width: 100%; border: 0; border-radius: 14px; cursor: pointer;
  padding: 16px 18px; font-weight: 800; font-size: 16px; letter-spacing: 0.03em;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--orange-bright); color: #1B1B20; margin-top: 8px; }
.btn-outline { background: transparent; border: 2px solid var(--surface-2); color: var(--text-2); }
.btn-outline.btn-danger { color: var(--magenta-bright); border-color: rgba(242,92,138,0.4); }
.btn-ghost { background: rgba(255,255,255,0.12); color: #fff; margin-top: 20px; }

.finish {
  scroll-margin-top: 72px;
  margin: 22px 0 8px;
  background: linear-gradient(135deg, var(--orange-bright), var(--orange) 60%, var(--burgundy-2));
  color: #fff; font-size: 19px; text-transform: uppercase; letter-spacing: 0.08em; min-height: 68px;
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(203,96,21,0.35);
  animation: pop .35s cubic-bezier(.2,1.4,.5,1);
}
.finish[disabled] { opacity: 0.35; filter: grayscale(0.6); box-shadow: none; animation: none; }
.finish-hint { text-align: center; color: var(--text-3); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
@keyframes pop { from { transform: scale(0.94); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
/* Blur lives on its own layer so it never bleeds through the animated card or sheet. */
.overlay::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: rgba(27,27,32,0.86); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.overlay > * { position: relative; z-index: 1; }
.overlay[hidden] { display: none; }
.done-card { position: relative; text-align: center; max-width: 360px; width: 100%; padding: 36px 24px; border-radius: 24px;
  background: linear-gradient(160deg, var(--burgundy) 0%, var(--grape) 100%); border: 1px solid rgba(255,255,255,0.1);
  animation: pop .5s cubic-bezier(.2,1.4,.5,1); }
.done-check { color: var(--orange-bright); animation: check .6s ease-out both; }
@keyframes check { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
.done-kicker { margin-top: 14px; font-size: 12px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(255,255,255,0.7); }
.done-title { font-size: 34px; font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.done-sub { margin-top: 10px; font-weight: 600; color: rgba(255,255,255,0.85); }
.done-burst { position: absolute; inset: 0; pointer-events: none; }
.done-burst span { position: absolute; left: 50%; top: 30%; width: 8px; height: 8px; border-radius: 2px; background: var(--orange-bright);
  animation: burst 1.1s ease-out both; }
.done-burst span:nth-child(2n) { background: var(--magenta-bright); }
.done-burst span:nth-child(3n) { background: var(--olive-bright); border-radius: 50%; }
.done-burst span:nth-child(1) { --dx: -120px; --dy: -90px; } .done-burst span:nth-child(2) { --dx: 120px; --dy: -70px; }
.done-burst span:nth-child(3) { --dx: -150px; --dy: 20px; }  .done-burst span:nth-child(4) { --dx: 150px; --dy: 30px; }
.done-burst span:nth-child(5) { --dx: -70px; --dy: -140px; } .done-burst span:nth-child(6) { --dx: 80px; --dy: -140px; }
.done-burst span:nth-child(7) { --dx: -110px; --dy: 90px; }  .done-burst span:nth-child(8) { --dx: 110px; --dy: 100px; }
@keyframes burst { 0% { transform: translate(0,0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(260deg); opacity: 0; } }

.overlay-sheet { align-items: flex-end; padding: 0; }
.sheet {
  width: 100%; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px var(--pad) calc(24px + var(--safe-bottom));
  animation: up .3s cubic-bezier(.2,1,.4,1);
}
/* transform only: animating opacity on this scrollable sheet leaves it translucent in Chromium */
@keyframes up { from { transform: translateY(40px); } to { transform: none; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--text-3); margin: 4px auto 10px; opacity: 0.5; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -0.01em; }
.sheet h3 { margin: 22px 0 6px; font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--orange-bright); }
.sheet-note { margin: 0 0 12px; font-size: 13px; color: var(--text-3); font-weight: 500; }
.day-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.day-grid button {
  border: 0; border-radius: 12px; padding: 12px 0; min-height: 56px;
  background: var(--surface-2); color: var(--text); font-weight: 800; font-size: 17px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.day-grid button small { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-3); }
.day-grid button.now { background: var(--orange-bright); color: #1B1B20; }
.day-grid button.now small { color: rgba(27,27,32,0.7); }
.history { list-style: none; margin: 0 0 12px; padding: 0; }
.history li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.history li span:last-child { color: var(--text-3); }
.history .empty { color: var(--text-3); border: 0; font-style: italic; font-weight: 500; }
.sheet .btn { margin-top: 6px; }

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