*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --serif: "Bricolage Grotesque", -apple-system, sans-serif;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ============ DARK (default) ============ */
:root, html[data-mode="dark"] {
  --bg: oklch(0.16 0.006 60);
  --bg-elev: oklch(0.20 0.006 60);
  --surface: oklch(0.22 0.006 60);
  --surface-2: oklch(0.26 0.006 60);
  --line: oklch(0.32 0.006 60);
  --line-soft: oklch(0.26 0.006 60);
  --text: oklch(0.96 0.005 80);
  --text-dim: oklch(0.78 0.006 60);
  --muted: oklch(0.58 0.008 60);
  --faint: oklch(0.40 0.008 60);
}

html[data-mode="light"] {
  --bg: oklch(0.965 0.006 80);
  --bg-elev: oklch(0.99 0.004 80);
  --surface: oklch(0.99 0.004 80);
  --surface-2: oklch(0.94 0.006 80);
  --line: oklch(0.86 0.006 80);
  --line-soft: oklch(0.91 0.006 80);
  --text: oklch(0.18 0.008 60);
  --text-dim: oklch(0.32 0.008 60);
  --muted: oklch(0.48 0.008 60);
  --faint: oklch(0.68 0.008 60);
}

/* Accents — bolder, more confident hues */
html[data-accent="lime"] { --accent: oklch(0.91 0.21 118); --accent-soft: oklch(0.91 0.21 118 / 0.18); --accent-ink: oklch(0.18 0.05 118); }
html[data-accent="terracotta"] { --accent: oklch(0.68 0.16 32); --accent-soft: oklch(0.68 0.16 32 / 0.18); --accent-ink: oklch(0.96 0.005 80); }
html[data-accent="cobalt"] { --accent: oklch(0.62 0.22 260); --accent-soft: oklch(0.62 0.22 260 / 0.18); --accent-ink: oklch(0.96 0.005 80); }
html[data-accent="magenta"] { --accent: oklch(0.68 0.26 350); --accent-soft: oklch(0.68 0.26 350 / 0.18); --accent-ink: oklch(0.96 0.005 80); }

/* Density */
html[data-density="comfy"] { --pad-card: 18px; --gap-card: 14px; --row-h: 48px; }
html[data-density="compact"] { --pad-card: 12px; --gap-card: 8px; --row-h: 40px; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  font-feature-settings: "ss01", "cv01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

body { overflow-x: hidden; }

/* Type primitives */
.serif { font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; }
.mono { font-family: var(--mono); font-feature-settings: "tnum", "zero"; }
.kicker {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Tabs (bottom-floating) */
.tabs-fixed {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 38%, var(--bg));
  z-index: 50;
  pointer-events: none;
}
.tabs-inner {
  max-width: 540px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px; display: flex; gap: 2px;
  pointer-events: auto;
  box-shadow: 0 12px 32px -16px rgba(0,0,0,0.6);
}
.tab-btn {
  flex: 1; padding: 10px 0; background: transparent; border: none;
  color: var(--muted); font-family: var(--sans); font-size: 13px; font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px; cursor: pointer; transition: all 160ms ease;
}
.tab-btn:hover { color: var(--text-dim); }
.tab-btn.active { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 2px 8px rgba(0,0,0,0.18); }

.page {
  max-width: 540px;
  margin: 0 auto;
  padding: 28px 18px 200px;
}

/* ===== Hero ===== */
.hero {
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 16px;
  padding: 4px 4px 22px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 22px;
}
.hero-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 60px;
  line-height: 0.92;
  letter-spacing: -0.035em;
}
.hero-title .italic { font-weight: 800; font-style: italic; color: var(--accent); }
.hero-date-input {
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 4px 0;
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
}
.hero-date-input:focus { outline: none; }
.hero-date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.5) sepia(1) saturate(5) hue-rotate(-20deg);
  cursor: pointer;
  opacity: 0.7;
  margin-left: 4px;
}
html[data-mode="light"] .hero-date-input::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.55;
}
.hero-meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hero-meta .date {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.15em;
}
.hero-meta .gym {
  font-family: var(--serif); font-weight: 600;
  font-size: 18px; color: var(--text-dim);
  line-height: 1;
}

.mode-toggle {
  background: var(--surface); border: 1px solid var(--line);
  width: 38px; height: 38px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  transition: all 200ms ease;
}
.mode-toggle:hover {
  color: var(--accent); border-color: var(--accent);
  transform: rotate(15deg);
}
.mode-toggle svg { width: 18px; height: 18px; }

