* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  color-scheme: light;

  --bg: #F9ECE7;
  --card: #FFFFFF;
  --ink: #33201B;
  --muted: #A58B84;
  --line: #EDD6CE;
  --accent: #E8887C;

  --tabbar-h: 62px;

  --on-accent: #FFFFFF;   /* text + icons on accent and on category fills */
  --now: #E5544B;
  --danger: #C0392B;
  --danger-soft: #FBE6E2;
  --shadow-rgb: 51 32 27;

  --c-train: #D34E5C;
  --c-meal: #55A468;
  --c-med: #9666CD;
  --c-class: #7C9CC4;
  --c-task: #E5A75F;

  --c-train-soft: #F7DFE2;  --c-train-ink: #A6414A;
  --c-meal-soft: #E0EFE4;   --c-meal-ink: #4B7F53;
  --c-med-soft: #ECE3F6;    --c-med-ink: #7A529C;
  --c-class-soft: #E7EDF5;  --c-class-ink: #5578A3;
  --c-task-soft: #F9EEDD;   --c-task-ink: #BB7F35;
}

/* ---------- Themes ---------- */
/* Peach is the default (no data-theme, or data-theme="peach").
   Tile swatches for each theme live in THEMES (app.js) — keep them in sync. */

:root[data-theme="lavender"] {
  --bg: #F4F0FC;
  --card: #FFFFFF;
  --ink: #2B2142;
  --muted: #9289AD;
  --line: #E5DDF7;
  --accent: #7C5FD3;
  --shadow-rgb: 43 33 66;
}

:root[data-theme="sage"] {
  --bg: #EDF5EF;
  --card: #FFFFFF;
  --ink: #1E2E24;
  --muted: #83A08C;
  --line: #D6E7DA;
  --accent: #4E9E73;
  --shadow-rgb: 30 46 36;
}

:root[data-theme="purple"] {
  color-scheme: dark;
  --bg: #171226;
  --card: #221C38;
  --ink: #F0ECFA;
  --muted: #9B92B8;
  --line: #322A4E;
  --accent: #8B5CF6;
  --now: #FF6B6B;
  --danger: #F0857A;
  --shadow-rgb: 0 0 0;
}

:root[data-theme="forest"] {
  color-scheme: dark;
  --bg: #0F1A14;
  --card: #18261D;
  --ink: #E8F2EA;
  --muted: #88A491;
  --line: #23372B;
  --accent: #3E9E68;
  --now: #FF6B6B;
  --danger: #F0857A;
  --shadow-rgb: 0 0 0;
}

/* Category tints derive from each theme's own card + ink, so a new theme only
   has to declare the palette above. Peach keeps its hand-picked values. */
:root[data-theme]:not([data-theme="peach"]) {
  --c-train-soft: color-mix(in srgb, var(--c-train) 18%, var(--card));
  --c-meal-soft: color-mix(in srgb, var(--c-meal) 18%, var(--card));
  --c-med-soft: color-mix(in srgb, var(--c-med) 18%, var(--card));
  --c-class-soft: color-mix(in srgb, var(--c-class) 18%, var(--card));
  --c-task-soft: color-mix(in srgb, var(--c-task) 18%, var(--card));
  --danger-soft: color-mix(in srgb, var(--danger) 18%, var(--card));

  --c-train-ink: color-mix(in srgb, var(--c-train) 72%, var(--ink));
  --c-meal-ink: color-mix(in srgb, var(--c-meal) 72%, var(--ink));
  --c-med-ink: color-mix(in srgb, var(--c-med) 72%, var(--ink));
  --c-class-ink: color-mix(in srgb, var(--c-class) 72%, var(--ink));
  --c-task-ink: color-mix(in srgb, var(--c-task) 72%, var(--ink));
}

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

body {
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 18px calc(96px + var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.day-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.day-date {
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  margin-top: 1px;
}

.today-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  color: var(--accent);
  background: var(--card);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(var(--shadow-rgb) / 0.08);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--card);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(var(--shadow-rgb) / 0.08);
}

.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:active { transform: scale(0.94); }

.icon-btn.push-on {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---------- Day strip ---------- */
.day-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.day-pill {
  font-family: inherit;
  border: none;
  background: transparent;
  border-radius: 16px;
  padding: 8px 0 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--ink);
}

.day-pill .dow {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.day-pill .num {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.day-pill .dots {
  display: flex;
  gap: 2px;
  height: 4px;
  margin-top: 2px;
}

.day-pill .dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  display: block;
}

.day-pill.selected {
  background: var(--card);
  box-shadow: 0 2px 10px rgb(var(--shadow-rgb) / 0.08);
}

.day-pill.is-today .num { color: var(--accent); }

.day-pill.selected.is-today .num { color: var(--accent); }

/* ---------- Progress ---------- */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 999px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease;
}

