/* =========================================================================
   Plateload - same design system as Paycheck Allocator:
   near-black canvas, layered surfaces, hairline borders, mint accent,
   large tabular numerals, system (SF) type.
   Phone (<1024px): frosted bottom tab bar, single column.
   Laptop (>=1024px): left sidebar.
   ========================================================================= */

:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #07090d;
  --surface: #10141b;
  --surface-2: #171c26;
  --surface-3: #212838;

  /* lines */
  --border: #232a38;
  --line: rgba(255, 255, 255, 0.07);

  /* text */
  --text: #f2f5fa;
  --muted: #8f9ab0;
  --faint: #5b6579;

  /* accent (mint, hue 156) */
  --accent-h: 156;
  --accent-l: 47%;
  --accent: hsl(var(--accent-h) 75% var(--accent-l));
  --accent-hover: hsl(var(--accent-h) 73% calc(var(--accent-l) + 12%));
  --accent-ink: hsl(var(--accent-h) 75% 5%);
  --accent-soft: hsl(var(--accent-h) 75% var(--accent-l) / 0.13);
  --accent-glow: hsl(var(--accent-h) 75% var(--accent-l) / 0.38);
  --accent-outline: hsl(var(--accent-h) 75% var(--accent-l) / 0.22);
  /* muscle diagram highlight (Settings can give it its own hue) */
  --map-h: var(--accent-h);
  --map-l: var(--accent-l);
  --map-hi: hsl(var(--map-h) 75% var(--map-l));
  --danger: #ff5d73;
  --danger-soft: rgba(255, 93, 115, 0.14);

  /* shape */
  --radius-card: 22px;
  --radius-row: 14px;
  --radius-ctl: 12px;
  --sidebar-w: 248px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.006em;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Soft mint glow behind everything (fixed pseudo-element; iOS ignores background-attachment:fixed). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 460px at 50% -160px, hsl(var(--accent-h) 75% var(--accent-l) / 0.11), transparent 70%),
    radial-gradient(640px 380px at 100% 0%, rgba(90, 120, 255, 0.07), transparent 70%);
}
#app { position: relative; z-index: 1; min-height: 100vh; }

::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: #2b3445 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b3445; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden, [hidden] { display: none !important; }

/* ---------- brand mark ---------- */
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent-hover), hsl(var(--accent-h) 82% calc(var(--accent-l) - 8%)));
  box-shadow: 0 6px 16px -6px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* ---------- header ---------- */
header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  padding-top: calc(max(12px, env(safe-area-inset-top)) + 28px);
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
#app::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 25;
  height: env(safe-area-inset-top);
  background: var(--bg);
  pointer-events: none;
}
header h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }

/* ---------- bottom tab bar (phones + tablets) ---------- */
#bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
  background: rgba(11, 14, 20, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--line);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 4px 2px;
  background: none;
  border: none;
  border-radius: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease;
}
.tab-icon { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 15px; transition: background 0.2s ease; }
.tab-icon svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab-label { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; line-height: 1; }
.tab-btn.active { color: var(--accent); }
.tab-btn.active .tab-icon { background: var(--accent-soft); }
.tab-btn:active .tab-icon { transform: scale(0.94); }