/* ===== Day picker ===== */
.day-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 26px; }
.day-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 14px 14px 13px;
  cursor: pointer; transition: all 160ms ease;
  text-align: left;
  font-family: inherit; color: inherit;
  overflow: hidden;
}
.day-card:hover { border-color: var(--line); transform: translateY(-1px); }
.day-card.active {
  background: var(--bg-elev);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.day-card.active::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 14px; height: 2px;
  background: var(--accent);
}
.day-card .num {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: 0.15em;
}
.day-card .name {
  font-family: var(--serif); font-weight: 700;
  font-size: 24px; line-height: 1; margin-top: 4px;
  letter-spacing: -0.025em;
}
.day-card.active .name { color: var(--accent); }
.day-card .focus {
  font-family: var(--sans); font-weight: 500;
  font-size: 12px; color: var(--muted); margin-top: 6px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

/* ===== Exercise card ===== */
.exercise {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: var(--pad-card);
  margin-bottom: var(--gap-card);
  position: relative;
  overflow: hidden;
}
.exercise.has-progress::before {
  content: ""; position: absolute; top: 0; left: 0; height: 3px;
  background: var(--accent);
  width: var(--progress, 0%);
  transition: width 240ms ease;
}
.ex-head {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  margin-bottom: 10px;
}
.ex-num {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 34px;
  line-height: 0.85;
  color: var(--faint);
  letter-spacing: -0.05em;
  padding-top: 2px;
  font-variant-numeric: lining-nums;
}
.ex-name-block { min-width: 0; }
.ex-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin-bottom: 4px;
}
.ex-meta { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ex-reps {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent);
}
.ex-last {
  font-family: var(--mono); font-size: 11.5px;
  color: var(--muted);
}
.ex-last .v { color: var(--text-dim); }
.info-btn {
  background: transparent; border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 6px 10px; border-radius: 999px; cursor: pointer;
  transition: all 140ms ease;
}
.info-btn:hover { border-color: var(--accent); color: var(--accent); }

.chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 14px;
}
.chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 6px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 140ms ease;
  font-family: inherit;
}
.chip:hover { border-color: var(--text-dim); color: var(--text); }
.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Sets */
.sets-head {
  display: grid; grid-template-columns: 28px 1fr 1fr 44px;
  gap: 6px; margin-bottom: 4px;
  padding: 0 6px;
}
.sets-head span {
  font-family: var(--mono); font-size: 9.5px;
  color: var(--faint); letter-spacing: 0.18em; text-transform: uppercase;
  text-align: center;
}
.sets-head .l { text-align: left; }

.set-row {
  display: grid; grid-template-columns: 28px 1fr 1fr 44px;
  gap: 6px; align-items: center;
  margin-bottom: 6px;
  transition: opacity 200ms;
}
.set-row.done .set-num { color: var(--accent); }
.set-num {
  font-family: var(--serif); font-weight: 700;
  font-size: 20px; text-align: center;
  color: var(--text-dim); line-height: 1;
}
.set-input {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  height: var(--row-h);
  padding: 0 10px;
  color: var(--text);
  font-family: var(--mono); font-size: 17px; font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: all 140ms ease;
  width: 100%;
}
.set-input::placeholder { color: var(--faint); font-weight: 400; }
.set-input:focus { outline: none; border-color: var(--accent); background: var(--bg-elev); }
.set-input::-webkit-outer-spin-button, .set-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.set-input[type=number] { -moz-appearance: textfield; }

.done-btn {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  height: var(--row-h);
  cursor: pointer; transition: all 140ms ease;
  color: var(--faint);
  display: flex; align-items: center; justify-content: center;
}
.done-btn:hover { color: var(--text-dim); }
.set-row.done .done-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.done-btn svg { width: 18px; height: 18px; }

.row-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px;
}
.add-set {
  background: transparent; border: 1px dashed var(--line);
  color: var(--text-dim);
  padding: 9px 14px; border-radius: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; flex: 1;
  transition: all 140ms ease;
}
.add-set:hover { border-color: var(--accent); color: var(--accent); }
.remove-set {
  background: transparent; border: none;
  color: var(--faint);
  font-family: var(--mono); font-size: 10px;
  cursor: pointer; padding: 6px 10px;
  letter-spacing: 0.1em; text-transform: uppercase;
}
.remove-set:hover { color: var(--accent); }

/* Date + notes blocks */
.field {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 14px 16px;
  margin-bottom: var(--gap-card);
}
.field label {
  display: block;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.field input, .field textarea {
  width: 100%; background: transparent; border: none;
  color: var(--text); font-family: inherit; font-size: 15px;
  resize: none;
}
.field input:focus, .field textarea:focus { outline: none; }
.field input[type=date] {
  font-family: var(--mono); letter-spacing: 0.04em;
}

/* Save bar */
.save-bar {
  position: fixed; bottom: 78px; left: 0; right: 0;
  z-index: 40; padding: 0 18px;
  pointer-events: none;
}
.save-bar-inner {
  max-width: 540px; margin: 0 auto;
  display: flex; gap: 8px;
  pointer-events: auto;
}
.btn {
  padding: 14px 18px; border-radius: 12px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer; border: none;
  transition: all 140ms ease;
}
.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  flex: 2;
  box-shadow: 0 8px 24px -10px var(--accent);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--line);
  flex: 1;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

