:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --line: #dfe2dc;
  --text: #171a18;
  --muted: #68706a;
  --accent: #1d7a4c;
  --accent-text: #ffffff;
  --accent-soft: #e3f1e9;
  --danger: #b3261e;
  --field: #f6f7f4;
  --chart: #1d7a4c;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101311;
    --surface: #1a1e1b;
    --line: #2c322e;
    --text: #eceeea;
    --muted: #98a19a;
    --accent: #4cc38a;
    --accent-text: #08130d;
    --accent-soft: #1c3327;
    --danger: #ff8a80;
    --field: #131614;
    --chart: #37a472;
  }
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  padding-top: max(16px, env(safe-area-inset-top));
}

h1 { font-size: 26px; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 28px 0 10px; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 14px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  min-height: 40px;
}

.link {
  background: none;
  border: 0;
  padding: 8px 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.link.danger { color: var(--danger); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 12px; }

.btn {
  display: block;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 18px;
  font-weight: 650;
  cursor: pointer;
}
.btn:disabled { opacity: 0.6; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }

:is(.btn, .link, .chip, input):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* главная */
.eyebrow { font-size: 14px; color: var(--muted); }
.eyebrow::first-letter { text-transform: uppercase; }
.hero-day { font-size: 34px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; margin: 4px 0 14px; }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.chip {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 650; }

.plan { list-style: none; margin: 0 0 16px; padding: 0; }
.plan li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 15px; }
.plan li:first-child { border-top: 0; }
.plan .target { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.rows li:first-child a { border-top: 0; }
.rows .meta { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px; margin-left: 8px; }

/* тренировка */
.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ex-name { font-size: 17px; font-weight: 650; }
.ex-target { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ex-note { color: var(--muted); font-size: 14px; margin-top: 2px; }
.ex-hint { font-size: 14px; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--field); color: var(--muted); }
.ex-hint.up { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sets { margin-top: 12px; display: grid; gap: 8px; }
.set { display: grid; grid-template-columns: 26px 1fr 14px 1fr; align-items: center; gap: 8px; }
.set.no-weight { grid-template-columns: 26px 1fr; }
.set-n {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 650;
  background: var(--field); color: var(--muted);
}
.set.done .set-n { background: var(--accent); color: var(--accent-text); }
.times { text-align: center; color: var(--muted); }

.field { position: relative; }
.field input {
  width: 100%;
  height: 48px;
  padding: 0 48px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.field input::placeholder { color: var(--muted); opacity: 0.55; font-weight: 400; }
.field input.invalid { border-color: var(--danger); }
.field span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }

.add-set { margin-top: 6px; font-size: 15px; }

.bar {
  position: sticky;
  bottom: 0;
  margin: 16px -16px 0;
  padding: 10px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.status { text-align: center; font-size: 13px; color: var(--muted); min-height: 18px; margin-bottom: 6px; }
.status.error { color: var(--danger); }
.card .status { margin: 0; }
.card .status:empty { display: none; }

.center { text-align: center; margin-top: 16px; }

/* замеры */
.stack { display: grid; gap: 12px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.labeled { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.labeled input[type="date"], select {
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  width: 100%;
  min-width: 0;
}

.quick { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.btn.compact { width: auto; min-height: 48px; padding: 0 18px; font-size: 16px; }
.quick + .error:empty { display: none; }

.reminders { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.reminders a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}
.reminders a::after { content: " →"; color: var(--accent); }
.links { display: flex; gap: 20px; margin-top: 10px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tile-value { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.tile-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.legend > span, .tip-row { display: inline-flex; align-items: center; gap: 6px; }
.key-line { width: 14px; height: 2px; border-radius: 1px; background: var(--chart); flex: none; }
.key-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: 0.6; flex: none; }

.chart { position: relative; margin-bottom: 10px; }
.chart svg { display: block; outline-offset: 2px; border-radius: 6px; }
.chart svg:focus-visible { outline: 2px solid var(--accent); }
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.c-line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.c-raw { fill: var(--muted); opacity: 0.5; }
.c-end { fill: var(--text); font-size: 13px; font-weight: 650; }
.c-cross { stroke: var(--muted); stroke-width: 1; }
.c-hit { fill: transparent; touch-action: pan-y; cursor: crosshair; }
.chart-tip {
  position: absolute;
  top: 0;
  z-index: 1;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.14);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}
.tip-date { color: var(--muted); font-size: 12px; }

.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 0 6px; }
.table td { padding: 9px 0; border-top: 1px solid var(--line); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.icon-btn {
  min-width: 36px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.icon-btn:focus-visible { outline: 2px solid var(--accent); }

/* фото */
.poses { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pose {
  display: grid;
  gap: 2px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.pose.has { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.pose:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.pose-name { font-weight: 650; }
.pose-state { font-size: 13px; color: var(--muted); }

.chips.auto { display: flex; flex-wrap: wrap; }
.chips.auto .chip { padding: 0 14px; }
figure { margin: 0; }
figure img { display: block; width: 100%; border-radius: 10px; background: var(--field); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare figcaption { margin-top: 6px; }
.compare select { height: 40px; font-size: 14px; padding: 0 8px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery img { aspect-ratio: 3 / 4; object-fit: cover; }
.gallery figcaption { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }

/* вход */
.auth { margin-top: 12vh; }
.auth h1 { margin-bottom: 6px; }
.auth form { margin-top: 20px; display: grid; gap: 12px; }
.auth input {
  width: 100%; height: 52px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 18px;
}
.error { color: var(--danger); font-size: 14px; min-height: 20px; }
