
:root {
  color-scheme: dark;
  --bg: #0b1017;
  --panel: #141d29;
  --raised: #1b2838;
  --line: #2e4054;
  --text: #f2f7ff;
  --muted: #acbdcf;
  --accent: #a4ddff;
  --accent-ink: #0c2537;
  --glass-solid: #182638;
  --glass-tint: rgb(18 31 47 / .87);
  --glass-edge: #435973;
  --dock-height: calc(66px + env(safe-area-inset-bottom));
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 70% 0%, #18293c, transparent 48rem), var(--bg);
  color: var(--text);
}
header { border-bottom: 1px solid var(--glass-edge); }
.top {
  max-width: 1184px;
  min-height: 74px;
  padding: 0 32px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.05rem; letter-spacing: .11em; }
.brand img { display: block; flex: none; }
main { max-width: 1184px; margin: auto; padding: 36px 32px 56px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw, 4rem); letter-spacing: -.055em; line-height: 1.03; overflow-wrap: anywhere; }
h2 { font-size: 1.18rem; letter-spacing: -.02em; }
h3 { font-size: 1.24rem; letter-spacing: -.025em; overflow-wrap: anywhere; }
p { color: var(--muted); line-height: 1.55; }
p + p { margin-top: 12px; }
button, input, select { font: inherit; }
button { cursor: pointer; color: inherit; border: 0; background: none; }
button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.solid, .outline {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 650;
}
.solid { background: var(--accent); color: var(--accent-ink); }
.outline { background: #182536; border-color: #3c5269; }
.solid:hover { background: #c9ebff; }
.outline:hover { background: #26384d; }
.quiet { min-height: 44px; padding: 7px 4px; color: var(--muted); font-size: .875rem; text-decoration: underline; }
.quiet:hover { color: var(--text); }
.actions, .heading, .row { display: flex; align-items: center; gap: 12px; }
.actions { flex-wrap: wrap; }
.heading, .row { justify-content: space-between; }
.heading { margin-bottom: 12px; }
.heading > :last-child { flex-shrink: 0; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.dock { display: flex; gap: 5px; }
.dock button {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  transition: background-color .15s ease, color .15s ease;
}
.dock button:hover, .dock [aria-current] { background: #213346; color: var(--accent); }
.dock svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.hero {
  display: grid;
  align-items: end;
  position: relative;
  isolation: isolate;
  min-height: clamp(340px, 47vw, 490px);
  padding: clamp(24px, 6vw, 72px);
  overflow: hidden;
  border: 1px solid #334a61;
  border-radius: 24px;
  background: #101b27;
  box-shadow: 0 24px 54px #04070b72;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, #101923 3%, #101923ed 25%, #1019234d 66%, transparent),
    linear-gradient(0deg, #101923b0, transparent 55%),
    url("gym-header.webp") 72% center / cover no-repeat;
}
.hero h1 { font-size: clamp(3rem, 8vw, 6rem); }
.hero p { margin-top: 15px; color: #c5d5e7; font-size: 1.06rem; }
.hero .actions { margin-top: 25px; }
.recent { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 22px; }
.recent p { margin-top: 4px; }

.page-title { padding: 8px 0; min-width: 0; }
.page-title p { margin-top: 12px; }
.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: radial-gradient(ellipse at 95% 0%, #213953, transparent 70%), var(--panel);
}
.completion { display: flex; flex: none; align-items: center; gap: 12px; color: var(--muted); font-size: .875rem; }
@property --completion { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.progress-ring {
  --completion: 0%;
  display: grid;
  position: relative;
  isolation: isolate;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--completion), #354c63 0);
  transition: --completion .24s ease-out;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.progress-ring::before { content: ""; position: absolute; inset: 5px; z-index: -1; border-radius: 50%; background: #152333; }
.progress-ring strong { max-width: 100%; font-size: .94rem; }
.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, #192534, #131d29 70%);
  box-shadow: inset 0 1px #ffffff07, 0 10px 24px #050a1029;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  grid-template-areas: "exercises rest" "exercises summary";
  grid-template-rows: auto 1fr;
  align-items: start;
  gap: 16px 22px;
}
.exercise-list { grid-area: exercises; min-width: 0; }
.exercise-card + .exercise-card { margin-top: 14px; }
.rest-slot { grid-area: rest; }
.rest { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rest.is-running { border-color: #6894b8; }
.time { margin-top: 3px; font-size: 1.85rem; font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.is-running .time { color: var(--accent); }
.summary { grid-area: summary; }
.summary > button { width: 100%; margin-top: 10px; }
.summary .actions { justify-content: space-between; margin-top: 7px; }
.stat { display: flex; gap: 10px; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 12px 0; color: var(--muted); }
.stat strong { color: var(--text); }
.set-list { margin: 0 0 12px; padding: 0; list-style: none; }
.set-row {
  display: grid;
  grid-template-columns: minmax(108px, 1fr) minmax(208px, 260px) auto;
  gap: 12px;
  align-items: end;
  padding: 12px 0;
  border-top: 1px solid #34465a;
}
.set-info { display: grid; align-self: center; gap: 4px; font-size: .875rem; }
.set-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) 44px; gap: 8px; align-items: end; }
.set-fields label { display: grid; gap: 5px; color: var(--muted); font-size: .875rem; }
input, select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #435973;
  border-radius: 8px;
  background: #0f1824;
  color: var(--text);
  font-size: 1rem;
}
input:disabled, select:disabled { opacity: .72; }
.check {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #52708c;
  border-radius: 10px;
  background: #17273a;
  color: #b4c7d9;
  font-size: 1.15rem;
  transition: background-color .18s ease, color .18s ease;
}
.check[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.set-row.just-completed { animation: set-confirmed .28s ease-out; }
.set-row.just-completed .check span { animation: check-in .18s ease-out; }
@keyframes set-confirmed {
  from { background-color: rgb(90 168 224 / .25); }
  to { background-color: transparent; }
}
@keyframes check-in { from { transform: scale(.72); } to { transform: scale(1); } }
.add-set { width: 100%; }

.history, .template-list, .prefs { margin-top: 20px; }
.history details { border-top: 1px solid var(--line); padding: 14px 0; }
.history summary { cursor: pointer; font-weight: 650; overflow-wrap: anywhere; }
.history details p { margin-top: 10px; }
.history details button { margin-top: 12px; }
.template-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.template-list p { margin-top: 8px; }
.template-list ul { color: var(--muted); padding-left: 20px; }
.prefs { max-width: 540px; }
.prefs label, dialog label { display: grid; gap: 8px; margin: 16px 0; font-weight: 600; }
.prefs .switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 20px; min-height: auto; height: 20px; accent-color: var(--accent); }
.prefs [role="status"] { margin-top: 8px; font-size: .9rem; }
dialog {
  width: min(440px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
}
dialog[open] { animation: dialog-enter .16s ease-out; }
@keyframes dialog-enter {
  from { transform: translateY(8px); opacity: .76; }
  to { transform: translateY(0); opacity: 1; }
}
dialog::backdrop { background: #060a10c9; }
dialog > form { display: flex; justify-content: flex-end; }
.close { min-width: 44px; min-height: 44px; font-size: 1.35rem; }
dialog #content p { margin: 10px 0; }
#entry > input { margin: 12px 0; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.choices button { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--raised); }

@media (max-width: 800px) {
  html { scroll-padding-bottom: calc(24px + var(--dock-height)); }
  html:has(.rest.is-running) { scroll-padding-bottom: calc(108px + var(--dock-height)); }
  .top { min-height: 58px; padding: 0 16px; }
  main { padding: 18px 16px calc(28px + var(--dock-height) + var(--keyboard-inset, 0px)); }
  main:has(.rest-slot) { padding-bottom: calc(112px + var(--dock-height) + var(--keyboard-inset, 0px)); }
  .dock {
    position: fixed;
    z-index: 5;
    bottom: var(--keyboard-inset, 0px);
    inset-inline: 0;
    height: var(--dock-height);
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--glass-edge);
    justify-content: center;
  }
  .dock button { display: grid; justify-items: center; align-content: center; gap: 3px; flex: 1; max-width: 130px; padding: 4px 2px; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "rest" "exercises" "summary"; grid-template-rows: auto; }
  .rest-slot { min-height: 6.5rem; }
  .rest:not(.is-running) { min-height: 6.5rem; }
  .rest.is-running {
    position: fixed;
    z-index: 4;
    inset-inline: 16px;
    bottom: calc(8px + var(--dock-height) + var(--keyboard-inset, 0px));
    padding-block: 10px;
    box-shadow: 0 4px 36px #02070dc0;
  }
}
@media (max-width: 520px) {
  .hero { min-height: 440px; padding: 21px; border-radius: 18px; }
  .hero::before {
    background: linear-gradient(0deg, #101923 5%, #101923e0 35%, #10192336 80%),
      url("gym-header.webp") 71% top / auto 75% no-repeat;
  }
  .hero .actions > button { width: 100%; }
  .card, .session-header { padding: 14px; }
  .session-header { align-items: center; gap: 10px; margin-bottom: 16px; }
  .session-header h1 { font-size: clamp(1.55rem, 7vw, 2rem); }
  .session-header p { font-size: .875rem; }
  .completion { flex-direction: column; gap: 5px; text-align: center; }
  .progress-ring { width: 58px; height: 58px; }
  .set-row { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; }
  .set-fields { grid-column: 1 / -1; grid-row: 2; }
  .edit-set { grid-column: 2; grid-row: 1; }
  .set-info { grid-column: 1; grid-row: 1; }
}
header, .rest.is-running, dialog { background: var(--glass-solid); }
@media (max-width: 800px) {
  .dock { background: var(--glass-solid); }
}
@supports (backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px)) {
  header, .rest.is-running, dialog {
    background: var(--glass-tint);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  @media (max-width: 800px) {
    header {
      background: var(--glass-solid);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
    .dock {
      background: var(--glass-tint);
      -webkit-backdrop-filter: blur(12px);
      backdrop-filter: blur(12px);
    }
  }
}
@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
  header, .rest.is-running, dialog, .dock {
    background: var(--glass-solid);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .progress-ring, .check, .dock button { transition: none; }
  .set-row.just-completed, .set-row.just-completed .check span, dialog[open] { animation: none; }
}
