:root {
  color-scheme: dark;
  font: 16px system-ui, sans-serif;
  color: #f5f3ef;
  background: #101112;
  --surface: #1a1b1d;
  --control: #252629;
  --line: #3d3f43;
  --muted: #bcbbb8;
  --accent: #ff942e;
  --on-accent: #1e1207;
  --accent-surface: #372416;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .35rem max(.75rem, calc((100% - 48rem) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

header a { color: inherit; text-decoration: none; font-weight: 750; }
header a::before {
  content: "";
  display: inline-block;
  width: .45rem;
  height: .85em;
  margin-right: .5rem;
  border-radius: .15rem;
  background: var(--accent);
}

main { max-width: 49.5rem; margin: auto; padding: .75rem; }
.credits { max-width: 49.5rem; margin: .5rem auto; padding: .75rem; color: var(--muted); font-size: .8rem; }
.credits a { color: var(--accent); }
nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .2rem;
  padding: .2rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--surface);
}

nav button {
  margin: 0;
  padding: .25rem .1rem;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: clamp(.75rem, 3.3vw, .9rem);
}

nav [aria-current] {
  border-color: #805025;
  background: var(--accent-surface);
  color: #ffad60;
  font-weight: 700;
}

h1 { margin: .95rem 0 .65rem; font-size: clamp(1.4rem, 5vw, 2rem); line-height: 1.15; }
h2 { margin: 0 0 .4rem; font-size: 1.05rem; line-height: 1.25; }
h3 { font-size: .95rem; }
p { margin: .45rem 0; }
article, #status {
  margin: .55rem 0;
  padding: .7rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--surface);
  overflow-wrap: anywhere;
}

article > p { color: var(--muted); }
article > :last-child { margin-bottom: 0; }
#status { border-color: #805025; background: var(--accent-surface); color: #ffd2a8; }

button, input, textarea, select { font: inherit; color: inherit; }
button {
  min-height: 2.75rem;
  min-width: 2.75rem;
  margin: .12rem .22rem .12rem 0;
  padding: .3rem .65rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--control);
  font-size: .875rem;
  line-height: 1.2;
  cursor: pointer;
}

button:disabled { cursor: default; opacity: .55; }
button.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 750; }
button:not(:disabled):active { filter: brightness(1.18); }
header button { margin: 0; }
label { display: block; min-width: 0; margin: .4rem 0; color: var(--muted); font-size: .8rem; }
input, textarea, select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 2.75rem;
  margin-top: .2rem;
  padding: .38rem .5rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: #121315;
  color: #f5f3ef;
  font-size: 1rem;
}

input[type=checkbox] {
  display: inline;
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  margin: 0 .45rem;
  vertical-align: middle;
  accent-color: var(--accent);
}
label:has(input[type=checkbox]) { min-height: 2.75rem; align-content: center; cursor: pointer; }
input::file-selector-button {
  margin-right: .5rem;
  padding: .25rem .5rem;
  border: 1px solid var(--line);
  border-radius: .3rem;
  background: var(--control);
  color: inherit;
}
textarea { min-height: 5rem; resize: vertical; }
fieldset {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 .35rem;
  min-width: 0;
  margin: .45rem 0;
  padding: .4rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
}
fieldset label:has(select), fieldset button { grid-column: 1 / -1; }
fieldset button { justify-self: start; }
dialog {
  width: min(36rem, calc(100% - 1.5rem));
  max-height: 86dvh;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--surface);
  color: inherit;
  overflow-wrap: anywhere;
}
dialog::backdrop { background: #000b; }
.description { white-space: pre-wrap; }
img { display: block; max-width: 100%; max-height: 22rem; object-fit: contain; border-radius: .45rem; }
.exercise-preview {
  width: min(100%, 18rem);
  height: 7rem;
  margin: .4rem 0;
  object-fit: contain;
  object-position: left center;
}
.workout-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) fit-content(55%) auto;
  align-items: center;
  gap: .5rem;
  width: 100%;
  margin: .25rem 0;
  padding: .35rem .6rem;
  background: var(--surface);
  text-align: left;
  overflow-wrap: anywhere;
}
.workout-summary::after {
  grid-column: 3;
  content: "›";
  color: var(--accent);
  font-size: 1.15rem;
}
.workout-summary-title { font-weight: 650; }
.workout-summary-detail {
  color: var(--muted);
  font-size: .8rem;
  text-align: right;
}
.add-exercise { margin: .35rem 0; }
.workout-metrics { margin-bottom: .65rem; }
.workout-completed { border-top: 1px solid var(--line); }
.workout-completed summary {
  min-height: 2.75rem;
  align-content: center;
  cursor: pointer;
  font-size: .875rem;
}
.workout-completed p { padding-inline-start: 1rem; font-size: .8rem; }
.workout-editor { max-height: min(86dvh, 42rem); }
.workout-editor p { font-size: .875rem; }
.workout-set .set-duration { grid-column: auto; align-self: end; justify-self: stretch; margin: 0 0 .4rem; }
.workout-set label:has(input[type=checkbox]) { grid-column: 1 / -1; margin: 0; }
.duration-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.editor-error { color: #ffb278; }
.editor-error:empty { display: none; }
@media (max-width: 35rem) {
  .workout-editor {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding-bottom: max(.85rem, env(safe-area-inset-bottom));
    border-radius: 1rem 1rem 0 0;
  }
}
.calendar-scroll { overflow-x: auto; padding: .3rem 0 .65rem; }
.heatmap { display: grid; grid-template-columns: repeat(52, 1.25rem); gap: .2rem; width: max-content; }
.heatmap > div { display: grid; grid-template-rows: 1.3rem repeat(7, 1.25rem); gap: .2rem; }
.heatmap small { color: var(--muted); font-size: .67rem; white-space: nowrap; }
.heatmap .cell { min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: .23rem; background: #303236; }
.heatmap .level1 { background: #356447; }
.heatmap .level2 { background: #45975e; }
.heatmap .level3 { background: #80d997; }
.heatmap .cell[aria-pressed=true] { outline: 2px solid var(--accent); outline-offset: -2px; }
.heatmap .cell:focus-visible { box-shadow: inset 0 0 0 2px #f5f3ef; outline: none; }
