/* MultiTool — base styles. Dark by default; light theme via [data-theme=light]
   or the system preference. Everything is sized for phones first. */

:root {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f242c;
  --border: #2a313b;
  --text: #e6e9ee;
  --muted: #8b95a5;
  --accent: #f5a524;
  --accent-ink: #1a1200;
  --accent-2: #2dd4bf;
  --danger: #ef5350;
  --success: #4ade80;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Hanken Grotesk', sans-serif;
  --mono: ui-monospace, 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* charts (stats page): one blue for single series, GitHub-like greens for
     tracked workouts, orange for "other" workouts, a faint red for empty weeks */
  --chart-1: #3987e5;
  --chart-empty: rgba(239, 83, 80, 0.11);
  --heat-0: #1c2a21;
  --heat-1: #0e4429;
  --heat-2: #006d32;
  --heat-3: #26a641;
  --heat-4: #39d353;
  --heat-other: #d95926;
  /* categorical (muscle groups, exercises): fixed order, one hue each */
  --cat-1: #3987e5;
  --cat-2: #d95926;
  --cat-3: #3fb56f;
  --cat-4: #a78bfa;
  --cat-5: #2dd4bf;
  --cat-6: #ec6fa8;
  --cat-7: #e3b341;
  --cat-8: #8b9cf3;
  --cat-9: #c0864a;
  --cat-10: #5ec8e5;
  --cat-11: #9aa78b;
  --chart-other: #6b7280;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef1f5;
    --border: #d9dee6;
    --text: #151a21;
    --muted: #5f6b7a;
    --accent: #d98c07;
    --accent-ink: #fff8ea;
    --accent-2: #0f9d8a;
    --shadow: 0 1px 2px rgba(20, 30, 40, 0.08);
    --chart-1: #2a78d6;
    --chart-empty: rgba(192, 57, 43, 0.11);
    --heat-0: #e3ebe5;
    --heat-1: #9be9a8;
    --heat-2: #40c463;
    --heat-3: #30a14e;
    --heat-4: #216e39;
    --heat-other: #eb6834;
    --cat-1: #2a78d6;
    --cat-2: #eb6834;
    --cat-3: #2e9e5b;
    --cat-4: #8b5cf6;
    --cat-5: #0f9d8a;
    --cat-6: #d6408b;
    --cat-7: #b8860b;
    --cat-8: #5b6fd6;
    --cat-9: #9a5f2a;
    --cat-10: #1f8fb0;
    --cat-11: #6b7a5c;
    --chart-other: #9aa3ad;
    color-scheme: light;
  }
}
:root[data-theme='light'] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #d9dee6;
  --text: #151a21;
  --muted: #5f6b7a;
  --accent: #d98c07;
  --accent-ink: #fff8ea;
  --accent-2: #0f9d8a;
  --shadow: 0 1px 2px rgba(20, 30, 40, 0.08);
  --chart-1: #2a78d6;
  --chart-empty: rgba(192, 57, 43, 0.11);
  --heat-0: #e3ebe5;
  --heat-1: #9be9a8;
  --heat-2: #40c463;
  --heat-3: #30a14e;
  --heat-4: #216e39;
  --heat-other: #eb6834;
  --cat-1: #2a78d6;
  --cat-2: #eb6834;
  --cat-3: #2e9e5b;
  --cat-4: #8b5cf6;
  --cat-5: #0f9d8a;
  --cat-6: #d6408b;
  --cat-7: #b8860b;
  --cat-8: #5b6fd6;
  --cat-9: #9a5f2a;
  --cat-10: #1f8fb0;
  --cat-11: #6b7a5c;
  --chart-other: #9aa3ad;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  -webkit-tap-highlight-color: transparent;
}
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a.link {
  color: var(--accent-2);
  text-decoration: none;
}
a.link:hover {
  text-decoration: underline;
}
.muted {
  color: var(--muted);
  margin: 0 0 12px;
}
.center {
  text-align: center;
}
.error {
  color: var(--danger);
  margin: 4px 0 0;
  font-size: 14px;
}
.fatal {
  white-space: pre-wrap;
  padding: 16px;
  color: var(--danger);
  font-family: var(--mono);
  font-size: 13px;
}

