/* Основа */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: #f5f7f4;
  color: #16392d;
  font: 16px/1.5 "DM Sans", system-ui, sans-serif;
}

/* Шапка и общие группы */
header, header div, .heading, .metrics, .period, .reply {
  display: flex;
  align-items: center;
}
header {
  background: #153f32;
  color: #fff;
  padding: 15px max(5vw, 18px);
  justify-content: space-between;
  gap: 12px;
}
header div, .heading, .metrics, .period, .reply {
  gap: 16px;
  flex-wrap: wrap;
}
header span, .card { overflow-wrap: anywhere; }
header a, header .plain { color: #fff; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -1px;
  text-decoration: none;
}
.brand i {
  width: 24px;
  height: 17px;
  border: 4px solid #ccf36e;
  border-radius: 1em;
  transform: skew(-18deg);
}
.shell {
  width: min(1050px, 92%);
  margin: 40px auto;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 30px;
}

/* Навигация */
nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.period {
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  padding: 3px;
  border: 1px solid #dce4dc;
  border-radius: 12px;
  background: #fff;
}
nav a, .period a {
  padding: 9px 14px;
  border-radius: 9px;
  text-decoration: none;
}
a, .plain { color: #205c44; }
[aria-current] {
  background: #dfebcf;
  font-weight: 700;
}

/* Заголовки и карточки */
hr {
  border: 0;
  border-top: 1px solid #e3e8df;
  margin: 20px 0;
}
h1 {
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.06;
  letter-spacing: -.05em;
  margin: 0 0 24px;
}
h2 { line-height: 1.2; }
h3 { font-size: 16px; }
.heading {
  justify-content: space-between;
  margin-bottom: 20px;
}
.heading h1 { margin: 0; }
.card {
  box-shadow: 0 3px 14px #16392d09;
  background: #fff;
  border: 1px solid #dce4dc;
  border-radius: 18px;
  padding: clamp(18px, 4vw, 32px);
  margin: 14px 0;
}
.card h2:first-child { margin-top: 0; }
.meta, small { color: #586d60; }
.metrics {
  margin: 12px 0;
  align-items: baseline;
}
.metrics strong {
  font-size: clamp(26px, 4vw, 43px);
  letter-spacing: -.04em;
}
.metrics small { font-size: 14px; }

/* Кнопки и формы */
.button, button {
  background: #dce9df;
  color: #153f32;
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}
.button.add-workout { background: #b8c1ba; }
button[aria-pressed="false"] { background: #edf0ec; color: #495a51; }
button[aria-pressed="true"], .button-danger { background: #f0dedd; color: #6b3c40; }

.feed-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.member-count { font-size: .8rem; color: #58675f; }

/* Страницы тренировок */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 24px 0; }
.pagination > :is(a, span) {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; min-height: 44px; padding: 6px 10px;
  border: 1px solid var(--line, #dce4dc); border-radius: 10px;
  text-decoration: none; font-variant-numeric: tabular-nums;
}
.pagination a { background: var(--surface, #fff); }
.pagination a:hover { border-color: currentColor; }
.pagination > .pagination-gap { min-width: 18px; padding-inline: 2px; border: 0; }
.pagination-summary { flex-basis: 100%; text-align: center; margin-top: 4px; }

.plain {
  background: none;
  padding: 6px 0;
  text-decoration: underline;
}
.fields {
  max-width: 600px;
  display: grid;
  gap: 15px;
}
.fields label {
  font-weight: 600;
  display: block;
}
input:not([type=checkbox]), textarea {
  width: 100%;
  border: 1px solid #9faa9c;
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  background: #fff;
}
.helptext {
  font-size: 13px;
  color: #56665a;
}
.errorlist { color: #9c3022; }
.reply { gap: 8px; }
.reply input {
  flex: 1;
  min-width: 140px;
}

/* Статистика */
.row {
  display: grid;
  grid-template-columns: 50px 1fr 90px;
  align-items: center;
  gap: 10px;
  margin: 13px 0;
  font-variant-numeric: tabular-nums;
}
.row b { text-align: right; }
.track {
  height: 12px;
  background: #f0f2ed;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
}
.track > span { height: 100%; }
.run-color { background: #27734e; }
.walk-color { background: #db8b30; }
.activity-key {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
}
.activity-key i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
}
.week-detail { grid-column: 2 / -1; }

/* Комментарии */
.comments-title {
  margin: 20px 0 8px;
  padding-top: 16px;
  border-top: 1px solid #dce4dc;
  font-size: 15px;
}
.comment-text {
  margin: 5px 0;
  font-size: .9rem;
  line-height: 1.45;
}
.comment-text > strong { color: #244638; }
.comment-row + .reply { margin-top: 12px; }
.comment-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
}
.comment-row + .comment-row { border-top: 1px solid #edf1ec; }
.delete-comment { margin-left: auto; }
.delete-comment button {
  color: #637069;
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
}
.delete-comment button:is(:hover, :focus-visible) {
  color: #9a3231;
  text-decoration: underline;
}

/* Мобильная версия */
@media (max-width: 680px) {
  header { flex-wrap: wrap; }
  .shell {
    display: block;
    margin: 25px auto;
    padding-bottom: 80px;
  }
  nav {
    position: fixed;
    z-index: 1;
    inset: auto 0 0;
    flex-direction: row;
    justify-content: space-evenly;
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #dce4dc;
  }
  nav a { font-size: 14px; }
  .row { grid-template-columns: 42px 1fr 80px; }
  .metrics { gap: 12px; }
}