.progress-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Filters ---------- */
.filter-row {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* ---------- Timeline ---------- */
.timeline { padding-top: 8px; }

.tl-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  position: relative;
}

.tl-rail {
  position: relative;
  display: flex;
  justify-content: center;
}

.tl-rail::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--line);
  border-radius: 2px;
}

.tl-row:first-child .tl-rail::before { top: 22px; }
.tl-row.tl-last .tl-rail::before { bottom: calc(100% - 22px); }

.tl-node {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  margin-top: 4px;
  border: 3px solid var(--bg);
}

.tl-node .node-icon {
  width: 19px;
  height: 19px;
  color: var(--on-accent);
}

.tl-node.cat-train { background: var(--c-train); }
.tl-node.cat-meal { background: var(--c-meal); }
.tl-node.cat-med { background: var(--c-med); }
.tl-node.cat-class { background: var(--c-class); }
.tl-node.cat-task { background: var(--c-task); }

.tl-card {
  background: var(--card);
  border-radius: 18px;
  padding: 12px 14px;
  margin: 0 0 10px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 1px 6px rgb(var(--shadow-rgb) / 0.06);
  transition: transform 0.12s ease;
}

.tl-card:active { transform: scale(0.985); }

.tl-card-body { flex: 1; min-width: 0; }

.tl-time {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.2px;
}

.tl-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  margin-top: 1px;
}

.tl-note {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 2px;
}

.tl-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 2px 7px;
  margin-top: 5px;
}

.badge-train { background: var(--c-train-soft); color: var(--c-train-ink); }
.badge-meal { background: var(--c-meal-soft); color: var(--c-meal-ink); }
.badge-med { background: var(--c-med-soft); color: var(--c-med-ink); }
.badge-class { background: var(--c-class-soft); color: var(--c-class-ink); }
.badge-task { background: var(--c-task-soft); color: var(--c-task-ink); }

.tl-check {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}

.tl-check svg {
  width: 14px;
  height: 14px;
  stroke: var(--on-accent);
  stroke-width: 3.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.15s ease;
}

.tl-row.done .tl-check {
  background: var(--accent);
  border-color: var(--accent);
}

.tl-row.done .tl-check svg { opacity: 1; transform: scale(1); }

.tl-row.done .tl-title {
  text-decoration: line-through;
  color: var(--muted);
}

.tl-row.done .tl-card { opacity: 0.72; }
.tl-row.done .tl-node { opacity: 0.55; }

.tl-row.now .tl-card {
  box-shadow: 0 0 0 2px var(--accent), 0 4px 14px color-mix(in srgb, var(--accent) 28%, transparent);
}

.now-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.6px;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 6px;
  padding: 2px 7px;
  margin-left: 6px;
  vertical-align: 1px;
}

/* now line */
.now-line {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  height: 18px;
}

.now-line .dot-wrap {
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.now-line .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--now);
  border: 2px solid var(--bg);
}

.now-line .bar {
  height: 2px;
  background: var(--now);
  border-radius: 2px;
  margin: 0 0 0 2px;
  opacity: 0.85;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  padding: 60px 20px;
}

/* ---------- Week view ---------- */
.week { padding-top: 6px; }

.wk-day {
  margin-bottom: 16px;
  scroll-margin-top: 112px;
}

.wk-day-head {
  width: 100%;
  font-family: inherit;
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ink);
  padding: 4px 4px 7px;
}

.wk-dow {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.wk-date { font-size: 16px; font-weight: 900; }

.wk-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

.wk-day.is-today .wk-dow,
.wk-day.is-today .wk-date { color: var(--accent); }

.wk-card {
  background: var(--card);
  border-radius: 18px;
  padding: 4px;
  box-shadow: 0 1px 6px rgb(var(--shadow-rgb) / 0.06);
}

.wk-day.is-today .wk-card { box-shadow: 0 0 0 2px var(--accent), 0 2px 10px rgb(var(--shadow-rgb) / 0.08); }

.wk-item {
  width: 100%;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 13px;
  cursor: pointer;
  color: var(--ink);
  padding: 6px 10px;
}

.wk-item:active { background: var(--bg); }

.wk-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wk-time {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--muted);
  width: 64px;
  flex-shrink: 0;
}

.wk-title {
  font-size: 13.5px;
  font-weight: 800;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wk-item.done .wk-title { text-decoration: line-through; color: var(--muted); }
.wk-item.done .wk-dot { opacity: 0.45; }

.wk-empty {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 10px 12px;
}

/* ---------- Week grid ---------- */
.wg {
  --wg-gutter: 50px;
  --wg-head: 44px;
  --wg-colw: 112px;
  --wg-hour: 58px;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-snap-type: x proximity;
  scroll-padding-left: var(--wg-gutter);
  scrollbar-width: none;
  margin-top: 6px;
}

.wg::-webkit-scrollbar { display: none; }

.wg-inner {
  display: grid;
  grid-template-columns: var(--wg-gutter) max-content;
  grid-template-rows: var(--wg-head) max-content;
}

.wg-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 4;
  background: var(--bg);
}

