/* ── History view shell ──────────────────────────────────────────────────── */
.view-shell {
  display: flex;
  flex-direction: column;
  max-width: 980px;
  margin: 0 auto;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.5rem;
  height: 100%;
  overflow: hidden;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.15rem 0 0.65rem;
  flex-shrink: 0;
}

.view-header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 3.5vw, 1.7rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* ── History section override ────────────────────────────────────────────── */
#view-history .view-shell {
  width: 100%;
  max-width: none;
}

/* ── Activity log list ───────────────────────────────────────────────────── */
.activity-log-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  flex: 1;
  width: 100%;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 0.5rem);
}

/* ── Activity card — compact grid row ────────────────────────────────────── */
.activity-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "info actions"
    "metrics actions";
  align-items: start;
  column-gap: 0.6rem;
  row-gap: 0.35rem;
  width: 100%;
  padding: 0.62rem 0.85rem;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 18px;
  backdrop-filter: blur(6px);
  animation: rise 400ms ease both;
  transition: border-color 150ms, background 150ms;
}
.activity-card:active { background: rgba(165, 202, 214, 0.06); }
.activity-card:hover  { border-color: rgba(165, 202, 214, 0.32); }

/* ── Info column (sport + date) ──────────────────────────────────────────── */
.activity-card__info {
  grid-area: info;
  min-width: 0;
}

.activity-sport {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

.activity-date {
  margin: 0.08rem 0 0;
  font-size: 0.72rem;
  color: var(--text-soft);
  font-weight: 500;
}

/* ── Metrics column (time, distance, guided) ─────────────────────────────── */
.activity-card__metrics {
  grid-area: metrics;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.activity-metric {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-soft);
  background: rgba(165, 202, 214, 0.08);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  white-space: nowrap;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.activity-guided-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  line-height: 1.3;
}

/* ── Actions column ──────────────────────────────────────────────────────── */
.activity-card__actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  align-self: center;
}

.activity-detail-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 1.05rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 160ms, border-color 160ms;
}

.activity-detail-btn:hover {
  color: var(--text-main);
  border-color: rgba(165, 202, 214, 0.4);
}

.activity-delete-btn {
  background: none;
  border: 1px solid rgba(218, 65, 65, 0.18);
  border-radius: 999px;
  color: rgba(218, 65, 65, 0.5);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 160ms, border-color 160ms, background 160ms;
  padding: 0;
}

.activity-delete-btn:hover {
  color: var(--danger);
  border-color: rgba(218, 65, 65, 0.5);
  background: rgba(218, 65, 65, 0.1);
}

/* ── Activity detail dialog content ─────────────────────────────────────── */
.detail-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.45rem;
}

.detail-kpis .summary-kpi-card {
  border-left: 3px solid var(--primary);
}

.detail-section-title {
  margin: 0.6rem 0 0.25rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  font-weight: 600;
}

.detail-guided-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.detail-guided-card {
  background: rgba(9, 27, 35, 0.7);
  border: 1px solid rgba(170, 198, 209, 0.18);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
}

.detail-guided-card h4 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.detail-guided-meta {
  margin: 0.2rem 0 0.35rem;
  font-size: 0.78rem;
  color: #c5d8de;
}

.detail-guided-stats {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.stat-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  line-height: 1.3;
}

.stat-ok {
  background: rgba(24, 191, 125, 0.2);
  color: var(--primary);
}

.stat-skip {
  background: rgba(247, 147, 30, 0.2);
  color: var(--accent);
}

.stat-stop {
  background: rgba(218, 65, 65, 0.2);
  color: var(--danger);
}

/* ── Sport breakdown ─────────────────────────────────────────────────────── */
.detail-sport-breakdown {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.detail-sport-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(165, 202, 214, 0.08);
  border: 1px solid rgba(170, 198, 209, 0.15);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  color: var(--text-main);
}

.detail-sport-chip__time {
  color: var(--text-soft);
  font-weight: 500;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  margin: 2rem auto;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.93rem;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .detail-kpis {
    grid-template-columns: 1fr 1fr;
  }
}
