:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1f242e;
  --line: #2a313d;
  --text: #eef1f6;
  --muted: #9aa4b2;
  --accent: #ff3b3b;
  --accent-dim: #b32a2a;
  --green: #36c47a;
  --amber: #f1b34a;
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --header-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* themeable surfaces */
  --header-bg: rgba(15, 17, 21, 0.9);
  --tabbar-bg: rgba(20, 22, 28, 0.96);
  --card-bg: var(--bg-elev);
  --card-shadow: none;
  --card-border: var(--line);
  --app-bg-img: none;
  --deco: "";
  --deco-card: "";
  /* rest timer (black default) */
  --rest-bg: rgba(10, 12, 16, 0.97);
  --rest-overtime-bg:
    radial-gradient(circle at 50% 42%, rgba(255, 90, 90, 0.16), rgba(10, 12, 16, 0) 55%),
    rgba(10, 12, 16, 0.97);
  --rest-overtime-time: #ff6b6b;
  --rest-overtime-status: #ff8a8a;
  --rest-snake-bright: #ff1f1f;
  --rest-snake-mid: rgba(255, 122, 122, 0.65);
}

/* ===================== Themes ===================== */
/* Cyberpunk — neon magenta / cyan on deep purple-black */
:root[data-theme="cyberpunk"] {
  --bg: #07040f;
  --bg-elev: #130a26;
  --bg-elev-2: #1d0f38;
  --line: #6a2cc4;
  --text: #ecf9ff;
  --muted: #9d8ad6;
  --accent: #ff2bd6;
  --accent-dim: #b51f9b;
  --green: #2bffce;
  --amber: #ffd23b;
  --header-bg: rgba(10, 5, 22, 0.88);
  --tabbar-bg: rgba(16, 8, 34, 0.96);
  --card-bg: linear-gradient(160deg, #170b2e 0%, #0e0720 100%);
  --card-border: #ff2bd6;
  --card-shadow: 0 0 0 1px rgba(43, 255, 206, 0.18), 0 0 18px rgba(255, 43, 214, 0.28);
  --app-bg-img: radial-gradient(60% 40% at 80% 0%, rgba(255, 43, 214, 0.14), transparent 70%),
                radial-gradient(50% 35% at 0% 100%, rgba(43, 255, 206, 0.12), transparent 70%);
  --deco: "\26A1"; /* ⚡ */
  --deco-card: "\25B8\0020"; /* ▸ */
}

/* Mushroom — red page, cream cards (🍄 #D0263D + #F0E1CD) */
:root[data-theme="mushroom"] {
  --bg: #D0263D;
  --bg-elev: #c02238;
  --bg-elev-2: #b82036;
  --line: rgba(240, 225, 205, 0.35);
  --text: #F0E1CD;
  --muted: #e8dcc8;
  --accent: #F0E1CD;
  --accent-dim: #dfc9b0;
  --green: #8b1830;
  --amber: #F0E1CD;
  --header-bg: rgba(192, 34, 56, 0.96);
  --tabbar-bg: rgba(184, 32, 54, 0.98);
  --card-bg: #F0E1CD;
  --card-border: rgba(208, 38, 61, 0.22);
  --card-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  --app-bg-img: none;
  --deco: "\1F344"; /* 🍄 */
  --deco-card: "\1F344\0020"; /* 🍄 */
  --rest-bg: rgba(184, 32, 54, 0.98);
  --rest-overtime-bg:
    radial-gradient(circle at 50% 42%, rgba(240, 225, 205, 0.12), rgba(184, 32, 54, 0) 58%),
    rgba(184, 32, 54, 0.98);
  --rest-overtime-time: #F0E1CD;
  --rest-overtime-status: #e8dcc8;
  --rest-snake-bright: #F0E1CD;
  --rest-snake-mid: rgba(240, 225, 205, 0.45);
}

/* Mushroom: cream cards re-scope tokens so all nested UI stays readable */
:root[data-theme="mushroom"] .card,
:root[data-theme="mushroom"] .collapse-section {
  --text: #7a1424;
  --muted: #a03040;
  --accent: #D0263D;
  --line: rgba(208, 38, 61, 0.18);
  --bg-elev-2: rgba(208, 38, 61, 0.08);
  border-width: 2px;
  color: var(--text);
}
:root[data-theme="mushroom"] .card h3,
:root[data-theme="mushroom"] .collapse-section .collapse-head {
  color: #8b1830;
}
:root[data-theme="mushroom"] .card .cal-cell.other {
  color: rgba(122, 20, 36, 0.35);
}
:root[data-theme="mushroom"] .card .chip:not(.on),
:root[data-theme="mushroom"] .collapse-section .chip:not(.on) {
  background: rgba(208, 38, 61, 0.14);
  border-color: rgba(122, 20, 36, 0.42);
  color: #7a1424;
  font-weight: 600;
}
:root[data-theme="mushroom"] .card .pill,
:root[data-theme="mushroom"] .collapse-section .pill {
  background: rgba(208, 38, 61, 0.14);
  border-color: rgba(122, 20, 36, 0.42);
  color: #7a1424;
  font-weight: 600;
}
:root[data-theme="mushroom"] .tab.active {
  color: #F0E1CD;
  font-weight: 700;
}
:root[data-theme="mushroom"] .section-title {
  color: rgba(240, 225, 205, 0.75);
}
:root[data-theme="mushroom"] .btn-primary {
  background: #F0E1CD;
  border-color: #F0E1CD;
  color: #D0263D;
  box-shadow: none;
}
:root[data-theme="mushroom"] .btn-ghost {
  border-color: rgba(240, 225, 205, 0.5);
  color: #F0E1CD;
  background: rgba(0, 0, 0, 0.08);
}
:root[data-theme="mushroom"] .btn-danger {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(240, 225, 205, 0.65);
  color: #F0E1CD;
}
:root[data-theme="mushroom"] .card .btn-danger {
  background: rgba(208, 38, 61, 0.08);
  border-color: #D0263D;
  color: #D0263D;
}
:root[data-theme="mushroom"] .chip {
  background: rgba(240, 225, 205, 0.2);
  border-color: rgba(240, 225, 205, 0.65);
  color: #F0E1CD;
  font-weight: 600;
}
:root[data-theme="mushroom"] .chip.selectable.on,
:root[data-theme="mushroom"] .chip.on {
  background: #F0E1CD;
  border-color: #F0E1CD;
  color: #D0263D;
}
:root[data-theme="mushroom"] .card .chip.on,
:root[data-theme="mushroom"] .collapse-section .chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
:root[data-theme="mushroom"] .theme-card {
  background: #F0E1CD;
  color: #7a1424;
  border-color: rgba(208, 38, 61, 0.2);
}
:root[data-theme="mushroom"] .theme-card .theme-desc {
  color: #a03040;
}
:root[data-theme="mushroom"] .theme-card.sel {
  border-color: #8b1830;
  box-shadow: 0 0 0 2px rgba(240, 225, 205, 0.6);
}
:root[data-theme="mushroom"] .collapse-head .chev {
  background: #D0263D;
  color: #F0E1CD;
}
:root[data-theme="mushroom"] .card .btn-ghost {
  border-color: rgba(122, 20, 36, 0.3);
  color: #8b1830;
  background: transparent;
}
:root[data-theme="mushroom"] .card .btn-primary,
:root[data-theme="mushroom"] .collapse-section .btn-primary {
  background: #D0263D;
  border-color: #D0263D;
  color: #F0E1CD;
  box-shadow: 0 2px 10px rgba(122, 20, 36, 0.22);
}
:root[data-theme="mushroom"] .ex-head .done-badge {
  color: #8b1830;
}
:root[data-theme="mushroom"] .rest-overlay.overtime::after {
  filter: none;
  padding: 2px;
}

/* Frogs — bright froggy greens + lily-pad cuteness */
:root[data-theme="frogs"] {
  --bg: #0c2415;
  --bg-elev: #123620;
  --bg-elev-2: #18482a;
  --line: #2f7a47;
  --text: #ecffef;
  --muted: #8fcda1;
  --accent: #5fd35f;
  --accent-dim: #3aa53a;
  --green: #5fd35f;
  --amber: #ffd76a;
  --header-bg: rgba(12, 36, 21, 0.9);
  --tabbar-bg: rgba(18, 54, 32, 0.96);
  --card-bg: linear-gradient(160deg, #163d24 0%, #0f3018 100%);
  --card-border: #3aa53a;
  --card-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  --app-bg-img: radial-gradient(45% 30% at 90% 5%, rgba(95, 211, 95, 0.16), transparent 70%);
  --deco: "\1F438"; /* 🐸 */
  --deco-card: "\1F438\0020"; /* 🐸 */
  --rest-bg: rgba(8, 28, 16, 0.98);
  --rest-overtime-bg:
    radial-gradient(circle at 50% 42%, rgba(95, 211, 95, 0.22), rgba(8, 28, 16, 0) 55%),
    rgba(8, 28, 16, 0.98);
  --rest-overtime-time: #7dff7d;
  --rest-overtime-status: #b8ffb8;
  --rest-snake-bright: #5fd35f;
  --rest-snake-mid: rgba(127, 255, 127, 0.65);
}

/* Nature — earthy bark + leaf tones */
:root[data-theme="nature"] {
  --bg: #14110b;
  --bg-elev: #211c12;
  --bg-elev-2: #2d2618;
  --line: #4a3d27;
  --text: #f4eede;
  --muted: #b8a983;
  --accent: #8cbf4f;
  --accent-dim: #5f8a33;
  --green: #8cbf4f;
  --amber: #d99a3c;
  --header-bg: rgba(20, 17, 11, 0.9);
  --tabbar-bg: rgba(33, 28, 18, 0.96);
  --card-bg: linear-gradient(160deg, #251f14 0%, #1c1810 100%);
  --card-border: #5f4f30;
  --card-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  --app-bg-img: radial-gradient(50% 35% at 100% 0%, rgba(140, 191, 79, 0.12), transparent 70%);
  --deco: "\1F33F"; /* 🌿 */
  --deco-card: "\1F343\0020"; /* 🍃 */
  --rest-bg: rgba(16, 14, 8, 0.98);
  --rest-overtime-bg:
    radial-gradient(circle at 50% 42%, rgba(140, 191, 79, 0.22), rgba(16, 14, 8, 0) 55%),
    rgba(16, 14, 8, 0.98);
  --rest-overtime-time: #b8e86a;
  --rest-overtime-status: #d4f0a0;
  --rest-snake-bright: #8cbf4f;
  --rest-snake-mid: rgba(168, 210, 100, 0.65);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
  transition: background-color 0.25s ease, color 0.25s ease;
}

body {
  background-image: var(--app-bg-img);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* Floating theme decoration (watermark in a corner) */
body::after {
  content: var(--deco);
  position: fixed;
  right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  font-size: 58px;
  line-height: 1;
  opacity: 0.16;
  pointer-events: none;
  z-index: 1;
  animation: decoFloat 5s ease-in-out infinite;
}

@keyframes decoFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
}

#app { min-height: 100vh; position: relative; z-index: 2; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.2px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

.view {
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  max-width: 720px;
  margin: 0 auto;
}

/* Bottom tab bar */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--tabbar-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  cursor: pointer;
  padding: 6px 0;
}
.tab .tab-ico { font-size: 20px; line-height: 1; }
.tab.active { color: var(--accent); }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--accent-dim); color: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-icon {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  font-size: 18px; line-height: 1;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--card-shadow);
}
.card-row { display: flex; align-items: center; gap: 12px; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
/* Theme accent prefix on card titles */
.card h3::before {
  content: var(--deco-card);
  filter: saturate(1.1);
}
.card .desc { color: var(--muted); font-size: 14px; margin: 0; }
.grow { flex: 1; min-width: 0; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 24px 0 10px; }
.filter-bar { margin-bottom: 14px; }
.filter-bar .chips { gap: 8px; }
.muted { color: var(--muted); }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}
.empty .big { font-size: 40px; display: block; margin-bottom: 12px; }