/* ---- Layout ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(8px + var(--safe-top)) 8px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .title {
  flex: 1;
  margin: 0 8px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.host {
  flex: 1;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
/* The workout grid is a spreadsheet: on a wide screen it gets the whole window. */
.host:has(.wk) {
  max-width: none;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row-between {
  justify-content: space-between;
}
.spacer {
  flex: 1;
}

/* ---- Icons & buttons ---- */
.icon {
  width: 22px;
  height: 22px;
  flex: none;
}
.icon-xl {
  width: 56px;
  height: 56px;
  color: var(--muted);
}
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.iconbtn:active {
  background: var(--surface-2);
}
.iconbtn.active {
  color: var(--accent);
}
.iconbtn-sm {
  width: 40px;
  height: 40px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.btn .icon {
  width: 18px;
  height: 18px;
}
.btn:active {
  filter: brightness(1.15);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-text {
  background: transparent;
  border-color: transparent;
  color: var(--accent-2);
}
.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- Home grid ---- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.tool-card:active {
  background: var(--surface-2);
}
.tool-card-icon {
  display: inline-flex;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--accent);
  margin-bottom: 4px;
}
.tool-card-name {
  font-weight: 650;
  font-size: 17px;
}
.tool-card-desc {
  font-size: 13px;
  color: var(--muted);
}
.tool-card-status {
  margin-top: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 16px;
  text-align: center;
}
.empty p {
  margin: 0;
}

/* ---- Lists / settings ---- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.list-row:first-child {
  border-top: 0;
}
.list-icon {
  display: inline-flex;
  color: var(--accent);
}
.list-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.list-title {
  font-weight: 600;
}
.list-sub {
  font-size: 13px;
  color: var(--muted);
}
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: var(--border);
  transition: background 0.15s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch input:checked + .switch-track {
  background: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field-label {
  font-weight: 600;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.seg + .seg {
  border-left: 1px solid var(--border);
}
.seg-active {
  background: var(--surface-2);
  color: var(--text);
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0 0 12px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
}
.notice {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  margin: 12px 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  font-size: 14px;
}

/* ---- Inputs ---- */
.input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  margin-bottom: 10px;
}
.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.input-num {
  font-family: var(--mono);
  font-size: 22px;
  text-align: center;
  padding: 0 4px;
  margin: 0;
  -moz-appearance: textfield;
}
.input-num::-webkit-outer-spin-button,
.input-num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}
.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

/* ---- Timer tool ---- */
.timer-form {
  margin-bottom: 16px;
}
.duration-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.duration-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.chip:active {
  border-color: var(--accent);
}
.chip-muted {
  color: var(--muted);
}
.timer-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.timer-card {
  position: relative;
  overflow: hidden;
}
.timer-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}
.timer-name {
  font-weight: 650;
  font-size: 17px;
}
.timer-meta {
  font-size: 13px;
  color: var(--muted);
}
.countdown {
  font-family: var(--mono);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
}
.timer-card[data-state='idle'] .countdown {
  color: var(--muted);
}
.timer-card[data-state='paused'] .countdown {
  color: var(--accent-2);
}
.progress {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s linear;
}
.timer-card[data-state='paused'] .progress-bar {
  background: var(--accent-2);
}
.timer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.timer-card.ringing {
  border-color: var(--accent);
  animation: ring-pulse 1s ease-in-out infinite;
}
.timer-card.ringing .countdown {
  color: var(--accent);
}
@keyframes ring-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
  }
  50% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

