/* ==========================================================================
   Weekly workouts: styles
   Calm, minimal and accessible. No animations, no external fonts.
   Colour tokens live at the top; dark mode swaps the same tokens.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-soft: #f9f8f7;
  --bg-muted: #f0efed;
  --border: #e6e5e3;
  --border-strong: #84827e;   /* control outlines, at least 3:1 */
  --track: #e3e2e0;

  --text: #2c2c2b;
  --text-2: #64615c;          /* secondary text, at least 4.5:1 on every surface */

  --accent: #1b6ac0;
  --accent-hover: #175aa3;
  --on-accent: #ffffff;
  --accent-soft: #e7f1fb;
  --accent-text: #1a5fad;
  --focus: #1b6ac0;

  --green: #2f7d4f;
  --green-soft: #eaf4ee;
  --green-text: #266a42;
  --orange: #c2620a;
  --orange-soft: #fcf0e3;
  --orange-text: #974a00;
  --red: #c0392b;
  --red-soft: #fdecea;
  --red-text: #a8322a;

  --shadow: 0 12px 40px rgba(15, 15, 15, 0.16);
  --shadow-up: 0 -6px 20px rgba(15, 15, 15, 0.08);
  --radius: 12px;
  --radius-sm: 8px;

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --bg-soft: #202020;
    --bg-muted: #2a2a29;
    --border: #373736;
    --border-strong: #7d7c79;
    --track: #3a3a39;

    --text: #ededec;
    --text-2: #abaaa7;

    --accent: #5e9fe8;
    --accent-hover: #7ab1ee;
    --on-accent: #0e1622;
    --accent-soft: #1c2b3d;
    --accent-text: #8ebdf2;
    --focus: #8ebdf2;

    --green: #5dbb84;
    --green-soft: #1c3026;
    --green-text: #7ccb9c;
    --orange: #e8954a;
    --orange-soft: #382717;
    --orange-text: #f0ae70;
    --red: #e8776d;
    --red-soft: #3b201e;
    --red-text: #f29a92;

    --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    --shadow-up: 0 -6px 20px rgba(0, 0, 0, 0.4);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-bottom: var(--timer-space, 0px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.has-timer { padding-bottom: var(--timer-space, 340px); }

h1, h2, h3, h4, h5, p, ul, ol, figure, fieldset { margin: 0; }
h1, h2, h3, h4, h5 { line-height: 1.3; font-weight: 650; }
ul, ol { padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
strong { font-weight: 650; }

[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -200px;
  z-index: 100;
  padding: 10px 16px;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.wrap {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.muted { color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 550;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}
.btn:hover { background: var(--bg-muted); }
.btn[aria-expanded="true"] { background: var(--bg-muted); }

.btn-small { padding: 8px 12px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-quiet {
  border-color: transparent;
  background: transparent;
}
.btn-quiet:hover { background: var(--bg-muted); }

.btn-success {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green-text);
}
.btn-success:hover { background: var(--green-soft); border-width: 2px; padding: 8px 15px; }

.btn-danger {
  border-color: var(--red);
  color: var(--red-text);
}
.btn-danger:hover { background: var(--red-soft); }

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}
.btn:disabled:hover { background: var(--bg); }
.btn-primary:disabled:hover { background: var(--accent); }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--border); }

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 18px;
  font-weight: 700;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--accent);
  flex: none;
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-right: -8px;
}
.header-nav .btn { padding-left: 12px; padding-right: 12px; }
@media (max-width: 479px) {
  .header-nav { margin-left: -12px; }
}

/* ---------- Notices and notes ---------- */
.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.notice p { flex: 1 1 320px; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.note {
  margin-top: 12px;
  padding: 10px 14px;
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 15px;
}

/* ---------- Week tabs ---------- */
.week {
  display: flex;
  gap: 8px;
  margin: 12px -6px 0;
  padding: 8px 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.day-tab {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 104px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  line-height: 1.35;
}
.day-tab:hover { background: var(--bg-soft); border-color: var(--border-strong); }

.day-tab.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.tab-day {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text-2);
}
.day-tab.is-selected .tab-day { color: var(--text); }
.tab-today { color: var(--accent-text); font-weight: 650; }
.tab-type { font-size: 16px; font-weight: 650; }
.tab-meta { font-size: 14px; color: var(--text-2); }
.tab-status { margin-top: 4px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.tab-status.is-complete { color: var(--green-text); }

@media (min-width: 820px) {
  .week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow: visible;
  }
  .day-tab { min-width: 0; }
}

/* ---------- Day panel ---------- */
.day-panel { padding-top: 8px; }
.day-panel:focus { outline: none; }

.day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 16px 0;
}

