:root {
  color-scheme: light;
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  color: #202923;
  background: #f5f5ef;
  --ink: #202923;
  --muted: #536357;
  --forest: #173b2b;
  --green: #214c38;
  --lime: #daf28e;
  --line: #dce2d8;
  --panel: #fffefb;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 3px solid #315e9b; outline-offset: 3px; }
h1, h2, h3, p, dl { margin: 0; }
h1, h2, h3 { line-height: 1.12; }
svg { flex: 0 0 auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.site-header { background: #fffefb; border-bottom: 1px solid var(--line); }
.header-inner, .page { max-width: 1160px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 40px); }
.header-inner { min-height: 67px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; justify-content: space-between; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; padding: 0; min-height: 48px; background: transparent; border: 0; color: var(--forest); font-weight: 750; letter-spacing: -.035em; }
.brand-icon { width: 34px; aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; background: var(--forest); }
.brand-icon i { position: relative; display: block; width: 18px; height: 2px; background: var(--lime); }
.brand-icon i::before, .brand-icon i::after { content: ''; position: absolute; top: -4px; width: 3px; height: 10px; background: var(--lime); border-radius: 2px; }
.brand-icon i::before { left: 2px; }
.brand-icon i::after { right: 2px; }
nav { display: flex; gap: 6px; }
nav button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; padding: 0 14px; color: var(--muted); font-weight: 650; background: transparent; border: 0; border-radius: 9px; }
nav button[aria-current] { color: var(--forest); background: #e7eee4; }
nav svg { width: 17px; height: 17px; }
.page { padding-block: clamp(20px, 3.5vw, 39px) 46px; }

.hero { min-height: 270px; display: grid; grid-template-columns: 1fr 1.1fr; background: var(--forest); color: white; border-radius: 22px; overflow: clip; }
.hero-image { grid-column: 2; grid-row: 1; background: #465944 url('./assets/garden.jpg') center 47% / cover; }
.hero-content { grid-column: 1; grid-row: 1; padding: clamp(25px, 5.2vw, 59px); align-self: center; }
.hero h1 { font-size: clamp(2.45rem, 5vw, 4.45rem); letter-spacing: -.07em; line-height: .99; max-width: 7em; }
.hero-meta { display: flex; gap: 7px 14px; flex-wrap: wrap; margin-block: 18px 25px; color: #e2ecdc; font-size: .9rem; }
.hero-meta span { display: inline-flex; gap: 6px; align-items: center; }
.hero-meta span + span::before { content: '·'; margin-right: 5px; }
.hero-meta svg { width: 16px; height: 16px; }
.hero .primary { background: var(--lime); color: #19301d; }
.hero .primary:hover { background: #e5ffa1; }
.hero-resume { color: #e2ecdc; margin-top: 12px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; line-height: 1.15; text-align: center; }
.primary { color: #fff; background: var(--green); }
.primary:hover { background: #173e2c; }
.secondary { background: #f4f7f0; color: var(--forest); border-color: var(--line); }
.secondary:hover { background: #e7eee4; }
.quiet { background: transparent; color: var(--green); padding-inline: 7px; }
.danger { color: #8a332c; }
.destructive { background: #8a332c; color: white; }
.wide { display: flex; width: 100%; }
.home-grid { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); align-items: start; margin-top: 27px; }
.home-grid h2 { font-size: 1.34rem; letter-spacing: -.035em; }
.workout-plan > h2 { margin-block: 0 13px; }
.panel { border: 1px solid var(--line); background: var(--panel); border-radius: 15px; }
.circuit { padding: 14px 17px; margin-bottom: 10px; }
.circuit-heading { display: flex; align-items: center; gap: 10px; }
.circuit-heading h3 { flex: 1; font-size: 1rem; }
.circuit-letter { display: grid; place-items: center; width: 29px; aspect-ratio: 1; border-radius: 8px; color: var(--forest); background: #e6efe1; font-weight: 760; }
.rounds { font-size: .83rem; font-weight: 650; color: var(--muted); }
.circuit ul { margin: 7px 0 0; padding: 0; list-style: none; }
.circuit li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-block: 8px; font-size: .94rem; line-height: 1.25; }
.circuit li + li { border-top: 1px solid #ebeee8; }
.circuit li span:last-child { color: var(--muted); white-space: nowrap; }
.circuit-rest { margin-top: 3px; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8rem; }
.circuit-rest svg { width: 15px; height: 15px; }
.workout-plan { grid-area: 1 / 1; }
.home-aside { grid-area: 1 / 2; display: grid; gap: 12px; }
.setup, .baseline { padding: 18px; }
.setup h2 { margin-bottom: 14px; }
.setup label { display: block; color: var(--muted); font-weight: 650; font-size: .82rem; margin-bottom: 5px; }
.setup select { width: 100%; min-height: 46px; border: 1px solid #cdd7cd; border-radius: 8px; background: #f8faf5; color: var(--ink); padding: 0 8px; }
.rest-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 11px; }
.baseline p { color: var(--muted); font-size: .84rem; margin-block: 6px 9px; }
.baseline dl > div { display: flex; gap: 10px; justify-content: space-between; padding: 7px 0; font-size: .88rem; }
.baseline dl > div + div { border-top: 1px solid #ebeee8; }
.baseline dd { margin: 0; white-space: nowrap; color: var(--forest); font-weight: 700; }

.workout-shell, .history-detail { max-width: 640px; margin-inline: auto; }
.page-heading h1 { font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: -.06em; }
.page-heading p { margin-top: 7px; color: var(--muted); }
.workout-progress { display: grid; gap: 6px; margin-block: 11px 19px; font-size: .9rem; color: var(--muted); font-weight: 650; }
progress { display: block; width: 100%; height: 9px; appearance: none; border: 0; border-radius: 100px; background: #e2e9df; accent-color: var(--green); }
progress::-webkit-progress-bar { border-radius: inherit; background: #e2e9df; }
progress::-webkit-progress-value { border-radius: inherit; background: var(--green); }
progress::-moz-progress-bar { border-radius: inherit; background: var(--green); }
.workout-card { padding: clamp(18px, 5vw, 34px); text-align: center; }
.workout-card h2 { font-size: clamp(1.85rem, 6.5vw, 2.8rem); letter-spacing: -.055em; }
.workout-card :is(h2, p) + .wide, .workout-card p + .paired { margin-top: 16px; }
.workout-card .context { color: var(--green); font-weight: 750; margin-bottom: 7px; }
.workout-card .muted { margin-top: 6px; }
.variant { font-weight: 650; margin-top: 5px; }
.muted, .up-next { color: var(--muted); }
.reference { display: inline-block; color: var(--forest); background: #e8efe3; border-radius: 7px; font-size: .87rem; padding: 7px 9px; margin-top: 13px; }
.rep-control { display: grid; grid-template-columns: 64px minmax(80px, 130px) 64px; justify-content: center; align-items: center; gap: clamp(10px, 4vw, 22px); margin-block: 17px 21px; }
.rep-control button { min-height: 64px; border: 1px solid #ccd9cd; border-radius: 12px; background: #eff4eb; color: var(--forest); font-size: 2.25rem; line-height: 1; }
.rep-control output { display: block; font-size: clamp(3.15rem, 10vw, 4.75rem); line-height: .95; letter-spacing: -.07em; font-weight: 750; font-variant-numeric: tabular-nums; }
.rep-control span { display: block; margin-top: 3px; font-size: .88rem; color: var(--muted); }
.up-next { margin-top: 12px; font-size: .85rem; }
.workout-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; margin-top: 4px; }
.countdown { font-size: clamp(4.8rem, 17vw, 7rem); line-height: 1.13; letter-spacing: -.07em; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--forest); }
.paired { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.timer-complete { color: var(--forest); background: var(--lime); font-weight: 700; padding: 6px; border-radius: 8px; margin-bottom: 9px; }
.workout-shell .page-heading + .workout-card { margin-top: 15px; }

.history-row { text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 72px; color: var(--ink); padding: 12px 15px; margin-top: 12px; }
.history-row:hover { border-color: #a7b8a7; }
.history-row small { display: block; color: var(--muted); margin-top: 3px; }
.history-row span + span { display: inline-flex; align-items: center; white-space: nowrap; gap: 6px; font-size: .87rem; color: var(--forest); }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; background: transparent; border: 0; color: var(--green); font-weight: 700; padding: 0 5px; margin: -9px 0 8px; }
.session-times, .history-circuit { padding: 15px; margin-top: 12px; }
.session-times dl > div { display: flex; gap: 5px 12px; flex-wrap: wrap; justify-content: space-between; padding: 4px 0; }
.session-times dt { color: var(--muted); }
.session-times dd { margin: 0; }
.history-circuit h2 { font-size: 1.17rem; }
.history-circuit ul { padding: 0; margin: 8px 0 0; list-style: none; }
.history-circuit li { padding-block: 9px; display: flex; justify-content: space-between; gap: 10px; }
.history-circuit li + li { border-top: 1px solid #ebeee8; }
.history-circuit li div + div { text-align: right; white-space: nowrap; }
.history-circuit li :is(span, time) { display: block; margin-top: 3px; color: var(--muted); font-size: .83rem; }
.delete-actions { margin-top: 12px; }
.routine-panel { margin-top: 16px; }
.routine-panel :is(input, select) { width: 100%; min-height: 46px; border: 1px solid #cdd7cd; border-radius: 8px; padding: 8px; color: var(--ink); font: inherit; background: #f8faf5; }
.routine-panel label { margin-top: 10px; }
.routine-panel > .button { margin-top: 12px; }
.routine-card { display: grid; gap: 8px; padding-block: 10px; border-bottom: 1px solid var(--line); }
.routine-card span { color: var(--muted); }
.routine-entry { min-width: 0; border: 1px solid var(--line); border-radius: 8px; margin: 14px 0; padding: 0 10px 10px; }
.routine-entry legend { font-weight: 700; }
.routine-block { min-width: 0; border: 1px solid #b8cabc; border-radius: 12px; margin: 18px 0; padding: 2px 12px 12px; }
.routine-block > legend { color: var(--forest); font-weight: 700; }
.routine-block .editor-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.routine-block .editor-actions .button { padding-inline: 11px; }
.routine-panel .rest-after-block { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.routine-panel .rest-after-block input { width: 20px; height: 20px; min-height: 0; accent-color: var(--green); }
.restore-preview { margin-top: 12px; display: grid; gap: 8px; }
.data-link { margin-top: 12px; }
.library-link { margin-top: 14px; }
.library-list { margin: 0; padding: 0; list-style: none; }
.library-list .history-row { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.library-list .history-row > span { min-width: 0; overflow-wrap: anywhere; }
.exercise-instructions { white-space: pre-wrap; overflow-wrap: anywhere; }
.local-diagram { margin: 10px 0; }
.local-diagram img { max-width: 100%; height: auto; }
.local-diagram img[hidden] { display: none; }
.pwa-status { text-align: center; margin: 16px auto 24px; padding: 0 16px; }
.diagram-button { display: block; padding: 0; border: 0; background: transparent; }
#diagram-dialog { margin: auto; max-width: min(94vw, 900px); max-height: 92vh; border: 1px solid var(--line); border-radius: 12px; }
#diagram-dialog img { display: block; margin-top: 10px; }
#diagram-dialog::backdrop { background: #13221bc9; }
.import-list { padding-left: 1.25rem; overflow-wrap: anywhere; }
.import-list li + li { margin-top: 6px; }
.import-routine, #import-preview > h3 { margin-top: 14px; }
#import-preview p, .routine-panel code { overflow-wrap: anywhere; }
.routine-panel textarea { width: 100%; padding: 8px; border: 1px solid #cdd7cd; border-radius: 8px; color: var(--ink); background: #f8faf5; font: inherit; resize: vertical; }
.form-help { color: var(--muted); font-size: .9rem; margin-top: 12px; }
.hero-content > h1 + .button { margin-top: 20px; }
.hero[data-routine-carousel] :is(.hero-image, h1, .hero-meta) { touch-action: pan-y pinch-zoom; }
.routine-carousel-controls { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.routine-carousel-controls button { display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 1px solid #a1b9a9; border-radius: 8px; color: white; background: transparent; }
.routine-carousel-controls svg { pointer-events: none; }
.routine-carousel-controls span { color: #e2ecdc; font-size: .9rem; }
.routine-delete { justify-self: start; }
.error { padding: 12px; border: 1px solid #cf9e91; background: #fff0ea; color: #842c25; border-radius: 8px; margin-bottom: 12px; }

.target-editor { margin-top: 5px; }
.target-editor summary { min-height: 44px; width: fit-content; margin-inline: auto; padding: 12px 8px; color: var(--green); cursor: pointer; font-weight: 700; }
.target-controls { max-width: 300px; margin: 0 auto; padding: 12px; background: #f4f7f0; border-radius: 8px; }
.target-controls .rep-control { grid-template-columns: 54px minmax(65px, 90px) 54px; margin-block: 0 10px; }
.target-controls .rep-control button { min-height: 54px; }
.target-controls output { font-size: 2.25rem; }
.target-controls > .button { width: 100%; margin-top: 10px; }
.check-in { min-inline-size: 0; border: 0; padding: 0; margin: 18px 0 16px; }
.check-in legend { margin-inline: auto; font-weight: 700; }
.check-in legend span { color: var(--muted); font-weight: 400; }
.feeling-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.feeling-options .button { padding-inline: 4px; }
.feeling-options [aria-pressed='true'] { color: white; background: var(--green); }
.exercise-history > p { margin-top: 10px; }
.exercise-history li { align-items: center; }
.exercise-history li .button { flex: 0 0 auto; padding-inline: 8px; }

@media (max-width: 680px) {
  .header-inner { min-height: 59px; }
  nav button { padding-inline: 9px; }
  .home-grid { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
  .home-aside { display: contents; }
  .baseline { order: 1; }
  .home-grid > *, .home-aside > * { width: 100%; }
  .hero { display: flex; flex-direction: column; min-height: auto; border-radius: 17px; }
  .hero-image { height: clamp(111px, 33vw, 200px); background-position: center 37%; }
  .hero-content { align-self: stretch; padding: 19px; }
  .hero h1 { max-width: none; font-size: clamp(2.25rem, 9vw, 3.75rem); }
  .hero-meta { margin-block: 12px 17px; }
  .hero .button { width: 100%; }
}

@media (max-width: 460px) {
  nav svg { display: none; }
  .wordmark { gap: 7px; }
  .brand-icon { width: 28px; }
  .header-inner { column-gap: 6px; }
}

@media (max-width: 350px) {
  .header-inner, nav { gap: 3px; }
  .wordmark, nav button { font-size: .88rem; }
  nav button { padding-inline: 7px; }
}