/* ---- Toasts ---- */
.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
  z-index: 100;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 480px;
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}
.toast-out {
  opacity: 0;
  transition: opacity 0.2s;
}
@keyframes toast-in {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

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

/* ---- Shared editor bits ---- */
.row-end {
  justify-content: flex-end;
}
.muted-inline {
  color: var(--muted);
  font-size: 13px;
}
.field-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.field-col .input {
  margin-bottom: 0;
}
.input-short {
  width: 96px;
  flex: none;
}
.textarea {
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.4;
}
.colour-input {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  flex: none;
}
.check-inline {
  min-height: 36px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger-text {
  color: var(--danger);
}
.btn-back {
  align-self: flex-start;
  padding-left: 4px;
}
.segmented-sm .seg {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}
.chip-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
}
.chip-mark {
  font-family: var(--mono);
}
.chip-tag {
  font-weight: 600;
}
.chip-add {
  border-style: dashed;
  color: var(--muted);
}
.chip-input {
  width: 180px;
  margin-bottom: 0;
}
.chip-input[hidden] {
  display: none;
}
.list-btn {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 52px;
}
.list-btn:first-child {
  border-top: 0;
}
.list-btn:active {
  background: var(--surface-2);
}
.list-current .list-title {
  color: var(--accent);
}
.editor-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.editor-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: #fff;
  flex: none;
}
.swatch-active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--accent);
}
.swatch-star {
  background: var(--surface-2);
  color: var(--accent);
}
.swatch-none {
  background: var(--surface-2);
  color: var(--muted);
}
.swatch-sm {
  width: 22px;
  height: 22px;
}
.swatch-sm .icon {
  width: 14px;
  height: 14px;
}
.ex-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.ex-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.ex-row:first-child {
  border-top: 0;
}
.ex-row .input {
  margin-bottom: 0;
}
.ex-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.ex-actions {
  display: flex;
  flex-direction: column;
}

