  :root {
    --bg: #faf9f6;
    --surface: #ffffff;
    --ink: #1a1a18;
    --muted: #6b6459;
    --line: #e0ddd4;
    --accent: #7d631c;
    --accent-soft: #f3ecd7;
    --liss: #6b5d4f;
    --liss-soft: #ede7de;
    --done: #7d631c;
    --partial: #c9a227;
    --content-max: 720px;
    --fill-strong: #6b5216;
  }
  :root[data-theme="dark"] {
    --bg: #0e0e0d;
    --surface: #1c1c1a;
    --ink: #f2efe8;
    --muted: #a39d8e;
    --line: #38352c;
    --accent: #d4af37;
    --accent-soft: #2e2712;
    --liss: #b8a68e;
    --liss-soft: #2a2620;
    --done: #d4af37;
    --partial: #cdae76;
    --fill-strong: #7a5a12;
  }
  :root { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }
  * { box-sizing: border-box; }
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  body {
    margin: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.4;
    padding-bottom: 60px;
  }

  /* ---- shared button base (was duplicated across 4 selectors) ---- */
  .btn {
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--muted);
    white-space: nowrap;
    font-family: inherit;
  }
  .btn:focus-visible, .set-dot:focus-visible, .week-dot:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  .btn-sm { padding: 4px 8px; font-size: 0.78rem; }
  .btn-active { background: var(--fill-strong); border-color: var(--fill-strong); color: white; }
  .btn-icon {
    width: 24px; height: 24px; padding: 0; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  }

  header {
    padding: 24px 20px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  h1 { margin: 0 0 4px; font-size: 1.35rem; font-weight: 700; }
  .title-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .greeting { font-size: 0.9rem; color: var(--muted); }
  .greeting:empty { display: none; }
  .text-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--ink);
  }
  .subtitle { margin: 0 0 14px; color: var(--muted); font-size: 0.88rem; }
  .day-notes { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
  .day-notes .settings-label { display: block; margin-bottom: 6px; }
  .notes-input { min-height: 64px; resize: vertical; line-height: 1.5; }

  .hold-timer { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
  .hold-timer-btn.active { background: var(--fill-strong); border-color: var(--fill-strong); color: white; }
  .hold-timer-display { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; color: var(--accent); }
  .hold-timer-last { font-size: 0.75rem; color: var(--muted); }

  .weight-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
  .weight-input { width: 70px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 0.85rem; background: var(--surface); color: var(--ink); }

  .controls-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
  }
  .date-picker {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--ink);
  }
  .field-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--muted);
  }
  .rest-setting { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--muted); margin-left: auto; }
  .rest-setting .rt-val { min-width: 32px; text-align: center; font-variant-numeric: tabular-nums; }

  main { max-width: var(--content-max); margin: 0 auto; padding: 20px; }

  /* ---- week strip ---- */
  .week-strip {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 20px;
  }
  .week-dot {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px 0;
    font-family: inherit;
  }
  .week-dot .wd-label { font-size: 0.72rem; color: var(--muted); }
  .week-dot .wd-fill {
    width: 26px; height: 26px; border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--surface);
  }
  .week-dot.current .wd-label { color: var(--ink); font-weight: 700; }
  .week-dot.current .wd-fill { border-color: var(--accent); border-width: 2px; }
  .week-dot.partial .wd-fill { background: var(--partial); border-color: var(--partial); }
  .week-dot.full .wd-fill { background: var(--done); border-color: var(--done); }
  .week-dot.rest .wd-fill { background: var(--muted); border-color: var(--muted); opacity: 0.55; }

  .day-heading { margin-bottom: 2px; }
  .day-heading .weekday { font-size: 1.15rem; font-weight: 700; }
  .day-heading .datestr { font-size: 0.82rem; color: var(--muted); }
  .month-week-label { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
  .up-next { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
  .up-next strong { color: var(--ink); font-weight: 600; }
  .backup-status.stale { color: var(--liss); }

  .exercise-top-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .flag-btn { width: 22px; height: 22px; color: var(--line); }
  .flag-btn.active { color: var(--liss); }
  .exercise-row.flagged { border-left: 2px solid var(--liss); padding-left: 10px; margin-left: -12px; }

  .preview-row { margin-top: 8px; }
  .preview-row .field-group { margin-bottom: 6px; }
  .preview-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .preview-buttons .btn {
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }

  .plan-label {
    display: inline-block;
    margin: 10px 0 10px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
  }
  .plan-label.workout { background: var(--accent-soft); color: var(--accent); }
  .plan-label.liss { background: var(--liss-soft); color: var(--liss); }
  .plan-label.rest { background: var(--line); color: var(--muted); }
  .rest-toggle-row { margin: 8px 0 14px; }
  .rest-toggle-btn { font-size: 0.78rem; }
  .rest-toggle-btn.active { background: var(--muted); border-color: var(--muted); color: var(--surface); }

  /* ---- progress bar ---- */
  .progress-bar-track {
    height: 6px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
    margin-bottom: 18px;
  }
  .progress-bar-fill {
    width: 0;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.2s ease;
  }

  .tip-box {
    background: var(--accent-soft);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 0.85rem;
    margin-bottom: 20px;
  }
  .tip-box p { margin: 4px 0; }
  .tip-box strong { color: var(--accent); }

  .block-title { font-size: 1rem; font-weight: 700; margin: 22px 0 10px; }
  .block-title:first-of-type { margin-top: 0; }

  .exercise-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .exercise-row:last-child { border-bottom: none; }
  .exercise-main { display: flex; gap: 12px; align-items: flex-start; }
  .exercise-icon { width: 42px; height: 42px; flex-shrink: 0; color: var(--muted); margin-top: 1px; }
  .exercise-icon svg { width: 100%; height: 100%; display: block; }
  body.icons-hidden .exercise-icon { display: none; }

  /* Toggle-button glyphs follow existing state (body.icons-hidden /
     :root[data-theme]) purely in CSS — no inline styles, no JS needed. */
  #iconsSlash { display: none; }
  body.icons-hidden #iconsSlash { display: inline; }
  #themeIconMoon { display: none; }
  :root[data-theme="dark"] #themeIconSun { display: none; }
  :root[data-theme="dark"] #themeIconMoon { display: inline; }
  .exercise-body { flex: 1; min-width: 0; }
  .exercise-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .exercise-name { font-weight: 600; font-size: 0.95rem; }
  .exercise-target { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
  .exercise-note { font-size: 0.8rem; color: var(--muted); font-style: italic; margin-top: 2px; }

  .set-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
  .log-set-btn {
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
  }
  .log-set-btn:disabled { opacity: 0.45; cursor: default; }
  .set-tracker { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
  .set-dot {
    width: 28px; height: 28px; border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-family: inherit;
  }
  .set-dot.done { background: var(--fill-strong); border-color: var(--fill-strong); color: white; }
  .set-count { font-size: 0.78rem; color: var(--muted); }

  .rest-timer {
    display: none;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding: 12px 14px;
    background: var(--accent-soft);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--accent);
  }
  .rest-timer.active { display: flex; }
  .rest-timer .rt-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.5rem; min-width: 46px; }
  .rest-timer .rt-skip {
    margin-left: auto;
    border: none;
    background: none;
    color: var(--accent);
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
  }

  .simple-check { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
  .simple-check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
  .simple-check label { font-size: 0.82rem; color: var(--muted); cursor: pointer; }

  .liss-card { background: var(--liss-soft); border-radius: 12px; padding: 18px; }
  .liss-card h2 { margin: 0 0 6px; font-size: 1.05rem; color: var(--liss); }
  .liss-card p { margin: 4px 0; font-size: 0.88rem; color: var(--ink); }
  .liss-card p.spaced { margin-top: 10px; }
  .liss-options { margin: 10px 0 0; padding-left: 18px; font-size: 0.85rem; }
  .liss-log { margin-top: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .liss-log input[type="number"] {
    width: 70px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 0.85rem;
  }
  .liss-log label { font-size: 0.82rem; color: var(--muted); }
  .liss-log .simple-check { margin-top: 0; }

  footer {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 10px 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--muted);
    font-size: 0.8rem;
  }
  .footer-actions { display: flex; gap: 10px; }

  /* ---- view tabs (Tracker / Guide) ---- */
  .view-tabs {
    display: flex;
    overflow-x: auto;  /* safety net: scroll rather than clip if a tab ever overflows */
    gap: 4px;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 10px 20px 0;
    border-bottom: 1px solid var(--line);
  }
  .view-tab {
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    padding: 8px 4px 10px;
    margin-right: 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
  }
  .view-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
  #trackerView[hidden], #guideView[hidden], #settingsView[hidden], #journalView[hidden] { display: none; }

  /* ---- guide view ---- */
  #guideView { max-width: var(--content-max); margin: 0 auto; padding: 20px; }
  #settingsView { max-width: var(--content-max); margin: 0 auto; padding: 20px; }
  #journalView { max-width: var(--content-max); margin: 0 auto; padding: 20px; }
  .journal-section { margin-bottom: 26px; }
  .journal-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
  .journal-row:last-child { border-bottom: none; }
  .journal-name { font-weight: 600; }
  .journal-value { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; white-space: nowrap; text-align: right; }
  .journal-date { font-size: 0.75rem; color: var(--muted); }
  .journal-empty { font-size: 0.82rem; color: var(--muted); margin: 0; }
  .journal-note { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .journal-note:last-of-type { border-bottom: none; }
  .journal-note-text { font-size: 0.88rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; margin: 2px 0 0; }
  .journal-more { margin-top: 10px; }

  .day-chips-head { display: flex; justify-content: space-between; width: 100%; font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
  .day-chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .day-chip, .variant-chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 8px; padding: 7px 10px; font-size: 0.82rem; font-family: inherit; cursor: pointer; min-width: 44px; }
  .day-chip.active, .variant-chip.active { background: var(--fill-strong); border-color: var(--fill-strong); color: white; }
  .day-chip:focus-visible, .variant-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .variant-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
  .variant-log { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
  .variant-log:empty { display: none; }
  .pause-list { width: 100%; }
  .pause-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.82rem; flex-wrap: wrap; }
  .pause-row:last-child { border-bottom: none; }
  .paused-card { background: var(--line); border-radius: 12px; padding: 18px; }
  .paused-card h2 { margin: 0 0 6px; font-size: 1.05rem; }
  .paused-card p { margin: 4px 0; font-size: 0.88rem; color: var(--ink); }
  .paused-card p.spaced { margin-top: 10px; }
  .trend-bar.paused { background: repeating-linear-gradient(135deg, var(--line) 0 4px, transparent 4px 8px); }
  .guide-intro { font-size: 0.88rem; color: var(--muted); margin-bottom: 16px; }
  .guide-note {
    background: var(--accent-soft);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 0.85rem;
    margin-bottom: 20px;
  }
  .guide-search { margin-bottom: 14px; }
  .guide-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
  }
  .guide-nav a {
    font-size: 0.78rem;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 5px 10px;
    border-radius: 999px;
    text-decoration: none;
  }
  .guide-section { margin-bottom: 28px; }
  .guide-section h3 {
    font-size: 1rem;
    margin: 0 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    scroll-margin-top: 70px;
  }
  .guide-item { margin-bottom: 14px; font-size: 0.88rem; line-height: 1.55; }
  .guide-item strong { display: block; color: var(--ink); margin-bottom: 2px; }
  .guide-item span { color: var(--muted); }
  .guide-footnote { font-size: 0.82rem; color: var(--muted); margin-top: 8px; }

  /* ---- progress panel (streak / overall % / recent history) ---- */
  .progress-panel { max-width: var(--content-max); margin: 0 auto; padding: 0 20px 16px; }
  .progress-panel[hidden] { display: none; }
  .progress-panel-inner {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
  }
  .stat-row { display: flex; gap: 28px; margin-bottom: 18px; }
  .stat { display: flex; flex-direction: column; }
  .stat-num-row { display: flex; align-items: center; gap: 5px; }
  .stat-num { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
  .streak-icon { color: var(--accent); flex-shrink: 0; }
  .stat-label { font-size: 0.75rem; color: var(--muted); }

  .panel-section { margin-top: 18px; }
  .panel-section-label { font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }

  /* ---- 12-week heatmap ---- */
  .heatmap-wrap { display: flex; gap: 6px; align-items: flex-start; }
  .heatmap-labels {
    display: grid;
    grid-template-rows: repeat(7, 11px);
    gap: 3px;
    font-size: 0.6rem;
    line-height: 11px;
    color: var(--muted);
    flex-shrink: 0;
  }
  .heatmap {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 11px);
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 2px; /* room for a scrollbar without clipping the last row */
  }
  .heat-cell { width: 11px; height: 11px; border-radius: 3px; background: var(--line); flex-shrink: 0; }
  .heat-cell.partial { background: var(--partial); }
  .heat-cell.full { background: var(--done); }
  .heat-cell.rest { background: var(--muted); opacity: 0.45; }

  /* ---- weekly trend sparkline ---- */
  .trend-row { display: flex; align-items: flex-end; gap: 4px; height: 44px; }
  .trend-bar {
    flex: 1;
    height: 100%;
    min-width: 6px;
    background: var(--line);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
  }
  .trend-fill { position: absolute; left: 0; right: 0; bottom: 0; height: var(--h, 0%); background: var(--done); }
  .trend-bar.current .trend-fill { background: var(--partial); }


  /* ---- motion ---- */
  @keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .content-transition { animation: fadeSlideIn 0.22s ease; }

  @keyframes dotPop {
    0% { transform: scale(1); }
    45% { transform: scale(1.28); }
    100% { transform: scale(1); }
  }
  .set-dot.pop { animation: dotPop 0.28s ease; }
  .set-dot { transition: background-color 0.15s ease, border-color 0.15s ease; }

  .week-dot .wd-fill { transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease; }
  .week-dot.current .wd-fill { transform: scale(1.08); }

  @media (prefers-reduced-motion: reduce) {
    .content-transition, .set-dot.pop { animation: none; }
    .set-dot, .week-dot .wd-fill { transition: none; }
  }

  /* ---- settings (in-flow tab, not a popover) ---- */
  .settings-row { padding: 16px 0; border-bottom: 1px solid var(--line); }
  .settings-row:first-child { padding-top: 0; }
  .settings-row:last-child { border-bottom: none; padding-bottom: 0; }
  .settings-row:not(.settings-stack) { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .settings-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
  .settings-label { font-size: 0.9rem; font-weight: 600; color: var(--ink); }
  .settings-controls { display: flex; gap: 8px; flex-wrap: wrap; }
  .settings-hint { font-size: 0.78rem; color: var(--muted); margin: 0; line-height: 1.5; }
  .settings-warn {
    font-size: 0.78rem;
    color: var(--ink);
    background: var(--liss-soft);
    border-radius: 8px;
    padding: 12px;
    margin: 0;
    line-height: 1.55;
    max-width: 100%;
  }
  .settings-warn[hidden] { display: none; }
  .data-box {
    width: 100%;
    min-height: 90px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: var(--bg);
    color: var(--ink);
    resize: vertical;
  }
  .data-box[hidden], #importActions[hidden] { display: none; }

  /* ---- week paging ---- */
  .week-row { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; }
  .week-row .week-strip { flex: 1; margin-bottom: 0; }
  .week-nav { flex-shrink: 0; font-size: 1rem; }

  /* ---- completed exercise dimming + current-exercise anchor ---- */
  .exercise-row.exercise-done { opacity: 0.45; }
  .exercise-row { transition: opacity 0.2s ease; scroll-margin-top: 150px; }

  /* ---- sticky rest bar ---- */
  .sticky-rest {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--fill-strong);
    color: white;
    padding: 10px 14px;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.22);
    max-width: calc(100vw - 32px);
  }
  .sticky-rest[hidden] { display: none; }
  .sticky-rest-time { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }
  .sticky-rest-label { font-size: 0.8rem; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sticky-rest .btn { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.35); color: white; }

  /* ---- celebration toast (day fully completed) ---- */
  .celebrate-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px) scale(0.95);
    z-index: 50;
    background: var(--fill-strong);
    color: white;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    max-width: calc(100vw - 32px);
    text-align: center;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
  }
  .celebrate-toast[hidden] { display: none; }
  .celebrate-toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

  /* ---- confetti burst (small, on-brand, decorative only) ---- */
  .confetti-burst {
    position: fixed;
    top: 0;
    left: 50%;
    width: 1px;
    height: 1px;
    z-index: 49;
    pointer-events: none;
  }
  .confetti-piece {
    position: absolute;
    top: 26px;
    left: 0;
    width: var(--cw, 7px);
    height: var(--ch, 7px);
    background: var(--cc, var(--accent));
    border-radius: var(--cr, 2px);
    opacity: 0.95;
    animation: confettiFall var(--cdur, 1.1s) var(--cdelay, 0s) ease-out forwards;
  }
  @keyframes confettiFall {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 0.95; }
    100% { transform: translate(var(--cx, 0), var(--cy, 90px)) rotate(var(--crot, 200deg)); opacity: 0; }
  }

  @media (prefers-reduced-motion: reduce) {
    .celebrate-toast { transition: opacity 0.15s ease; transform: translateX(-50%) !important; }
    .confetti-burst { display: none; }
  }

  /* ==================================================================
     Responsive. The layout is a single centred column (--content-max)
     that every region shares, so breakpoints mostly adjust that one
     variable plus spacing, rather than re-laying-out each region.
     ================================================================== */

  /* Header spans the full viewport (for its sticky background + border)
     but its contents align to the same column as everything below. */
  header > .title-row,
  header > .subtitle,
  header > .controls-row {
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
  }

  /* Phones. Reclaim vertical space in the sticky header, and stop the
     exercise name/target pair from colliding on a narrow column. */
  @media (max-width: 560px) {
    header { padding: 14px 16px 10px; }
    h1 { font-size: 1.1rem; margin-bottom: 2px; }
    .subtitle { display: none; }
    .preview-buttons { grid-template-columns: repeat(2, 1fr); }
    main, #guideView, #journalView { padding: 16px; }
    .view-tab { margin-right: 10px; }  /* four tabs must fit a 320px phone */
    .view-tabs { padding: 8px 16px 0; }
    .progress-panel { padding: 0 16px 16px; }
    footer { padding: 10px 16px 24px; flex-direction: column; align-items: flex-start; gap: 10px; }
    .controls-row { gap: 8px; }
    .rest-setting { margin-left: 0; }
    .exercise-main { gap: 10px; }
    .exercise-icon { width: 34px; height: 34px; }
    .exercise-top { flex-direction: column; align-items: flex-start; gap: 1px; }
    .exercise-target { white-space: normal; }
    .week-dot .wd-fill { width: 22px; height: 22px; }
    .week-dot .wd-label { font-size: 0.68rem; }
    .stat-row { gap: 20px; }
    .rest-timer .rt-time { font-size: 1.3rem; }
    .week-row { gap: 2px; }
    .week-nav { width: 26px; height: 26px; }
    .week-strip { gap: 3px; }
    .settings-row { padding: 12px 0; }
    .sticky-rest { bottom: 12px; gap: 10px; padding: 9px 12px; }
    .sticky-rest-label { max-width: 38vw; }
  }

  /* iOS zooms the page in when focusing an input under 16px. Applies to
     touch devices at any width, so it is kept out of the width query. */
  @media (pointer: coarse) {
    .date-picker, .text-input, .liss-log input[type="number"] { font-size: 16px; }
    .set-dot { width: 34px; height: 34px; font-size: 0.8rem; }
    .btn-icon { width: 34px; height: 34px; }
    .btn { padding: 9px 14px; }
    .week-dot { padding: 8px 0; }
    .view-tab { padding: 10px 4px 12px; }
  }

  /* Large desktops: widen the column a little rather than stranding the
     content in a narrow strip. */
  @media (min-width: 1100px) {
    :root { --content-max: 860px; }
  }

  /* ---- two-column layout: Tracker content + a permanently-visible
     progress sidebar, once there's genuinely room for both. Below this
     width, everything is untouched — single column, progress panel still
     toggled via the "Progress" button exactly as before. ---- */
  @media (min-width: 900px) {
    .tracker-columns {
      display: flex;
      align-items: flex-start;
      gap: 32px;
      max-width: 1040px;
      margin: 0 auto;
      padding: 0 20px;
    }
    .tracker-columns > main {
      flex: 1 1 auto;
      min-width: 0;
      max-width: none;
      margin: 0;
      padding: 20px 0;
    }
    .tracker-columns > .progress-panel {
      flex: 0 0 300px;
      max-width: none;
      margin: 0;
      padding: 20px 0;
      position: sticky;
      top: 16px;
      display: block !important; /* always visible at this width */
    }
    #progressToggleBtn { display: none; } /* redundant once always-visible */
  }