main {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px calc(100px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.tab-panel:not(.hidden) { animation: panelIn 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.intro { margin: 0 0 14px; font-size: 14px; }

/* ---------- cards ---------- */
.card {
  position: relative;
  margin: 0 0 16px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 130px), var(--surface);
  border: 3px solid var(--accent-outline);
  border-radius: var(--radius-card);
  box-shadow: 0 20px 44px -24px rgba(0, 0, 0, 0.8);
}
.card h2 { position: relative; display: inline-block; margin: 0 0 14px; font-size: 18px; font-weight: 650; letter-spacing: -0.018em; }
.card h2::after {
  content: "";
  position: absolute;
  left: 8%; right: 8%; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, hsl(var(--accent-h) 75% var(--accent-l) / 0.22) 35%, hsl(var(--accent-h) 75% var(--accent-l) / 0.22) 65%, transparent);
  pointer-events: none;
}
.card-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-header-row h2 { margin: 0; }
.card-body > p.muted { margin: 0 0 12px; }

/* Hero card: like Account Balance */
.card.hero {
  background:
    radial-gradient(520px 240px at 100% 0%, hsl(var(--accent-h) 75% var(--accent-l) / 0.17), transparent 70%),
    linear-gradient(180deg, #141c24, #0f151c);
  border-color: hsl(var(--accent-h) 75% var(--accent-l) / 0.2);
}
.hero-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.hero-title { margin: 4px 0 14px; font-size: clamp(34px, 9.5vw, 46px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.stat { padding: 10px 12px; background: rgba(255, 255, 255, 0.035); border-radius: var(--radius-row); }
.stat b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.stat span { font-size: 12px; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-actions button { flex: 1 1 140px; padding-inline: 12px; white-space: nowrap; }
/* Workout + rest timer buttons: a matched pair */
.timer-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.timer-buttons .timer-btn { min-width: 0; padding-inline: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-buttons .timer-btn span { overflow: hidden; text-overflow: ellipsis; }
.timer-btn.running { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-variant-numeric: tabular-nums; }
.timer-btn.running.paused { color: var(--text); border-color: var(--accent-outline); background: rgba(255, 255, 255, 0.05); }
.finish-btn { grid-column: 1 / -1; }
.session-pill {
  display: inline-flex; align-items: center; gap: 7px; min-height: 30px; margin-left: auto; padding: 0 12px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--accent-outline); color: var(--accent); font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.session-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.session-pill.paused { color: var(--muted); background: rgba(255, 255, 255, 0.05); border-color: var(--line); }
.session-pill.paused .dot { background: var(--muted); animation: none; }
.session-pill:not(.hidden) + #settings-gear { margin-left: 8px; }
@keyframes pulse { 50% { opacity: 0.3; } }
.note { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--text); font-size: 13px; box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- lists + rows ---------- */
.list { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--accent-outline);
  border-radius: var(--radius-row);
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.meta { margin-top: 2px; color: var(--muted); font-size: 13px; font-weight: 400; }
.muted { color: var(--muted); font-size: 13px; }

/* Sets per muscle */
.vol-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 34px; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.vol-row + .vol-row { border-top: 1px solid var(--line); }
.vol-track { height: 8px; background: rgba(255, 255, 255, 0.06); border-radius: 999px; overflow: hidden; }
.vol-track i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.vol-row .n { text-align: right; font-weight: 600; }

/* ---------- exercise rows ---------- */
.ex-row { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; }
.ex-row.done { opacity: 0.55; }
.ex-top { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; align-items: start; }
.ex-info { min-width: 0; }
.ex-name-line { display: flex; align-items: baseline; gap: 8px; }
.ex-tag {
  flex: none; display: inline-grid; place-items: center; min-width: 28px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
.name-btn {
  min-height: 0; padding: 0; background: none; border: none; border-radius: 0; color: var(--text);
  font-size: 16px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.3; text-align: left; cursor: pointer;
}
.rx { margin-top: 6px; font-size: 20px; font-weight: 700; letter-spacing: -0.025em; }
.rx small { margin-left: 8px; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.cue { margin: 0; color: var(--muted); font-size: 13px; }
.ex-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sets { display: flex; flex-wrap: wrap; gap: 6px; }
button.set {
  min-width: 44px; min-height: 40px; padding: 0 10px; border-radius: 12px; font-size: 15px; font-weight: 650;
  background: var(--surface-2); border: 1px solid var(--accent-outline); color: var(--text);
}
button.set[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 18px -10px var(--accent-glow); }
.ex-act { display: flex; gap: 4px; }

/* Superset label */
.pair-label { margin: 6px 2px 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

/* ---------- photos (tap to play) ---------- */
.thumb {
  position: relative; display: block; width: 84px; aspect-ratio: 1; max-width: 100%; min-height: 0; padding: 0; overflow: hidden;
  border: 1px solid var(--accent-outline); border-radius: 12px; background: #fff; flex: none; cursor: pointer;
}
.thumb.sm { width: 60px; border-radius: 10px; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .play {
  position: absolute; right: 4px; bottom: 4px; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 11px; background: rgba(7, 9, 13, 0.75); color: var(--text); font-size: 9px; line-height: 1;
}
.thumb.playing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.thumb.playing .play { background: var(--accent); color: var(--accent-ink); }
.thumb.playing .top, .sheet-media .top { animation: flip 1.6s infinite; }
@keyframes flip { 0%, 42% { opacity: 1; } 50%, 92% { opacity: 0; } 100% { opacity: 1; } }
.thumb.ph { display: grid; place-items: center; background: var(--accent-soft); cursor: default; }
.thumb.ph svg { width: 50%; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; }

/* Library rows */
.lib-row { display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; gap: 12px; padding: 10px 12px; }
.lib-row .name-btn { font-size: 15px; }
.lib-row { content-visibility: auto; contain-intrinsic-size: auto 84px; }

/* ---------- form controls ---------- */
input[type="search"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--accent-outline);
  border-radius: var(--radius-ctl);
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* iOS zooms in under 16px */
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: var(--faint); }
input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

button {
  min-height: 46px;
  padding: 11px 18px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
  border: none;
  border-radius: var(--radius-ctl);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.98); }
button:focus-visible, .tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 10px 24px -12px var(--accent-glow); }
button.secondary { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--accent-outline); color: var(--text); }
button.small { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
button.wide { display: block; width: 100%; margin: 0 0 16px; min-height: 54px; font-size: 17px; }
button.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; padding: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--accent-outline); color: var(--muted); }
button.icon-btn svg { display: block; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
button.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
button.icon-btn.round { border-radius: 50%; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Option tiles (single choice with a description) */
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.option-grid button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 62px; padding: 11px 14px; text-align: left;
  background: rgba(255, 255, 255, 0.035); border: 1px solid var(--accent-outline); border-radius: var(--radius-row);
}
.option-grid button b { font-size: 15px; font-weight: 650; }
.option-grid button small { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.3; }
.option-grid button[aria-pressed="true"] { border: 2px solid var(--accent); padding: 10px 13px; background: var(--accent-soft); }
.option-grid button[aria-pressed="true"] b { color: var(--accent); }

/* Chips (multi choice) */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-row.sub { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.chip-row button {
  min-height: 36px; padding: 7px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: rgba(255, 255, 255, 0.05); border: 1px solid transparent; color: var(--muted);
}
.chip-row button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-outline); }
.scroll-x { flex-wrap: nowrap; overflow-x: auto; margin: 12px -20px; padding: 0 20px; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x button { flex: none; }

/* Segmented control (same as Activity's sub-nav) */
.sub-nav { display: flex; gap: 4px; padding: 4px; background: rgba(255, 255, 255, 0.05); border-radius: 16px; }
.sub-nav + .muted { margin: 14px 0 10px; }
.sub-nav button { flex: 1; min-height: 40px; padding: 8px 10px; background: none; border: none; border-radius: 12px; color: var(--muted); font-size: 14px; font-weight: 600; }
.sub-nav button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }

/* Time slider */
.time-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.time-big { font-size: 40px; font-weight: 700; letter-spacing: -0.035em; line-height: 1; }
input.range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 8px; margin: 10px 0 4px; padding: 0; border: none; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--pct, 50%), rgba(255, 255, 255, 0.08) var(--pct, 50%)); cursor: pointer;
}
input.range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--text); border: 4px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
input.range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--text); border: 4px solid var(--accent); }
input.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