/* ---- Exercise form: label column + wrapping field groups (Exercise / Weight / Timer) ---- */
.exf {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 12px;
  align-items: start;
  flex: 1;
  min-width: 0;
}
.exf-label {
  padding-top: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.exf-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  min-width: 0;
}
.exf-fields .input {
  margin-bottom: 0;
}
.exf-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.exf-item[hidden] {
  display: none;
}
.exf-item .muted-inline {
  white-space: nowrap;
}
.exf-grow {
  flex: 1 1 200px;
  min-width: 0;
}
.exf-full {
  flex-basis: 100%;
}
.exf-select {
  width: auto;
  flex: none;
}
.input-xs {
  width: 64px;
  flex: none;
}
.chip-toggle {
  min-height: 32px;
  font-size: 13px;
}
.ex-rest-set {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ex-rest-set .input-short {
  width: 72px;
}
@media (max-width: 560px) {
  .exf {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .exf-label {
    padding-top: 6px;
  }
  .exf-label:not(:first-child) {
    margin-top: 4px;
  }
}
@media (min-width: 900px) {
  /* a sheet across a 2000 px window stretches every field; keep it readable */
  .sheet-panel {
    width: min(100%, 980px);
    margin: 0 auto;
  }
}

/* ---- Bottom sheet ---- */
body.sheet-open {
  overflow: hidden;
}
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.18s;
}
.sheet-panel {
  position: relative;
  max-height: 88dvh;
  overflow: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 6px 16px calc(16px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.18s ease-out;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}
.sheet-in .sheet-backdrop {
  opacity: 1;
}
.sheet-in .sheet-panel {
  transform: translateY(0);
}
.sheet-handle {
  width: 36px;
  height: 4px;
  margin: 4px auto 6px;
  border-radius: 2px;
  background: var(--border);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.sheet-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-actions {
  margin-top: 8px;
}
.set-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.set-pos {
  font-weight: 600;
}
.input-set {
  font-family: var(--mono);
  font-size: 28px;
  min-height: 56px;
  text-align: center;
}

/* ---- Workout grid ---- */
.wk {
  display: flex;
  flex-direction: column;
  margin: -16px -16px calc(-24px - var(--safe-bottom));
  height: calc(100dvh - 61px - var(--safe-top));
}
/* Slim bar above each grid — phones only; wide screens use the corner cell,
   the side arrows and the menu in the bottom-right cell instead. */
.wk-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  /* the grid may be wider than the window: keep the bar in view
     (100cqw = the scroll container's width, see .wk-scroll) */
  position: sticky;
  left: 0;
  width: 100cqw;
  max-width: 100%;
  box-sizing: border-box;
}
.wk-label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  padding: 4px;
}
.wk-label-title {
  font-weight: 650;
  font-size: 15px;
}
.wk-label-sub {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}
.wk-scroll {
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(24px + var(--safe-bottom));
  container-type: inline-size;
}
.wk-grid {
  min-width: max-content;
}
/* From 1200 px a full week usually fits, so the bar gives way to the side
   arrows and the menu in the grid's corner. */
@media (min-width: 1200px) {
  .wk-bar {
    display: none;
  }
}
.wk-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 15px;
}
.wk-table th,
.wk-table td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 0;
  vertical-align: top;
}
.wk-tinted {
  background: color-mix(in srgb, var(--cell-bg) 38%, var(--bg)) !important;
}
.wk-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  font-weight: 650;
  text-align: left;
}
.wk-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  font-weight: 600;
}
.wk-table th.wk-corner {
  left: 0;
  z-index: 3;
}
/* the week's label + start date in the corner cell */
.wk-corner-btn {
  min-width: 96px;
  gap: 2px;
}
.wk-corner-date {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}
.wk-hbtn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  min-height: 48px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}
.wk-hbtn-add {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  white-space: nowrap;
}
.wk-ex {
  min-width: 96px;
}
.wk-ex-name {
  white-space: nowrap;
}
.wk-ex-weight {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.wk-ex-note {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  white-space: normal;
  max-width: 220px;
  line-height: 1.25;
}
.wk-day {
  min-width: 72px;
}
.wk-day-name {
  white-space: nowrap;
}
.wk-day-bw {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--mono);
}
.wk-day-bw-empty {
  color: var(--accent-2);
}
.wk-marks {
  color: var(--accent);
  font-family: var(--mono);
}
/* word marks ticked on a day ("Pre-workout"), small pills under the weekday */
.wk-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 140px;
}
.wk-tag {
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  line-height: 17px;
  white-space: nowrap;
}
.wk-cell {
  position: relative;
  min-width: 52px;
}
.wk-cell-first {
  border-left: 2px solid var(--border);
}
/* "worked out, but not tracked": one cell across the exercise columns */
.wk-alt {
  text-align: left;
}
.field-hint {
  font-size: 12px;
  margin: 4px 0 0;
}
.wk-cbtn {
  width: 100%;
  min-width: 52px;
  min-height: 48px;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  font-size: 15px;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}