.day-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.today-tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
}

.day-summary { margin-top: 4px; color: var(--text-2); }

.day-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 559px) {
  .day-actions { width: 100%; }
  .day-actions .btn { flex: 1 1 0; }
}

/* Selection controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.segmented {
  min-width: 0;
  padding: 0;
  border: 0;
}
.segmented legend {
  margin-bottom: 6px;
  padding: 0;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 650;
}

.seg-options { display: flex; flex-wrap: wrap; gap: 6px; }

.seg { position: relative; display: flex; }
.seg input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.seg label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.seg input:hover + label { background: var(--bg-muted); }
.seg input:checked + label {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
}
.seg input:focus-visible + label {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Overview */
.overview { margin: 24px 0 0; }
.estimate {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
}
.estimate-total { font-size: 20px; font-weight: 700; }
.estimate-parts { color: var(--text-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.format { margin-top: 6px; max-width: 70ch; }

/* ---------- Blocks ---------- */
.block {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.block.is-done { background: var(--bg-soft); }
.block.is-current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  margin-bottom: 12px;
}
.block-head h3 { font-size: 20px; }
.block-meta { color: var(--text-2); font-size: 15px; font-variant-numeric: tabular-nums; }

/* Warm-up and cool-down moves */
.moves { list-style: none; }
.move { padding: 10px 0; border-top: 1px solid var(--border); }
.move:first-child { border-top: 0; padding-top: 0; }
.move-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
}
.move-name { font-weight: 650; }
.move-time { color: var(--text-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.move-text { margin-top: 2px; color: var(--text-2); font-size: 15px; max-width: 70ch; }

.block.is-done .move-name { color: var(--text-2); }

/* Checkbox with label */
.check-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-top: 8px;
  cursor: pointer;
}
.check-line input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.block > .check-line {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-weight: 600;
}

/* Exercise groups */
.group + .group { margin-top: 24px; }
.group-head h4 { font-size: 17px; }
.group-meta { margin-top: 2px; color: var(--text-2); font-size: 15px; }

.exercise-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  list-style: none;
}
.block-head + .exercise-list { margin-top: 0; }

.exercise {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  column-gap: 8px;
  padding: 14px 16px 14px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.exercise.is-done { background: var(--bg-soft); }
.exercise.is-done .ex-name { color: var(--text-2); }
.exercise.is-current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.ex-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-top: -10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.ex-check:hover { background: var(--bg-muted); }
.ex-check input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.ex-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
  min-width: 0;
}
.ex-body > * { flex: 1 1 100%; }

.ex-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
}
.ex-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 17px;
  font-weight: 650;
}
.ex-num {
  flex: none;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.ex-dose {
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ex-instruction { margin-top: 4px; font-size: 15px; max-width: 70ch; }
.ex-meta { margin-top: 4px; color: var(--text-2); font-size: 14px; }

.ex-simpler {
  flex: 1 1 260px;
  margin-top: 8px;
  color: var(--text-2);
  font-size: 15px;
}
.ex-simpler .label,
.ex-simpler strong { color: var(--text); font-weight: 600; }

.ex-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
@media (min-width: 560px) {
  .ex-actions { margin-left: auto; }
}

/* Swap panel */
.swap-panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}
.swap-intro { margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.swap-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
  list-style: none;
}
.swap-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  height: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  text-align: left;
}
.swap-option:hover { background: var(--bg-muted); }
.swap-name { font-weight: 650; line-height: 1.35; }
.swap-meta { color: var(--text-2); font-size: 14px; line-height: 1.4; }
.swap-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* Rest day */
.rest-block h3 { margin-bottom: 8px; font-size: 20px; }
.rest-block p + p { margin-top: 8px; }