/* Chips (muscle tags) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: default;
}
.chip.selectable { cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 72px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper input { text-align: center; max-width: 90px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease;
}
.modal {
  background: var(--bg-elev);
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  animation: slideup 0.22s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius); border-bottom: 1px solid var(--line); }
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideup { from { transform: translateY(24px); opacity: 0.4 } to { transform: none; opacity: 1 } }

/* Body diagram */
.body-diagram { width: 100%; max-width: 360px; margin: 0 auto; display: block; }
.body-diagram .skin { fill: #2a313d; }
.body-diagram .muscle { fill: #39414f; stroke: #11141a; stroke-width: 1.2; transition: fill 0.2s ease; }
.body-diagram .muscle.active { fill: var(--accent); }
.body-diagram .fig-label { fill: var(--muted); font-size: 11px; font-weight: 600; text-anchor: middle; }

/* Session checklist */
.session-sticky {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top));
  z-index: 15;
  background: var(--bg);
  padding-bottom: 12px;
  margin: 0 -16px 4px; /* bleed to edges so content doesn't show at sides */
  padding-left: 16px;
  padding-right: 16px;
}
.timer-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.timer-bar .time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-bar .meta { font-size: 12px; color: var(--muted); }

.rest-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px 8px 14px;
  margin-top: 8px;
}
.rest-bar .rest-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.rest-bar .rest-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rest-bar .grow { flex: 1; }