.wk-cbtn:active {
  background: var(--surface-2);
}
.wk-cbtn sup {
  font-size: 10px;
  color: var(--accent-2);
  margin-left: 1px;
}
.wk-cbtn-alt {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-2);
  text-align: left;
  white-space: normal;
  padding: 6px 10px;
}
.wk-cbtn-alt .icon {
  color: var(--muted);
}
.wk-notes {
  position: relative;
  min-width: 180px;
  max-width: 260px;
}
.wk-cbtn-notes {
  font-family: var(--font);
  font-size: 13px;
  text-align: left;
  white-space: normal;
  line-height: 1.3;
}
.wk-notes-h {
  min-width: 180px;
  padding: 6px 8px !important;
}
.wk-star {
  position: absolute;
  top: 2px;
  right: 3px;
  width: 12px;
  height: 12px;
  color: var(--accent);
  pointer-events: none;
}
.wk-empty-row {
  padding: 16px !important;
  color: var(--muted);
}
/* top bar: legend + view control */
.wk-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.wk-legend {
  flex: 1 1 320px;
  min-width: 0;
}
.wk-legend summary {
  cursor: pointer;
  list-style: none;
  margin: 0;
  padding: 6px 0;
}
.wk-legend summary::-webkit-details-marker {
  display: none;
}
.wk-legend summary::before {
  content: '▸ ';
  color: var(--muted);
}
.wk-legend[open] summary::before {
  content: '▾ ';
}
/* colours in one column, marks in the next; both left aligned */
.wk-legend-cols {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 40px;
  margin: 2px 0 8px;
}
.wk-legend-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.wk-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.wk-legend-hint {
  font-size: 12px;
  margin: 0 0 4px;
}
.wk-viewctl {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding-top: 2px;
}
.wk-per-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.wk-per {
  width: 56px;
  min-height: 32px;
  padding: 2px 6px;
}
/* page tabs (X weeks per page) — clear space below the legend so they read as
   part of the week list, not of the legend */
