/* ── Desktop ≥ 768 px overrides ──────────────────────────────────────────── */
@media (min-width: 768px) {
  .section {
    padding: 26px 28px;
  }

  .divider {
    margin: 0 28px;
  }

  .distance-grid {
    grid-template-columns: repeat(4, 1fr); /* single row on desktop */
    margin-bottom: 12px;
  }

  .dist-btn {
    padding: 10px 6px;
    font-size: 0.9rem;
  }

  .finish-time-input {
    font-size: clamp(2.8rem, 6vw, 3.4rem);
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .stat-box__value {
    font-size: 2rem;
  }
}

/* ── Kompaktowy mobile — wszystko na jednym ekranie ───────────────────────── */
@media (max-width: 767px) {
  .main {
    padding-top: calc(var(--nav-h) + 2px);
    padding-bottom: 6px;
  }

  /* Cały page-header ukryty — zbędne miejsce */
  .page-header { display: none; }

  /* Sekcje */
  .section { padding: 5px 12px; }

  /* Etykiety sekcji — ukryte na mobile, oszczędzamy miejsce */
  .section__label { display: none; }

  .divider { margin: 0 12px; }

  /* Dystans — 4 przyciski w JEDNYM rzędzie */
  .distance-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 0;
  }

  .dist-btn {
    padding: 5px 1px;
    font-size: 0.6rem;
    letter-spacing: -0.01em;
    border-radius: 8px;
    line-height: 1.2;
  }

  /* Własny dystans — ukryty */
  .custom-distance { display: none; }

  /* Tempo biegu — kompaktowa linia */
  .pace-display {
    margin-bottom: 0;
    /* grid pozostaje — kolumna balancer i unit dają prawdziwe centrowanie */
  }

  .pace-display__value {
    font-size: 1.25rem;
    filter: drop-shadow(0 1px 6px rgba(255,80,0,.4));
  }

  .pace-display__unit { font-size: 0.62rem; padding-left: 4px; }

  .slider-wrap { padding: 0; }

  .slider-labels { display: none; }

  .nudge-row { margin-top: 4px; }

  /* Czas ukończenia */
  .finish-time-wrap { margin-bottom: 2px; }

  .finish-time-input {
    font-size: clamp(1.4rem, 6.5vw, 1.8rem);
    padding: 6px 8px;
  }

  .finish-time-hint { display: none; }

  /* Stats */
  .stats-row { gap: 5px; }

  .stat-box { padding: 6px 10px; }

  .stat-box__value { font-size: 1.15rem; }

  .stat-box__label {
    font-size: 0.5rem;
    margin-bottom: 1px;
  }

  .stat-box__unit { font-size: 0.62rem; }
}

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  text-align: center;
  padding: 4px 0 24px;
}

.page-header__title {
  font-size: clamp(1.9rem, 8vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  margin-bottom: 10px;
  background: linear-gradient(160deg, var(--heading-start) 40%, var(--heading-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header__sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 270px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Main card */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

/* Generic section */
.section {
  padding: 22px 20px;
}

.section__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 14px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 0 20px;
}

/* ---- Distance section ---- */
.distance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.dist-btn {
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-light);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s, transform 0.1s;
  user-select: none;
}

.dist-btn:active {
  transform: scale(0.95);
}

.dist-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow-strong);
}

/* Custom distance input row */
.custom-distance {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color 0.2s;
}

.custom-distance:focus-within {
  border-color: var(--accent);
}

.custom-distance__label {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.custom-distance__input-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.custom-distance__input {
  width: 68px;
  text-align: right;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
}

.custom-distance__input::placeholder {
  color: var(--text-dim);
  font-weight: 400;
}

.custom-distance__input::-webkit-outer-spin-button,
.custom-distance__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.custom-distance__input[type=number] {
  -moz-appearance: textfield;
}

.custom-distance__unit {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Pace display (above slider) ---- */
/* Grid 3-kolumnowy: [balancer] [wartość] [jednostka]
   Balancer ma tę samą min-width co kolumna z jednostką → 6:00 jest dokładnie na środku */
.pace-display {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  margin-bottom: 22px;
  width: 100%;
}

.pace-display__value {
  grid-column: 2;
  font-size: clamp(3.2rem, 14vw, 4.2rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  padding-right: 0.08em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #ff6020, var(--accent-bright) 60%, #ffb080);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: opacity 0.1s;
  filter: drop-shadow(0 2px 12px rgba(255,80,0,.45));
  text-align: center;
}

.pace-display__value.flash {
  opacity: 0.5;
}

.pace-display__unit {
  grid-column: 3;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0;
  padding-left: 7px;
  align-self: baseline;
}

/* ---- Result section ---- */
.finish-time-wrap {
  margin-bottom: 8px;
}

.finish-time-input {
  width: 100%;
  text-align: center;
  font-size: clamp(2.4rem, 11vw, 3.2rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 160, 60, 0.07);
  border: 1.5px solid rgba(0, 160, 60, 0.4);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  color: #00a03a;
  background-image: linear-gradient(135deg, #007a30, #00c050 55%, #55e080);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 10px rgba(0,180,60,.35));
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: #00a03a;
  animation: green-pulse 2.8s ease-in-out infinite;
}

/* Ciemny motyw — jasna zieleń */
html.dark .finish-time-input {
  background: rgba(0, 200, 83, 0.06);
  border-color: rgba(0, 200, 83, 0.35);
  background-image: linear-gradient(135deg, #00e06a, #4dffa0 55%, #a0ffcc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 10px rgba(0,220,80,.4));
  caret-color: #00e676;
}

.finish-time-input:focus {
  border-color: #00a040;
  box-shadow: 0 0 0 3px rgba(0, 160, 60, 0.2);
  animation: none;
}

html.dark .finish-time-input:focus {
  border-color: #00e676;
  box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.22);
}

@keyframes green-pulse {
  0%,  100% {
    box-shadow: 0 0 0 1px rgba(0, 160, 60, 0.1),
                0 0 12px rgba(0, 160, 60, 0.05);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(0, 160, 60, 0.25),
                0 0 24px rgba(0, 160, 60, 0.12);
  }
}

html.dark .finish-time-input { animation: green-pulse-dark 2.8s ease-in-out infinite; }
html.dark .finish-time-input:focus { animation: none; }

@keyframes green-pulse-dark {
  0%,  100% {
    box-shadow: 0 0 0 1px rgba(0, 200, 83, 0.1),
                0 0 12px rgba(0, 200, 83, 0.06);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(0, 200, 83, 0.28),
                0 0 24px rgba(0, 200, 83, 0.18);
  }
}

.finish-time-hint {
  font-size: 0.76rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 18px;
  line-height: 1.5;
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats-row--single {
  grid-template-columns: 1fr;
  max-width: none;
}

.stat-box {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.stat-box__label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.stat-box__value {
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}

.stat-box__unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