/* Checkbox (same custom box as Paycheck Allocator) */
.check-row { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; font-size: 14px; color: var(--muted); cursor: pointer; }
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin: 0; flex: none;
  border: 1.5px solid #3b475c; border-radius: 6px; background: transparent; cursor: pointer;
}
input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.6 9.4l2.8 2.8 6-6.4' fill='none' stroke='%2303150d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
input[type="checkbox"]:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }

/* Phone handoff (laptop only) */
.phone-body { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 16px; align-items: center; }
.phone-body p { margin: 0; }
.phone-body b { color: var(--text); font-weight: 600; word-break: break-all; }
.phone-qr { padding: 8px; background: #fff; border-radius: 12px; }
.phone-qr svg { display: block; width: 100%; height: auto; }

/* ---------- sheet (bottom sheet on phones, centered dialog on laptops) ---------- */
dialog.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; margin: auto auto 0; padding: 0;
  background: transparent; border: none; color: var(--text); overflow: visible;
}
@supports (height: 100dvh) { dialog.sheet { max-height: 88dvh; } }
dialog.sheet::backdrop { background: rgba(2, 4, 8, 0.64); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet-panel {
  max-height: inherit; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  animation: sheetUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.sheet-panel::before { content: ""; display: block; width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: rgba(255, 255, 255, 0.16); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
@keyframes sheetUp { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-media { position: relative; aspect-ratio: 4 / 3; max-width: 100%; overflow: hidden; border-radius: 16px; border: 1px solid var(--accent-outline); background: #fff; }
.sheet-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.sheet-ph { position: absolute; inset: 0; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.sheet-meta { margin: 14px 0 0; }
.sheet-cue { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 14px; box-shadow: inset 3px 0 0 var(--accent); }
.sheet-steps-title { margin: 16px 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.sheet-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; line-height: 1.45; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.sheet-actions button { flex: 1 1 160px; }
.link-box { width: 100%; margin-top: 4px; }

/* ---------- rest timer + toast ---------- */
.timer {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(80px + env(safe-area-inset-bottom));
  width: calc(100% - 24px); max-width: 560px;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  background: rgba(20, 27, 38, 0.92); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: 1px solid hsl(var(--accent-h) 75% var(--accent-l) / 0.38); border-radius: 16px;
  box-shadow: inset 4px 0 0 var(--accent), 0 16px 44px rgba(0, 0, 0, 0.55);
}
.timer button { flex: none; white-space: nowrap; padding-inline: 10px; }
@media (max-width: 400px) { .timer { gap: 8px; padding-left: 12px; } .timer-label { display: none; } }
.timer-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.timer-clock { min-width: 3.2ch; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.timer-bar { flex: 1; min-width: 30px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.timer-bar i { display: block; width: 0; height: 100%; background: var(--accent); transition: width 0.25s linear; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  top: calc(env(safe-area-inset-top) + 10px);
  max-width: calc(100% - 24px); padding: 12px 16px;
  background: rgba(20, 27, 38, 0.92); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: 1px solid hsl(var(--accent-h) 75% var(--accent-l) / 0.38); border-radius: 16px;
  box-shadow: inset 4px 0 0 var(--accent), 0 16px 44px rgba(0, 0, 0, 0.55); font-size: 14px;
}

/* ---------- hover (mouse only) ---------- */
@media (hover: hover) {
  .tab-btn:hover:not(.active) { color: var(--text); }
  button.primary:hover { background: var(--accent-hover); }
  button.secondary:hover, button.icon-btn:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--accent-glow); }
  .chip-row button:hover:not([aria-pressed="true"]) { color: var(--text); }
  .option-grid button:hover { background: rgba(255, 255, 255, 0.065); }
  .sub-nav button:not([aria-pressed="true"]):hover { color: var(--text); }
  .name-btn:hover { color: var(--accent); }
}

@media (max-width: 380px) {
  .option-grid { grid-template-columns: minmax(0, 1fr); }
  .ex-top { grid-template-columns: 72px minmax(0, 1fr); }
  .thumb { width: 72px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
  .scroll-x { margin-inline: -16px; padding-inline: 16px; }
}

/* ---------- body diagram ---------- */
.bodymap { display: block; width: 100%; height: auto; }
.bodymap .bm-base { fill: rgba(255, 255, 255, 0.13); }
.bodymap .bm-off { fill: rgba(255, 255, 255, 0.07); }
.bodymap .bm-on { fill: var(--map-hi); }
.bodymap .bm-label { fill: var(--muted); font-size: 11px; font-weight: 600; text-anchor: middle; font-family: var(--font); }
.ex-left { display: flex; flex-direction: column; gap: 8px; width: 84px; }
.ex-left .bodymap { padding: 4px 2px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); }
.map-wrap { max-width: 320px; margin: 0 auto 6px; }
.map-legend { display: flex; justify-content: center; gap: 18px; margin-bottom: 14px; font-size: 12px; color: var(--muted); }
.map-legend span, .target-line { display: inline-flex; align-items: center; gap: 7px; }
.lg-hi, .lg-lo { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--map-hi); flex: none; }
.lg-lo { opacity: 0.45; }
.vol-note { margin: 10px 0 0; font-size: 12px; }
.sheet-target { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; align-items: center; margin-top: 16px; }
.sheet-target .sheet-steps-title { margin-top: 0; }
.target-line { display: flex; margin-bottom: 6px; font-size: 14px; }
@media (max-width: 380px) { .sheet-target { grid-template-columns: 120px minmax(0, 1fr); } }

/* ---------- settings ---------- */
/* Same footprint on every screen: a 38px circle whose center sits on the logo's center line. */
#settings-gear {
  flex: none; display: grid; place-items: center; place-content: center; gap: 0; box-sizing: border-box;
  width: 38px; height: 38px; min-width: 38px; min-height: 38px; margin: 0 0 0 auto; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: var(--muted); line-height: 0;
}
#settings-gear svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transform-origin: 50% 50%; transition: transform 0.3s ease; }
#settings-gear.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-outline); }
@media (hover: hover) { #settings-gear:hover { color: var(--text); } #settings-gear:hover svg { transform: rotate(30deg); } }
/* ---------- saved workouts ---------- */
.saved-row { display: flex; align-items: center; gap: 12px; }
.saved-main { flex: 1; min-width: 0; }
.saved-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-meta { margin: 2px 0 0; font-size: 13px; }
.saved-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
button.swatch {
  width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%; background: var(--sw);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
button.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--sw); }
.hue-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.hue-swatch { flex: none; width: 28px; height: 28px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08); }
input.hue-slider {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 14px; padding: 0; margin: 0; border: none; border-radius: 999px;
  background: linear-gradient(90deg, hsl(0 75% 55%), hsl(60 75% 50%), hsl(120 75% 45%), hsl(180 75% 45%), hsl(240 75% 62%), hsl(300 75% 58%), hsl(360 75% 55%));
  cursor: pointer;
}
input.hue-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--text); border: 3px solid var(--bg); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
input.hue-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--text); border: 3px solid var(--bg); }
input.hue-slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.preview-map { max-width: 220px; margin: 0 auto 14px; }
#set-map-custom { margin-top: 16px; }
#set-bg button { flex-direction: row; align-items: center; gap: 12px; min-height: 56px; }
.bg-chip { width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.14); flex: none; }