.wk-tabs {
  display: flex;
  gap: 6px;
  padding: 18px 12px 4px;
  overflow-x: auto;
  background: var(--bg);
  scrollbar-width: thin;
}
@media (min-width: 900px) {
  .wk-tabs {
    justify-content: center;
  }
}
.wk-tab {
  flex: none;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.wk-tab-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
/* week blocks: every week is as wide as the widest one on the page (the
   column is sized by its widest child and the children stretch to it), the
   block is centred in the window on wide screens, and a grid wider than the
   window scrolls. Phones let the column fill the screen so the slim bar spans
   it. */
.wk-weeks {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 28px;
  min-width: max-content;
  padding: 0 0 16px;
}
@media (min-width: 900px) {
  .wk-weeks {
    width: max-content;
    min-width: 0;
    margin: 0 auto;
    padding-top: 12px;
  }
}
.wk-week {
  min-width: max-content;
}
.wk-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.wk-row .wk-grid {
  flex: 1;
}
/* fill the common width; extra space is shared out across the columns, so a
   narrower week's cells grow a little instead of leaving a ragged right edge */
.wk-row .wk-table {
  width: 100%;
}
/* ‹ › on each side of the grid box (1-week mode, wide screens) */
.wk-side-arrow {
  display: none;
  flex: none;
  width: 36px;
  height: 56px;
  border-radius: var(--radius-sm);
}
.wk-side-arrow:disabled {
  opacity: 0.25;
}
@media (min-width: 1200px) {
  .wk-side-arrow {
    display: inline-flex;
  }
}
.wk-bar-multi {
  justify-content: space-between;
}
.wk-bar-multi .wk-label {
  justify-content: flex-start;
  padding-left: 8px;
}
.wk-mode-one .wk-bar {
  border-top: 0;
}
.wk-tabs + .wk-scroll .wk-weeks {
  padding-top: 4px;
}
/* notes row under each grid */
.wk-fnrow td,
.wk-fnrow th {
  border-top: 2px solid var(--border);
  background: var(--surface);
  vertical-align: top;
}
.wk-fnh {
  padding: 8px !important;
  font-size: 13px;
  color: var(--muted);
  text-align: left;
}
.wk-fncell {
  padding: 6px 8px 6px 6px !important;
}
/* Wrap note text to the width the set columns already have instead of widening them. */
.wk-fnwrap {
  width: 0;
  min-width: 100%;
}
.wk-fncell .wk-cbtn-notes {
  min-height: 32px;
  color: var(--muted);
}
/* bottom-right cell: the week note with the week menu in its corner */
.wk-fnlast {
  padding-bottom: 32px !important;
}
.wk-corner-menu {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 30px;
  height: 30px;
  color: var(--muted);
}
.wk-corner-menu:hover {
  color: var(--text);
}
.wk-fn-plain {
  color: var(--text);
}
.wk-fn {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  padding: 2px 0;
  cursor: pointer;
  text-align: left;
  white-space: normal;
}
.wk-fn sup {
  color: var(--accent-2);
  font-weight: 700;
}
.wk-fn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  margin-top: 2px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.wk-fn-add:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.icon-sm {
  width: 14px;
  height: 14px;
}
.wk-mark {
  font-family: var(--mono);
  min-width: 34px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
}

/* ---- sync ------------------------------------------------------------- */
.sync-indicator[data-status='syncing'] .icon {
  animation: sync-pulse 1s ease-in-out infinite;
}
.sync-indicator[data-status='offline'],
.sync-indicator[data-status='error'] {
  color: var(--muted);
}
.sync-indicator[data-status='error'] {
  color: var(--danger, #e5484d);
}
@keyframes sync-pulse {
  50% {
    opacity: 0.35;
  }
}
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.link-code {
  font-family: var(--mono);
  font-size: 34px;
  letter-spacing: 0.12em;
  text-align: center;
  padding: 16px 8px;
  margin: 8px 0;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  user-select: all;
}
.link-code-input {
  font-family: var(--mono);
  font-size: 28px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
  box-sizing: border-box;
}
.recovery-key {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  word-break: break-all;
  padding: 12px;
  margin: 8px 0;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  user-select: all;
}
.mono {
  font-family: var(--mono);
}
.danger-zone summary {
  cursor: pointer;
  font-size: 14px;
}
.danger-zone[open] {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--danger, #e5484d) 40%, transparent);
}

.devices {
  margin-top: 4px;
}
.subtitle {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.devices .list-row {
  gap: 8px;
}
.devices .list-row .iconbtn {
  flex: none;
}

/* ---- Inline editing (workout grid) ---- */
.wk-editing {
  position: relative;
}
.wk-editing > .wk-cbtn {
  visibility: hidden;
}
.inline-edit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  box-sizing: border-box;
  border: 2px solid var(--accent);
  border-radius: 0;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: center;
  padding: 2px 4px;
  outline: none;
  z-index: 4;
}
.inline-mono {
  font-family: var(--mono);
}
.inline-edit-text {
  text-align: left;
  font-size: 13px;
  line-height: 1.3;
  padding: 6px 8px;
  resize: none;
}
.inline-inplace {
  position: static;
  display: block;
  width: 100%;
  height: auto;
  min-height: 2.6em;
  margin: 2px 0;
  border-radius: 6px;
}
.wk-fn-empty {
  color: var(--muted);
  font-style: italic;
}
.wk-link {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.wk-cbtn-alt .wk-link {
  color: inherit;
}

/* ---- Popover (context menus) ---- */
.popover {
  position: fixed;
  z-index: 60;
  min-width: 276px;
  max-width: min(92vw, 360px);
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pop-label {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.pop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
}
.pop-actions .btn {
  white-space: nowrap;
}
.popover .swatches .swatch {
  width: 28px;
  height: 28px;
}

.segmented-xs .seg {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}
.chips-tight {
  gap: 4px;
  margin-bottom: 0;
}
.chips-tight .chip {
  min-height: 28px;
  padding: 0 9px;
  font-size: 13px;
}
.chip-link {
  color: var(--accent-2);
}

/* ---- Workout mode (session.ts) ------------------------------------------- */
.wk-top-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.wk-session-btn {
  gap: 6px;
}
.sess-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.sess-title {
  font-weight: 600;
  flex: 1;
}
/* Today's row: an accent bar on the day cell and a light wash across the row. */
.wk-table tr.wk-today > th.wk-dayh {
  box-shadow: inset 4px 0 0 var(--accent);
}
.wk-table tr.wk-today > td {
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}
.sess-panel {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}
.sess-panel[data-phase='work'] {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}
.sess-panel[data-phase='finished'] {
  background: color-mix(in srgb, #c0392b 16%, var(--surface));
}
.sess-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.sess-count {
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.sess-count-done {
  animation: sess-blink 1s steps(2, start) infinite;
  color: var(--danger, #e05252);
}
.sess-count-watch {
  color: var(--accent);
}
/* the set being done right now: its stopwatch in the cell */
.wk-cell-live > .wk-cbtn {
  color: var(--accent);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.wk-cell-live .wk-live {
  display: inline-block;
}
@keyframes sess-blink {
  to {
    opacity: 0.35;
  }
}
.sess-sub {
  color: var(--muted);
  font-size: 13px;
}
.sess-actions,
.sess-idle,
.sess-timed {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.sess-hint {
  margin: 0;
}
.field-label .field-hint {
  display: block;
  font-weight: 400;
  color: var(--muted);
}
/* Keep toasts clear of the workout-mode panel. */
body:has(.sess-panel) .toasts {
  bottom: calc(170px + var(--safe-bottom));
}

/* ---- Stats page (stats-view.ts, charts.ts) ------------------------------- */
.stats-head {
  flex-wrap: wrap;
}
.stats-range {
  margin-left: auto;
}
.stats-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}
.stats-card {
  margin: 0;
}
.stats-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}
.stats-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.stats-tile-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stats-tile-label {
  font-size: 13px;
  margin-top: 2px;
}
.stats-tile-sub {
  font-size: 12px;
  margin-top: 2px;
}
.stats-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.stats-select {
  flex: 1 1 200px;
  min-width: 0;
}
.stats-note {
  font-size: 12px;
  margin: 6px 0 0;
}
/* charts */
.chart {
  position: relative;
}
.chart-plot {
  width: 100%;
  min-height: 60px;
}
.chart-svg {
  display: block;
  max-width: 100%;
  font-family: var(--font);
  touch-action: pan-y;
}
.chart-gridline {
  stroke: var(--border);
  stroke-width: 1;
}
.chart-baseline {
  stroke: var(--muted);
  stroke-width: 1;
  opacity: 0.6;
}
.chart-ylabel,
.chart-xlabel {
  fill: var(--muted);
  font-size: 11px;
}
.chart-bar {
  stroke: none;
}
.chart-empty-col {
  fill: var(--chart-empty);
}
.chart-empty-tick {
  fill: var(--danger);
  opacity: 0.8;
}
.chart-hover-col {
  fill: var(--text);
  opacity: 0.06;
  pointer-events: none;
}
.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-marker {
  stroke: var(--surface);
  stroke-width: 2;
}
.chart-crosshair {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}
.chart-tip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px 9px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--text);
}
.chart-tip-title {
  font-weight: 600;
  margin-bottom: 2px;
}
.chart-tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-tip-row b {
  font-variant-numeric: tabular-nums;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}
.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chart-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  flex: none;
}
.chart-swatch-line {
  height: 3px;
  width: 14px;
  border-radius: 2px;
}
/* activity map */
.heatmap-wrap {
  position: relative;
  display: flex;
  align-items: flex-start;
}
.heatmap-days {
  flex: none;
  display: flex;
  flex-direction: column;
  width: 30px;
}
.heatmap-day {
  font-size: 11px;
  color: var(--muted);
  line-height: 13px;
}
.heatmap-scroll {
  flex: 1 1 auto;
  min-width: 0;
}
.heatmap-scroll {
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 4px;
}
.heatmap-svg {
  display: block;
  font-family: var(--font);
}
.hm-cell {
  cursor: pointer;
}
.hm-off {
  fill: var(--heat-0);
  background: var(--heat-0);
}
.hm-t1 {
  fill: var(--heat-1);
  background: var(--heat-1);
}
.hm-t2 {
  fill: var(--heat-2);
  background: var(--heat-2);
}
.hm-t3 {
  fill: var(--heat-3);
  background: var(--heat-3);
}
.hm-t4 {
  fill: var(--heat-4);
  background: var(--heat-4);
}
.hm-other {
  fill: var(--heat-other);
  background: var(--heat-other);
}
.heatmap-legend {
  margin: 6px 0 0;
}
.heatmap-legend .chart-swatch + .chart-swatch {
  margin-left: -3px;
}
/* calendar */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.cal-title {
  font-weight: 600;
}
.cal-grid {
  display: grid;
  grid-template-columns: 28px repeat(7, 1fr);
  gap: 3px;
  align-items: stretch;
}
.cal-head,
.cal-wk-head {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 2px;
}
.cal-wk {
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.cal-out {
  opacity: 0.4;
}
.cal-future {
  opacity: 0.35;
}
.cal-today {
  border-color: var(--accent);
}
.cal-tracked {
  background: color-mix(in srgb, var(--heat-3) 28%, var(--surface-2));
}
.cal-other {
  background: color-mix(in srgb, var(--heat-other) 30%, var(--surface-2));
}
.cal-marked {
  background: color-mix(in srgb, var(--danger) 18%, var(--surface-2));
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--heat-3);
}
.cal-other .cal-dot {
  background: var(--heat-other);
}
.cal-swatch-marked {
  background: color-mix(in srgb, var(--danger) 40%, var(--surface-2));
}

/* ---- Stats v2: ranges per card, axis titles, zoom, donuts ---------------- */
.stats-range-all {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-left: auto;
}
.stats-range-all-label {
  font-size: 12px;
}
.range-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.chip-range {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}
.range-custom-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 6px 0 2px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}
.range-custom-wrap.chip-active {
  border-color: var(--accent);
}
.range-custom {
  width: 48px;
  min-height: 24px;
  padding: 0 4px;
  font-size: 12px;
  border-radius: 999px;
}
.card-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-bottom: 10px;
}
.stats-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 14px 0 6px;
}
.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 4px;
}
.chart-head .chart-legend {
  margin: 0;
}
.chart-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.chart-view-hint {
  font-size: 12px;
  margin-right: 4px;
}
.chart-zoom-btn {
  width: 28px;
  height: 28px;
  font-size: 15px;
  font-weight: 600;
}
.chart-axis-title {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.chart-plot-zoomable {
  touch-action: pan-y;
  cursor: grab;
}
.chart-zoomed .chart-plot-zoomable {
  cursor: grabbing;
}
.chip-muscle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* donut */
.donut {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
}
.donut-svg {
  flex: none;
  font-family: var(--font);
}
.donut-slice {
  stroke: var(--surface);
  stroke-width: 2;
  cursor: pointer;
  transition: opacity 0.15s;
}
.donut-dim {
  opacity: 0.35;
}
.donut-center {
  fill: var(--text);
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.donut-center-label {
  fill: var(--muted);
  font-size: 11px;
}
.donut-legend {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.donut-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 4px 8px;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.donut-row-active {
  background: var(--surface-2);
}
.donut-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.donut-value {
  font-variant-numeric: tabular-nums;
}
.donut-pct {
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}
.donut-detail {
  grid-column: 2 / -1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* library lists: rows that are buttons */
.list-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  padding: 10px 4px;
}
.list-btn:first-child {
  border-top: 0;
}
.list-btn .list-main {
  flex: 1;
  min-width: 0;
}
.list-btn .list-sub {
  white-space: normal;
}
.ex-lib-row {
  gap: 6px;
}
.ex-lib {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}
.input-sm {
  min-height: 30px;
  padding: 2px 8px;
}

/* ---- "workout not completed" banner above the log ---- */
.stats-taglist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.stats-tagrow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 2px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.stats-tagrow:hover {
  background: var(--surface-2);
}

.wk-stale {
  margin: 0 0 8px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wk-stale-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.wk-stale-text {
  font-size: 13px;
}
.sess-duration {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