.wg-heads {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  background: var(--bg);
}

.wg-head {
  width: var(--wg-colw);
  flex: 0 0 auto;
  font-family: inherit;
  background: transparent;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px 0 6px;
}

.wg-head .dow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.wg-head .num { font-size: 15px; font-weight: 800; }

.wg-head.is-today .dow,
.wg-head.is-today .num { color: var(--accent); }

.wg-head.is-today {
  background: var(--card);
  box-shadow: 0 1px 6px rgb(var(--shadow-rgb) / 0.08);
}

.wg-gutter {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg);
}

.wg-hourlabel {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 9.5px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}

.wg-cols {
  display: flex;
  position: relative;
  background:
    repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--wg-hour));
}

.wg-col {
  width: var(--wg-colw);
  flex: 0 0 auto;
  position: relative;
  border-left: 1px solid var(--line);
  scroll-snap-align: start;
}

.wg-col.is-today { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.wg-item {
  position: absolute;
  font-family: inherit;
  text-align: left;
  border: none;
  border-left: 3px solid var(--c-task);
  border-radius: 7px;
  padding: 3px 4px 2px 5px;
  overflow: hidden;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.15;
  background: var(--c-task-soft);
  color: var(--c-task-ink);
}

.wg-item .wg-t {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wg-item .wg-when {
  display: block;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.75;
}

.wg-item.done { opacity: 0.5; }
.wg-item.done .wg-t { text-decoration: line-through; }

.wg-item.cat-train { background: var(--c-train-soft); color: var(--c-train-ink); border-left-color: var(--c-train); }
.wg-item.cat-meal { background: var(--c-meal-soft); color: var(--c-meal-ink); border-left-color: var(--c-meal); }
.wg-item.cat-med { background: var(--c-med-soft); color: var(--c-med-ink); border-left-color: var(--c-med); }
.wg-item.cat-class { background: var(--c-class-soft); color: var(--c-class-ink); border-left-color: var(--c-class); }
.wg-item.cat-task { background: var(--c-task-soft); color: var(--c-task-ink); border-left-color: var(--c-task); }

.wg-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--now);
  z-index: 2;
  pointer-events: none;
}

.wg-now::before {
  content: '';
  position: absolute;
  left: -3px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--now);
}

/* ---------- Bank ---------- */
.bank-list { padding-top: 8px; }

.bank-row {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border-radius: 18px;
  padding: 4px 8px 4px 4px;
  margin-bottom: 10px;
  box-shadow: 0 1px 6px rgb(var(--shadow-rgb) / 0.06);
}

.bank-body {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: var(--ink);
  padding: 10px;
}

.bank-body:active { background: var(--bg); }

.bank-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bank-text { min-width: 0; }