/* Fullscreen rest countdown popup */
.rest-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: var(--rest-bg);
  display: flex; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  animation: fade 0.18s ease;
}
.rest-overlay-inner {
  position: relative;
  z-index: 2;
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; align-items: center; gap: 28px;
  text-align: center;
}
.rest-status { font-size: 15px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.rest-time {
  font-size: clamp(72px, 28vw, 160px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.rest-adjust { display: flex; gap: 12px; }
.rest-adjust .btn { min-width: 76px; }
.rest-overlay .btn-stop { width: 100%; max-width: 320px; font-size: 18px; padding: 16px; }

/* Overtime: no sound, calm "breathing" glow that's eye-catching but relaxed */
.rest-overlay.overtime {
  background: var(--rest-overtime-bg);
  animation: restBreatheBg 3.2s ease-in-out infinite;
}
.rest-overlay.overtime .rest-time {
  color: var(--rest-overtime-time);
  animation: restBreathe 3.2s ease-in-out infinite;
}
.rest-overlay.overtime .rest-status {
  color: var(--rest-overtime-status);
  font-weight: 700;
  animation: restFade 3.2s ease-in-out infinite;
}
@keyframes restBreatheBg {
  0%, 100% { background-size: 120% 120%, auto; }
  50% { background-size: 165% 165%, auto; }
}
@keyframes restBreathe {
  0%, 100% { transform: scale(1); text-shadow: 0 0 12px color-mix(in srgb, var(--rest-overtime-time) 25%, transparent); }
  50% { transform: scale(1.05); text-shadow: 0 0 48px color-mix(in srgb, var(--rest-overtime-time) 60%, transparent); }
}
@keyframes restFade {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
/* Neon "snake" pill running around the screen edges during overtime */
@property --snake-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
.rest-overlay.overtime::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 3px; /* ring thickness */
  border-radius: 4px;
  background: conic-gradient(
    from var(--snake-angle),
    transparent 0deg 326deg,
    var(--rest-snake-mid) 334deg,
    var(--rest-snake-bright) 344deg,
    var(--rest-snake-mid) 354deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  filter: drop-shadow(0 0 4px var(--rest-snake-bright)) drop-shadow(0 0 11px color-mix(in srgb, var(--rest-snake-bright) 85%, transparent));
  pointer-events: none;
  animation: snakeRun 2.4s linear infinite;
}
@keyframes snakeRun {
  to { --snake-angle: 360deg; }
}

/* Themed emoji "party popper" burst during rest overtime (non-black themes) */
.rest-emoji-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.rest-emoji-pop {
  position: absolute;
  font-size: clamp(22px, 6vw, 36px);
  line-height: 1;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  animation: restEmojiPop 2.6s ease-out forwards;
  will-change: transform, opacity;
}
@keyframes restEmojiPop {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.85) rotate(var(--rot));
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rest-overlay.overtime,
  .rest-overlay.overtime .rest-time,
  .rest-overlay.overtime .rest-status { animation: none; }
  .rest-overlay.overtime::after { animation: none; }
  .rest-emoji-pop { animation: none; opacity: 0.7; }
}

.ex-block { margin-bottom: 14px; }
.ex-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ex-head h3 { margin: 0; font-size: 16px; }
.ex-head .done-badge { font-size: 12px; color: var(--green); margin-left: auto; }

.set-row {
  display: grid;
  grid-template-columns: 28px 64px 1fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.set-row:first-of-type { border-top: 0; }
.set-row .set-no { color: var(--muted); font-size: 13px; }
.set-row input {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 8px;
  font-size: 15px;
  text-align: center;
}
.set-row.done input { opacity: 0.6; }
.check {
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: transparent;
  font-size: 16px;
  flex: none;
}
.check.on { background: var(--green); border-color: var(--green); color: #fff; }
.col-head {
  display: grid;
  grid-template-columns: 28px 64px 1fr 1fr;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 4px;
}

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-head h3 { margin: 0; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  border-radius: 50%;
  position: relative;
  color: var(--text);
}
.cal-cell.other { color: #4a5160; }
.cal-cell.today { outline: 1px solid var(--muted); }
.cal-cell.has-session {
  border: 2px solid var(--accent);
  font-weight: 700;
  cursor: pointer;
}
.cal-cell.has-session::after {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.add-set { margin-top: 10px; width: 100%; border-style: dashed; }

/* Theme picker */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-card {
  appearance: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.theme-card:active { transform: scale(0.98); }
.theme-card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.theme-card .theme-emoji { font-size: 26px; line-height: 1; }
.theme-card .theme-name { font-weight: 700; font-size: 15px; margin-top: 4px; }
.theme-card .theme-desc { font-size: 11.5px; color: var(--muted); }

/* Collapsible section (e.g. Personal bests) */
.collapse-section {
  margin-top: 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.collapse-head {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  user-select: none;
}
.collapse-head::-webkit-details-marker { display: none; }
.collapse-head .pb-count { font-size: 15px; font-weight: 600; }
.collapse-head .chev {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  transition: transform 0.25s ease;
}
.collapse-section[open] .collapse-head .chev { transform: rotate(180deg); }
.collapse-body { padding: 0 16px 12px; }

/* Exercise progress chart */
.exercise-chart { width: 100%; height: auto; display: block; background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px; }
.exercise-chart .ch-grid { stroke: var(--line); stroke-width: 1; opacity: 0.5; }
.exercise-chart .ch-axis { stroke: var(--line); stroke-width: 1.4; }
.exercise-chart .ch-lbl { fill: var(--muted); font-size: 10px; }
.exercise-chart .ch-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.exercise-chart .ch-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }

/* History */
.history-item .row { display: flex; justify-content: space-between; gap: 8px; }
.history-item .dur { color: var(--accent); font-weight: 700; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-child { border-top: 0; }
.kv .k { color: var(--muted); }
.detail { margin-top: 10px; }

/* Sortable exercise order (workout form) */
.sortable-list { display: flex; flex-direction: column; gap: 8px; touch-action: pan-x pan-y; }
.sortable-list.is-sorting { touch-action: none; }
.sortable-list.is-sorting .sortable-item { transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1); }
.sortable-empty {
  font-size: 13px;
  margin: 0;
  padding: 14px 12px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.sortable-placeholder {
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.04);
  box-sizing: border-box;
  transition: height 0.15s ease;
}
.sortable-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  touch-action: none;
  user-select: none;
  will-change: transform;
}
.sortable-item.is-dragging {
  position: fixed;
  z-index: 200;
  margin: 0;
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  transition: none;
  cursor: grabbing;
}
.sortable-num {
  flex-shrink: 0;
  width: 22px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.sortable-handle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: -4px -4px -4px 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: grab;
  font-size: 20px;
  line-height: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.sortable-handle:active { cursor: grabbing; background: rgba(255, 255, 255, 0.08); }

/* Toast */
.toast-root {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  animation: fade 0.2s ease;
  max-width: 90%;
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--accent); }

/* Misc */
.row-actions { display: flex; gap: 8px; }
.pill { font-size: 12px; color: var(--muted); background: var(--bg-elev-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.spacer { height: 8px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.link { color: var(--accent); cursor: pointer; text-decoration: none; }
.help-ico { text-decoration: none; }