/* Rest timer */
.rest-timer {
  position: fixed; left: 18px; right: 18px; bottom: 142px;
  max-width: 540px; margin: 0 auto;
  background: var(--bg-elev); border: 1px solid var(--accent);
  border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 12px 32px -12px rgba(0,0,0,0.5);
  z-index: 45;
  animation: rest-in 240ms ease-out;
}
@keyframes rest-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.rest-timer .label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted);
}
.rest-timer .countdown {
  font-family: var(--serif); font-size: 30px; line-height: 1;
  color: var(--accent); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.rest-timer .bar {
  flex: 1; height: 4px; background: var(--surface-2);
  border-radius: 2px; overflow: hidden;
}
.rest-timer .bar-fill {
  height: 100%; background: var(--accent);
  transition: width 1000ms linear;
}
.rest-timer .dismiss {
  background: transparent; border: none; color: var(--faint);
  cursor: pointer; font-family: var(--mono); font-size: 11px;
  padding: 4px;
}
.rest-timer .dismiss:hover { color: var(--text); }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: 160px;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: all 240ms ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* History */
.history-entry {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 12px;
  position: relative;
}
.hist-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.hist-date-block { display: flex; align-items: baseline; gap: 12px; }
.hist-day-num {
  font-family: var(--serif); font-weight: 700;
  font-size: 40px; line-height: 0.85;
  color: var(--text); letter-spacing: -0.04em;
}
.hist-day-meta {
  display: flex; flex-direction: column; gap: 1px;
}
.hist-month {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted);
}
.hist-weekday {
  font-family: var(--serif); font-weight: 500;
  font-size: 14px; color: var(--text-dim);
}
.hist-pill {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--accent);
  padding: 4px 10px; border: 1px solid var(--accent);
  border-radius: 999px;
}
.hist-ex {
  padding: 10px 0; border-top: 1px solid var(--line-soft);
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: baseline;
}
.hist-ex-name {
  font-family: var(--serif); font-weight: 600;
  font-size: 17px; letter-spacing: -0.02em;
}
.hist-ex-eq {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px;
}
.hist-ex-sets {
  font-family: var(--mono); font-size: 13px; color: var(--text-dim);
  text-align: right; font-variant-numeric: tabular-nums;
}
.hist-notes {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--sans);
  color: var(--muted); font-size: 14px;
  line-height: 1.5;
}
.hist-notes::before { content: "“"; color: var(--accent); font-family: var(--serif); font-size: 22px; margin-right: 2px; vertical-align: -3px; }
.hist-notes::after { content: "”"; color: var(--accent); font-family: var(--serif); font-size: 22px; margin-left: 2px; vertical-align: -3px; }
.hist-delete {
  background: transparent; border: none;
  color: var(--faint); cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 8px;
}
.hist-delete:hover { color: var(--accent); }

/* Stats */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 16px; padding: 18px;
  position: relative; overflow: hidden;
}
.stat-card.span-2 { grid-column: 1 / -1; }
.stat-card .kicker { margin-bottom: 8px; }
.stat-card .big {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 56px; line-height: 0.9;
  letter-spacing: -0.045em;
  color: var(--text);
}
.stat-card .big .unit {
  font-size: 18px; color: var(--muted); margin-left: 4px;
  font-weight: 500;
}
.stat-card .sub {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  margin-top: 6px; letter-spacing: 0.04em;
}

.day-breakdown { display: flex; flex-direction: column; gap: 0; }
.day-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 14px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line-soft);
}
.day-row:first-child { border-top: none; }
.day-row .name { font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: -0.02em; }
.day-row .bar {
  height: 6px; background: var(--surface-2); border-radius: 3px;
  overflow: hidden;
}
.day-row .bar-fill { height: 100%; background: var(--accent); }
.day-row .count {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 13px; color: var(--text-dim);
}