.bank-title {
  display: block;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-meta {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-edit {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.bank-edit svg { width: 16px; height: 16px; }
.bank-edit:active { background: var(--bg); }

/* ---------- Schedule sheet ---------- */
.sheet-sub {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: -8px 0 16px;
}

.sched-week {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.sched-week .icon-btn {
  width: 30px;
  height: 30px;
  background: var(--bg);
  box-shadow: none;
}

.sched-week .icon-btn svg { width: 15px; height: 15px; }

.sched-range {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.sched-days .day-pill {
  background: var(--bg);
  border-radius: 14px;
}

.sched-days .day-pill.pick { background: var(--accent); }
.sched-days .day-pill.pick .dow,
.sched-days .day-pill.pick .num { color: var(--on-accent); }

.sched-end {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin: -8px 0 14px;
}

/* ---------- Workouts ---------- */
.wo-list, .wo-detail { padding-top: 8px; }

.wo-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wo-head .day-title {
  font-size: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wo-row {
  width: 100%;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--card);
  border: none;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 1px 6px rgb(var(--shadow-rgb) / 0.06);
}

.wo-row:active { transform: scale(0.99); }

.wo-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--c-train);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wo-icon svg { width: 19px; height: 19px; }

.wo-text { min-width: 0; flex: 1; }

.wo-name {
  display: block;
  font-size: 16px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wo-meta {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 2px;
}

.wo-linkline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.wo-editblock {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  background: var(--card);
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.ex-card {
  background: var(--card);
  border-radius: 18px;
  padding: 12px 12px 8px;
  margin-bottom: 12px;
  box-shadow: 0 1px 6px rgb(var(--shadow-rgb) / 0.06);
}

.ex-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.ex-text { flex: 1; min-width: 0; }

.ex-name {
  display: block;
  font-size: 15px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ex-note {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 2px;
}

.ex-edit {
  flex-shrink: 0;
  margin-top: -3px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ex-edit svg { width: 15px; height: 15px; }

.set-head, .set-row {
  display: grid;
  grid-template-columns: 28px 16px 1.35fr 1fr 26px;
  align-items: center;
  gap: 7px;
}

.set-head {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0 4px;
}

.set-head span:nth-child(2) { grid-column: 3; }
.set-head span:nth-child(3) { grid-column: 4; }

.set-row { padding: 3px 0; }

.set-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.set-check svg {
  width: 12px;
  height: 12px;
  stroke: var(--on-accent);
  stroke-width: 3.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.set-row.done .set-check { background: var(--c-train); border-color: var(--c-train); }
.set-row.done .set-check svg { opacity: 1; }
.set-row.done .set-in { color: var(--muted); }

.set-n {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}

.set-in {
  width: 100%;
  min-width: 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  background: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}

.set-in:focus { box-shadow: 0 0 0 2px var(--accent); }
.set-in::-webkit-outer-spin-button,
.set-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.set-x {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.set-x svg { width: 13px; height: 13px; }

.add-row {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 9px 0;
  margin-top: 2px;
  cursor: pointer;
}

.add-row:active { background: var(--bg); }

.tl-link {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--c-train);
}

.tl-link svg { width: 13px; height: 13px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  display: flex;
  background: var(--card);
  border-top: 1.5px solid var(--line);
  padding: 5px 0 calc(4px + env(safe-area-inset-bottom));
  z-index: 20;
}

.tab {
  flex: 1;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 6px 0;
}

.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--accent); }
.tab:active { transform: scale(0.94); }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: max(20px, calc(50% - 240px));
  bottom: calc(20px + var(--tabbar-h) + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent);
  z-index: 20;
}

.fab:active { transform: scale(0.94); }

/* ---------- Sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(var(--shadow-rgb) / 0.35);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 10px 22px calc(24px + env(safe-area-inset-bottom));
  z-index: 31;
  max-height: 88vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  margin: 4px auto 14px;
}

.sheet-title {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 14px;
}

.field { display: block; margin-bottom: 14px; }

.field > span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.field > span em { text-transform: none; font-style: normal; font-weight: 700; opacity: 0.7; }

.field select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

.field input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

.field input:focus { box-shadow: 0 0 0 2px var(--accent); }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.cat-picker, .scope-picker { display: flex; gap: 6px; }

.cat-picker button, .scope-picker button {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 4px;
  cursor: pointer;
}

.cat-picker button.active[data-cat="train"] { border-color: var(--c-train); color: var(--c-train-ink); background: var(--c-train-soft); }
.cat-picker button.active[data-cat="meal"] { border-color: var(--c-meal); color: var(--c-meal-ink); background: var(--c-meal-soft); }
.cat-picker button.active[data-cat="med"] { border-color: var(--c-med); color: var(--c-med-ink); background: var(--c-med-soft); }
.cat-picker button.active[data-cat="class"] { border-color: var(--c-class); color: var(--c-class-ink); background: var(--c-class-soft); }
.cat-picker button.active[data-cat="task"] { border-color: var(--c-task); color: var(--c-task-ink); background: var(--c-task-soft); }

.scope-picker button.active {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--card);
}

/* ---------- Theme picker ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.theme-tile {
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 11px 12px;
}

.theme-tile.active {
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 2px 10px rgb(var(--shadow-rgb) / 0.08);
}

.theme-swatch { display: flex; gap: 5px; }

.theme-swatch i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: block;
  box-shadow: inset 0 0 0 1.5px rgb(var(--shadow-rgb) / 0.10);
}

.theme-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.theme-tile.active .theme-name { color: var(--ink); }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-delete, .btn-save {
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  padding: 14px 0;
  cursor: pointer;
}

.btn-delete {
  flex: 1;
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-save {
  flex: 2;
  background: var(--accent);
  color: var(--on-accent);
}

[hidden] { display: none !important; }

/* ---------- Desktop (≥900px) ----------
   "Wide week": the app frame widens so the Week grid fits all 7 days
   (sizeWeekGrid switches from 3 to 7 visible columns); list-y screens
   cap at a readable 640px. Phone layout is untouched below 900px. */
@media (min-width: 900px) {
  .app, .tabbar { max-width: 980px; }

  #screenToday, #screenBank, #screenWorkouts, #screenWorkout {
    max-width: 640px;
    margin: 0 auto;
  }

  /* The FAB only shows on the 640px screens — pin it to their edge. */
  .fab { right: max(20px, calc(50% - 300px)); }
}