/* ---------- tablets and up: sheet centers ---------- */
@media (min-width: 768px) {
  dialog.sheet { max-width: 560px; margin: auto; }
  .sheet-panel { padding: 22px 26px 26px; border-bottom: 1px solid var(--line); border-radius: 24px; }
  .sheet-panel::before { display: none; }
}

/* ---------- laptops: sidebar ---------- */
@media (min-width: 1024px) {
  header {
    position: fixed; top: 0; left: 0; z-index: 21;
    width: var(--sidebar-w); height: 84px; padding: 0 24px;
    background: none; border-bottom: none;
  }
  header h1 { font-size: 16px; }
  #bottom-nav {
    top: 0; right: auto; bottom: 0; width: var(--sidebar-w);
    flex-direction: column; gap: 4px; padding: 92px 14px 24px;
    background: rgba(12, 15, 21, 0.7); -webkit-backdrop-filter: none; backdrop-filter: none;
    border-top: none; border-right: 1px solid var(--line);
  }
  .tab-btn { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; width: 100%; min-height: 46px; padding: 0 16px; }
  .tab-icon, .tab-btn.active .tab-icon { width: 24px; height: 24px; background: none; border-radius: 0; }
  .tab-label { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
  .tab-btn.active { background: var(--accent-soft); }
  main { max-width: none; margin: 0 0 0 var(--sidebar-w); padding: 40px 48px 64px; }
  .tab-panel { max-width: 780px; margin: 0 auto; }
  /* header is 84px tall with the logo centered at 42px, so top 23px puts the gear's center on the same line */
  #settings-gear { position: fixed; top: 23px; right: 28px; z-index: 22; }
  .timer { left: calc(50% + var(--sidebar-w) / 2); bottom: 24px; }
  .toast { left: calc(50% + var(--sidebar-w) / 2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