.empty {
  text-align: center; padding: 80px 20px;
  color: var(--muted);
}
.empty .serif { font-size: 28px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; }
.empty p { font-size: 14px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 200ms ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-elev);
  width: 100%; max-width: 540px;
  border-radius: 20px 20px 0 0;
  max-height: 88dvh; overflow-y: auto;
  padding: 22px 22px 32px;
  border: 1px solid var(--line);
  border-bottom: none;
  animation: slide-up 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slide-up { from { transform: translateY(20%); } to { transform: translateY(0); } }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 20px; border: 1px solid var(--line); max-height: 85dvh; }
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 6px; }
.modal-title { font-family: var(--serif); font-weight: 700; font-size: 26px; line-height: 1.05; letter-spacing: -0.03em; }
.modal-sub {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  letter-spacing: 0.15em; text-transform: uppercase;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
}
.modal-close {
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 8px 12px; border-radius: 999px;
  cursor: pointer; flex-shrink: 0;
}
.modal-section { margin-bottom: 20px; }
.modal-section h4 {
  font-family: var(--mono); font-size: 10px; color: var(--accent);
  letter-spacing: 0.2em; text-transform: uppercase;
  margin-bottom: 10px; font-weight: 600;
}
.modal-section p { font-size: 14px; line-height: 1.55; color: var(--text-dim); }
.modal-section ol, .modal-section ul { padding-left: 20px; }
.modal-section li { font-size: 14px; line-height: 1.55; margin-bottom: 4px; color: var(--text-dim); }
.modal-section .cue-list li { color: var(--muted); }
.modal-section .cue-list li::marker { color: var(--accent); }

.demo-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.demo-photo {
  background: var(--surface-2);
  border-radius: 10px; overflow: hidden;
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-soft);
}
.demo-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.demo-photo .label { font-size: 11px; color: var(--muted); padding: 8px; text-align: center; font-family: var(--mono); }
.demo-credit { font-family: var(--mono); font-size: 9.5px; color: var(--faint); text-align: center; margin-top: 8px; letter-spacing: 0.05em; }

.ref-links { display: flex; flex-direction: column; gap: 8px; }
.ref-link {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); padding: 12px 14px;
  border-radius: 10px; text-decoration: none; color: var(--text);
  border: 1px solid var(--line-soft);
  font-size: 13px;
  transition: border-color 140ms;
}
.ref-link:hover { border-color: var(--accent); }
.ref-link .ico {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 13px;
}
.ref-link .lbl { flex: 1; font-family: var(--serif); font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
.ref-link .lbl small {
  display: block; font-family: var(--mono); font-size: 10px;
  color: var(--muted); margin-top: 1px; letter-spacing: 0.06em;
}

/* Tab content reveal — only on an actual tab switch (class added in JS),
   never on in-tab re-renders, so day/chip/set changes don't re-flash. */
.tab-content.tab-enter { animation: tab-in 240ms ease; }
@keyframes tab-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Settings popover (replaces the host-protocol tweaks panel) ===== */
#settings-host { position: fixed; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 60; }
.settings-fab {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px -14px rgba(0,0,0,0.7);
  transition: color 160ms ease, border-color 160ms ease, transform 200ms ease;
}
.settings-fab:hover { color: var(--accent); border-color: var(--accent); transform: rotate(30deg); }
.settings-fab svg { width: 19px; height: 19px; }
.settings-panel {
  position: absolute; right: 0; bottom: 52px;
  width: 260px;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px;
  box-shadow: 0 16px 40px -16px rgba(0,0,0,0.6);
  animation: rest-in 200ms ease-out;
}
.settings-panel[hidden] { display: none; }
.settings-row { margin-bottom: 16px; }
.settings-row:last-child { margin-bottom: 0; }
.settings-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}
.seg { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 999px; padding: 4px; }
.seg-btn {
  flex: 1; border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-family: var(--sans); font-size: 12px; font-weight: 600;
  padding: 7px 0; border-radius: 999px; transition: all 140ms ease;
}
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
.swatches { display: flex; gap: 8px; }
.sw {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  transition: transform 140ms ease;
}
.sw:hover { transform: scale(1.08); }
.sw.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--text); }
#settings-host input[type=range] {
  width: 100%; accent-color: var(--accent); cursor: pointer;
  background: transparent;
}

/* ===== Edit history ===== */
.hist-edit {
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 4px 8px;
}
.hist-edit:hover { color: var(--accent); }

.edit-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--text-dim);
}
.edit-banner #discard-edit {
  background: var(--accent); color: var(--accent-ink);
  border: none; cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px;
  flex-shrink: 0;
}
.edit-banner #discard-edit:hover { filter: brightness(1.08); }

/* ===== History export / import ===== */
.hist-actions { display: flex; gap: 8px; align-items: center; }
.io-btn {
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-dim); cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 12px; border-radius: 999px;
  transition: color 140ms ease, border-color 140ms ease;
}
.io-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ===== Location selector ===== */
.settings-select {
  width: 100%;
  background: var(--surface); border: 1px solid var(--line-soft);
  color: var(--text); cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  padding: 9px 12px; border-radius: 10px;
  appearance: none; -webkit-appearance: none;
}
.settings-select:focus { outline: none; border-color: var(--accent); }

/* ===== Per-entry gym label in history ===== */
.hist-loc {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
  padding: 4px 9px; border: 1px solid var(--line-soft);
  border-radius: 999px;
}

/* ===== Per-entry program label in history ===== */
.hist-prog {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-dim);
  padding: 4px 9px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface-2);
}