/* Day footer */
.day-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-top: 20px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.progress-wrap { flex: 1 1 220px; }
.progress-text { margin-bottom: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }

progress {
  display: block;
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--track);
  color: var(--accent);
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}
progress::-webkit-progress-bar { background: var(--track); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 40px;
  padding-top: 20px;
  padding-bottom: 32px;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 14px;
}

/* ---------- Timer ---------- */
.timer-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  border-top: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-up);
}

.timer {
  --phase: var(--accent);
  --phase-soft: var(--accent-soft);
  --phase-text: var(--accent-text);
  border-top: 4px solid var(--phase);
  background: var(--phase-soft);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.timer.is-work { --phase: var(--orange); --phase-soft: var(--orange-soft); --phase-text: var(--orange-text); }
.timer.is-rest,
.timer.is-finished { --phase: var(--green); --phase-soft: var(--green-soft); --phase-text: var(--green-text); }
.timer.is-paused { --phase: var(--border-strong); --phase-soft: var(--bg-muted); --phase-text: var(--text-2); }

.timer-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 16px 14px;
}

.timer-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 12px;
}
.timer-phase {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--phase-text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--phase);
}
.timer-day {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  color: var(--text-2);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timer-tools { display: flex; gap: 4px; margin-left: auto; margin-right: -8px; }
.timer-tools .btn:hover { background: var(--bg); }

.timer-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 2px;
}
.timer-text { flex: 1 1 auto; min-width: 0; }
.timer-title { font-size: 20px; font-weight: 700; line-height: 1.3; }
.timer-detail { margin-top: 2px; font-size: 15px; }
.timer-next { margin-top: 4px; color: var(--text-2); font-size: 14px; }
.timer-clock { flex: none; }
.clock-digits {
  display: block;
  font-size: clamp(44px, 13vw, 68px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}
.timer.is-paused .clock-digits { color: var(--text-2); }

.timer-progress {
  height: 6px;
  margin: 12px 0;
  background: var(--bg);
}
.timer-progress::-webkit-progress-bar { background: var(--bg); }
.timer-progress::-webkit-progress-value { background: var(--phase); }
.timer-progress::-moz-progress-bar { background: var(--phase); }

.timer-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.timer-controls .timer-done { grid-column: 1 / -1; }

.timer-finish { display: flex; flex-wrap: wrap; gap: 8px; }
.timer-finish .btn { flex: 1 1 180px; }

@media (min-width: 640px) {
  .timer-controls:has(.timer-done:not([hidden])) { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .timer-controls:has(.timer-done:not([hidden])) .timer-done { grid-column: auto; }
  .timer-title { font-size: 22px; }
}

/* ---------- Dialogs ---------- */
dialog {
  width: min(560px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 24px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog.dialog-wide { width: min(760px, calc(100vw - 24px)); }
dialog.dialog-small { width: min(420px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 15, 15, 0.45); }

dialog h2 { font-size: 20px; }
.dialog-small h2 { margin-bottom: 8px; }
.dialog-small p { color: var(--text-2); }

/* Title row and action row stay visible while a long dialog scrolls. */
.dialog-head {
  position: sticky;
  top: -24px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -24px -8px 8px 0;
  padding: 18px 0 6px;
  background: var(--bg);
}
.dialog-intro { margin-bottom: 16px; color: var(--text-2); font-size: 15px; }
.dialog-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.dialog-actions {
  position: sticky;
  bottom: -24px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 20px 0 -24px;
  padding: 16px 0 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.spacer { flex: 1 1 auto; }

@media (max-width: 479px) {
  dialog { padding: 20px 16px; }
  .dialog-head { top: -20px; margin-top: -20px; padding-top: 14px; }
  .dialog-actions { bottom: -20px; margin-bottom: -20px; padding-bottom: 20px; }
  .dialog-actions .btn { flex: 1 1 auto; }
  .dialog-actions .spacer { display: none; }
  .setting { flex-direction: column; align-items: flex-start; }
  .setting > div { flex: none; }
}

/* Equipment */
.equipment-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0 16px;
  list-style: none;
}
.equipment-list .check-line { margin-top: 0; }

/* Settings */
#settings-dialog > .check-line { margin-top: 0; }
.settings-list { margin-top: 12px; border-top: 1px solid var(--border); }
.setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting > div { flex: 1 1 240px; }
.setting h3 { font-size: 16px; }
.setting p { margin-top: 2px; color: var(--text-2); font-size: 15px; }

.about { margin-top: 12px; }
.about summary {
  display: list-item;
  min-height: 44px;
  padding: 10px 0;
  cursor: pointer;
  font-weight: 600;
}
.about ul { padding-left: 20px; color: var(--text-2); font-size: 15px; }
.about li + li { margin-top: 6px; }

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}
.field > label,
.field > legend {
  padding: 0;
  font-size: 15px;
  font-weight: 600;
}
fieldset.field > legend { margin-bottom: 6px; }

input[type="text"],
input[type="search"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-2); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; }

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
}
.field-row.compact { grid-template-columns: repeat(2, minmax(0, 150px)); }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0 12px;
}
.check-group .check-line { margin-top: 0; }
.check-group { gap: 0; }
.hint { margin: 0 0 4px; color: var(--text-2); font-size: 14px; font-weight: 400; }

#edit-body > .check-line { margin: -4px 0 12px; }
fieldset.field .check-line { margin-top: 0; }

.form-errors {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--red);
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red-text);
}
.form-errors p { font-weight: 650; }
.form-errors ul { margin-top: 4px; padding-left: 20px; }

/* ---------- Library ---------- */
.library-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0 12px;
  margin-top: 8px;
}
.library-tools .field { flex: 0 1 150px; margin-bottom: 12px; }
.library-tools .field.grow { flex: 1 1 240px; }

.library-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.library-status { margin-top: 10px; font-weight: 600; }
.library-status:empty { display: none; }
.library-count { margin: 12px 0 4px; color: var(--text-2); font-size: 14px; }

.library-list { list-style: none; border-top: 1px solid var(--border); }
.lib-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.lib-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-name { font-weight: 650; }
.lib-meta { color: var(--text-2); font-size: 14px; }
.lib-row .btn { flex: none; }
.lib-empty { padding: 16px 0; color: var(--text-2); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 550;
  line-height: 22px;
  vertical-align: 1px;
}

/* ---------- Larger screens ---------- */
@media (min-width: 760px) {
  .wrap { padding-left: 24px; padding-right: 24px; }
  .timer-inner { padding-left: 24px; padding-right: 24px; }
  .day-title { font-size: 30px; }
  .block { padding: 24px; }
}

/* ---------- Small phones ---------- */
@media (max-width: 400px) {
  .block { padding: 16px 14px; }
  .controls { padding: 14px; }
  .exercise { padding-right: 12px; padding-left: 4px; column-gap: 6px; }
  .seg label { padding: 0 12px; }
}

/* ---------- High contrast / forced colours ---------- */
@media (forced-colors: active) {
  .seg input:checked + label,
  .day-tab.is-selected,
  .exercise.is-current,
  .block.is-current { outline: 3px solid Highlight; outline-offset: -3px; }
  .brand-mark, .phase-dot { forced-color-adjust: none; }
}

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

/* ---------- Print: one clean day sheet ---------- */
@media print {
  :root {
    --bg: #fff; --bg-soft: #fff; --bg-muted: #fff; --text: #000; --text-2: #333;
    --border: #bbb; --border-strong: #777; --accent: #000; --accent-text: #000; --accent-soft: #fff;
  }
  .skip-link, .header-nav, #notice, .week, .controls, .note, .day-actions,
  .ex-actions, .swap-panel, .day-foot .btn, .timer-host, .site-footer { display: none !important; }
  body.has-timer { padding-bottom: 0; }
  .site-header { border: 0; }
  .block, .exercise, .group-head { break-inside: avoid; }
  .block { padding: 12px 0; border: 0; border-top: 1px solid #bbb; border-radius: 0; }
}
