/* ═══════════════════════════════════════════════════════════════════════════
   ENTRENA — Main training view
   ═══════════════════════════════════════════════════════════════════════════ */

.app-shell {
  position: relative;
  z-index: 2;
  max-width: 980px;
  margin: 0 auto;
  height: 100%;
  padding: calc(0.5rem + env(safe-area-inset-top)) clamp(0.75rem, 2.2vw, 1.4rem)
    calc(0.75rem + env(safe-area-inset-bottom));
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
  grid-template-areas:
    "top"
    "global"
    "guided"
    "history"
    "controls";
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.top-bar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.1rem 0;
}

.top-bar h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: clamp(1.05rem, 2.6vw, 1.6rem);
}

.pill {
  border: 1px solid var(--line);
  background: rgba(171, 201, 213, 0.08);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  transition: color 250ms, border-color 250ms, background 250ms;
  min-width: 52px;
  text-align: center;
}

/* GPS status indicators */
.gps-off       { color: var(--text-soft); }
.gps-searching { color: #f7c948; border-color: rgba(247, 201, 72, 0.35); }
.gps-ok        { color: var(--primary); border-color: rgba(24, 191, 125, 0.35); }
.gps-medium    { color: #f7931e; border-color: rgba(247, 147, 30, 0.35); }
.gps-low       { color: #da4141; border-color: rgba(218, 65, 65, 0.35); }
.gps-denied,
.gps-no-gps,
.gps-error     { color: #da4141; border-color: rgba(218, 65, 65, 0.35); background: rgba(218, 65, 65, 0.08); }

/* ── Global panel ────────────────────────────────────────────────────────── */
.global-panel {
  grid-area: global;
  padding: 0.75rem 0.85rem;
  border-radius: 18px;
}

.global-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.global-header .label {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Top row: label + sport chip inline */
.global-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.sport-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(24, 191, 125, 0.1);
  border: 1px solid rgba(24, 191, 125, 0.22);
  border-radius: 999px;
  padding: 0.16rem 0.3rem 0.16rem 0.55rem;
  flex-shrink: 0;
  max-width: 170px;
}

.sport-chip span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sport-chip__change {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(24, 191, 125, 0.15);
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  transition: background 160ms, opacity 160ms;
  -webkit-tap-highlight-color: transparent;
}

.sport-chip__change:hover {
  background: rgba(24, 191, 125, 0.28);
}

.sport-chip__change:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Timer display ───────────────────────────────────────────────────────── */
.global-time {
  margin-top: 0.15rem;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: clamp(2.8rem, 14vw, 6.2rem);
  line-height: 0.92;
  color: #8dffd2;
  font-variant-numeric: tabular-nums;
}

/* ── Metric cards ────────────────────────────────────────────────────────── */
.global-metrics-wrap {
  position: relative;
  margin-top: 0.35rem;
}

.global-metrics-edit {
  position: absolute;
  top: -0.1rem;
  right: 0;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border-color: rgba(165, 202, 214, 0.16);
  background: rgba(9, 25, 32, 0.78);
  color: var(--text-soft);
  z-index: 2;
  backdrop-filter: blur(8px);
}

.global-metrics-edit:hover {
  color: var(--text-main);
  border-color: rgba(24, 191, 125, 0.35);
  background: rgba(24, 191, 125, 0.1);
}

.global-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.global-metrics[data-count="1"] {
  grid-template-columns: 1fr;
}

.global-metrics[data-count="3"] .global-metric-card:last-child {
  grid-column: 1 / -1;
}

.global-metric-card {
  border-radius: 12px;
  border: 1px solid rgba(165, 202, 214, 0.14);
  padding: 0.45rem 0.55rem;
  background: rgba(7, 22, 30, 0.5);
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.global-metric-card.is-empty {
  opacity: 0.72;
}

.metric-value.is-placeholder {
  color: #d7e4e8;
  opacity: 0.88;
}

/* ── Sport picker ────────────────────────────────────────────────────────── */
.sport-picker-card {
  margin-top: 0.55rem;
  border: 1px solid rgba(165, 202, 214, 0.14);
  border-radius: 14px;
  background: rgba(8, 20, 26, 0.5);
  padding: 0.6rem;
}

.sport-picker-copy {
  margin: 0.2rem 0 0;
  color: #c8dae0;
  font-size: 0.82rem;
}

.sport-picker-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.sport-select {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(170, 198, 209, 0.2);
  border-radius: 12px;
  background: rgba(13, 31, 39, 0.95);
  color: var(--text-main);
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}

.sport-select:focus {
  border-color: rgba(24, 191, 125, 0.5);
  box-shadow: 0 0 0 2px rgba(24, 191, 125, 0.12);
}

.metric-label {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-soft);
  letter-spacing: 0.08em;
}

.metric-value {
  margin: 0.15rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Botón compacto XS */
.btn-xs {
  padding: 0.4rem 0.85rem !important;
  font-size: 0.82rem !important;
  flex-shrink: 0;
}

/* ── Guided panel ────────────────────────────────────────────────────────── */
.guided-panel {
  grid-area: guided;
  position: relative;
  overflow: hidden;
  padding: 0.75rem 0.85rem;
  min-height: 260px;
  border-radius: 18px;
  background: linear-gradient(170deg, rgba(247, 147, 30, 0.1) 0%, rgba(14, 28, 33, 0.9) 50%);
  border-left: 4px solid var(--accent);
}

/* ── Add guided CTA ──────────────────────────────────────────────────────── */
.add-guided-card {
  grid-area: guided;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.2rem;
  border-radius: 18px;
  cursor: pointer;
  border: 1px dashed rgba(24, 191, 125, 0.28);
  transition: border-color 200ms, background 200ms;
}

.add-guided-card:hover {
  border-color: rgba(24, 191, 125, 0.45);
  background: rgba(24, 191, 125, 0.04);
}

.add-guided-card.hidden {
  display: none;
}

.add-guided-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(24, 191, 125, 0.3);
  background: rgba(24, 191, 125, 0.08);
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 160ms, border-color 160ms, transform 160ms;
  -webkit-tap-highlight-color: transparent;
}

.add-guided-btn:hover {
  background: rgba(24, 191, 125, 0.16);
  border-color: rgba(24, 191, 125, 0.55);
  transform: scale(1.06);
}

.add-guided-btn:active {
  transform: scale(0.97);
}

.add-guided-label {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

/* ── Guided header ────────────────────────────────────────────────────────── */
.guided-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.template-name {
  margin: 0;
  color: #ffc784;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}

.exercise-name {
  margin: 0;
  font-size: clamp(1rem, 3.5vw, 1.7rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.15;
}

/* Two-column layout: current exercise left, next exercise right */
.guided-main-row {
  display: grid;
  grid-template-columns: 1fr 35%;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.guided-left {
  min-width: 0;
}

.guided-right {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem 0.55rem;
  background: rgba(165, 202, 214, 0.06);
  border: 1px solid rgba(165, 202, 214, 0.12);
  border-radius: 12px;
  overflow: hidden;
  gap: 0.06rem;
}

.guided-next-label {
  margin: 0;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-soft);
  white-space: nowrap;
}

.guided-next-name {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #c8d8de;
  line-height: 1.2;
  word-break: break-word;
  hyphens: auto;
}

.guided-next-duration {
  margin: 0.06rem 0 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  color: #a8bfc6;
  font-variant-numeric: tabular-nums;
  line-height: 0.95;
}

/* Compact pause/resume icon button in actions row */
.guided-pause-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(170, 198, 209, 0.2);
  background: rgba(170, 198, 209, 0.08);
  color: var(--text-main);
  cursor: pointer;
  padding: 0;
  transition: background 160ms, color 160ms, border-color 160ms;
  -webkit-tap-highlight-color: transparent;
}

.guided-pause-btn:hover {
  background: rgba(170, 198, 209, 0.18);
}

.guided-pause-btn.paused {
  background: rgba(24, 191, 125, 0.15);
  border-color: rgba(24, 191, 125, 0.3);
  color: var(--primary);
}

.guided-time {
  margin: 0.06rem 0 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: clamp(3rem, 13vw, 4.8rem);
  color: #ffbe67;
  line-height: 0.92;
  font-variant-numeric: tabular-nums;
}

.guided-time.guided-prepared {
  color: #f2f6f7;
  font-size: clamp(2.4rem, 10vw, 3.8rem);
}

.guided-time.guided-countdown {
  color: #8dffd2;
  font-size: clamp(3.6rem, 16vw, 5.8rem);
}

.guided-confirm {
  margin: 0.45rem auto 0;
  width: min(320px, 78%);
}

.guided-confirm:not(.hidden) {
  display: block;
}

/* ── Progress bars ───────────────────────────────────────────────────────── */
.exercise-progress-track,
.session-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(152, 190, 204, 0.15);
  overflow: hidden;
}

.exercise-progress-fill,
.session-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  transition: width 220ms linear;
}

.exercise-progress-fill {
  background: linear-gradient(90deg, #ffdd91 0%, #f7931e 100%);
}

.session-progress-fill {
  background: linear-gradient(90deg, #6ff9be 0%, #18bf7d 100%);
}

.guided-actions-row {
  margin-top: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.next-preview {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.session-progress-wrap {
  margin-top: 0.5rem;
}

.session-time {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

/* ── Countdown overlay ───────────────────────────────────────────────────── */
.countdown-overlay-global {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(6px);
  place-items: center;
}

.countdown-overlay-global:not(.hidden) {
  display: grid;
}

.countdown-overlay-global p {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: clamp(5.5rem, 22vw, 9rem);
  color: #8dffd2;
  text-shadow: 0 10px 28px rgba(24, 191, 125, 0.3);
}

/* ── History panel ───────────────────────────────────────────────────────── */
.history-panel {
  grid-area: history;
  padding: 0.6rem 0.75rem;
  max-height: 200px;
  overflow: auto;
  border-radius: 18px;
}

.history-panel__head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.history-count {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 0.08rem 0.42rem;
  line-height: 1.35;
}

.history-list {
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.history-item,
.history-empty {
  border: 1px solid rgba(165, 202, 214, 0.12);
  border-radius: 12px;
  background: rgba(8, 20, 26, 0.5);
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.history-item.completado {
  border-left: 3px solid var(--primary);
}

.history-item.saltado {
  border-left: 3px solid var(--accent);
}

.history-item.detenido {
  border-left: 3px solid var(--danger);
}

/* ── Controls panel ──────────────────────────────────────────────────────── */
.controls-panel {
  grid-area: controls;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.6rem 0.75rem;
  position: sticky;
  bottom: 0.4rem;
  background: var(--bg-panel-strong);
  border-radius: 18px;
}

.controls-panel > button {
  flex: 1 1 auto;
  min-width: 0;
}

/* ── Dialogs ─────────────────────────────────────────────────────────────── */
.template-dialog {
  width: min(460px, calc(100vw - 2rem));
  max-height: calc(100dvh - 3rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0c1d24;
  color: var(--text-main);
  padding: 0;
}

.template-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.dialog-shell {
  margin: 0;
  padding: 0.85rem;
  display: grid;
  gap: 0.6rem;
}

.dialog-shell header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.dialog-shell header p {
  margin: 0.2rem 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.template-list {
  display: grid;
  gap: 0.45rem;
}

.template-card {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(170, 198, 209, 0.18);
  background: rgba(15, 34, 43, 0.8);
  color: inherit;
  cursor: pointer;
  transition: border-color 160ms, background 160ms;
}

.template-card:hover {
  border-color: rgba(24, 191, 125, 0.3);
  background: rgba(24, 191, 125, 0.04);
}

.template-card h3 {
  margin: 0;
  font-size: 0.94rem;
}

.template-card p {
  margin: 0.2rem 0 0;
  color: var(--text-soft);
  font-size: 0.8rem;
}

/* ── Summary KPIs ────────────────────────────────────────────────────────── */
.summary-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.summary-kpi-card {
  margin: 0;
  border: 1px solid rgba(170, 198, 209, 0.18);
  background: rgba(9, 27, 35, 0.7);
  border-radius: 12px;
  padding: 0.45rem 0.55rem;
}

.summary-label {
  margin: 0;
  font-size: 0.68rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary-value {
  margin: 0.1rem 0 0;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.summary-guided {
  display: grid;
  gap: 0.45rem;
}

.summary-guided-card {
  border: 1px solid rgba(170, 198, 209, 0.18);
  background: rgba(16, 35, 45, 0.78);
  border-radius: 12px;
  padding: 0.5rem 0.6rem;
}

.summary-guided-card h3 {
  margin: 0;
  font-size: 0.92rem;
}

.summary-guided-card p {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: #d0e0e6;
}

.summary-empty {
  margin: 0;
  padding: 0.6rem;
  border-radius: 12px;
  background: rgba(16, 35, 45, 0.5);
  color: var(--text-soft);
  font-size: 0.84rem;
}

.train-metrics-dialog {
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
}

.train-metrics-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.train-metrics-copy {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.train-metrics-section {
  display: grid;
  gap: 0.45rem;
}

.train-metrics-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.train-metrics-section__head h3 {
  margin: 0;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}

.train-metrics-section__head span {
  color: var(--text-soft);
  font-size: 0.74rem;
}

.train-metrics-list {
  display: grid;
  gap: 0.42rem;
}

.train-metrics-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.65rem;
  border-radius: 12px;
  border: 1px solid rgba(170, 198, 209, 0.18);
  background: rgba(12, 31, 39, 0.86);
}

.train-metrics-item--soon {
  border-style: dashed;
  background: rgba(12, 31, 39, 0.56);
}

.train-metrics-item__slot {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(24, 191, 125, 0.12);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.train-metrics-item__body {
  flex: 1;
  min-width: 0;
}

.train-metrics-item__title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.15;
}

.train-metrics-item__meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.76rem;
  color: var(--text-soft);
}

.train-metrics-item__actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.train-metrics-item__btn,
.train-metrics-item__add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(170, 198, 209, 0.18);
  background: rgba(170, 198, 209, 0.06);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 160ms, background-color 160ms, color 160ms;
  padding: 0 0.6rem;
}

.train-metrics-item__btn:hover,
.train-metrics-item__add:hover {
  color: var(--text-main);
  border-color: rgba(24, 191, 125, 0.28);
  background: rgba(24, 191, 125, 0.1);
}

.train-metrics-item__btn:disabled,
.train-metrics-item__add:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.train-metrics-item__btn svg,
.train-metrics-item__add svg {
  pointer-events: none;
}

.train-metrics-item__add {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
}

.train-metrics-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 28px;
  border-radius: 999px;
  padding: 0 0.7rem;
  background: rgba(247, 147, 30, 0.12);
  color: #ffb15b;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dialog-shell menu {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Desktop two-column
   ═══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "top top"
      "global guided"
      "history history"
      "controls controls";
    overflow: hidden;
  }

  .history-panel {
    overflow-y: auto;
    min-height: 0;
  }

  .controls-panel {
    justify-content: center;
  }

  .controls-panel > button {
    flex: 0 1 auto;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile portrait (no-scroll sport layout)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    gap: 0.35rem;
    padding:
      calc(0.35rem + env(safe-area-inset-top))
      0.65rem
      calc(0.35rem + env(safe-area-inset-bottom));
    grid-template-areas: none;
  }

  /* Reset grid-area for flex context */
  .top-bar,
  .global-panel,
  .guided-panel,
  .add-guided-card,
  .history-panel,
  .controls-panel {
    grid-area: auto;
  }

  /* ── Top bar ── */
  .top-bar {
    flex-shrink: 0;
    padding: 0;
  }

  .top-bar h1 {
    font-size: 1rem;
  }

  .pill {
    padding: 0.2rem 0.5rem;
    font-size: 0.68rem;
  }

  /* ── Global panel ── */
  .global-panel {
    flex-shrink: 0;
    padding: 0.55rem 0.65rem;
  }

  .global-header {
    margin-bottom: 0.2rem;
  }

  .global-time {
    font-size: clamp(2rem, 12.5vw, 3.4rem);
  }

  .global-metrics {
    gap: 0.3rem;
  }

  .global-metrics-edit {
    top: -0.05rem;
    width: 28px;
    height: 28px;
  }

  .global-metric-card {
    padding: 0.35rem 0.45rem;
    min-height: 62px;
  }

  .metric-label {
    font-size: 0.62rem;
  }

  .metric-value {
    font-size: 0.92rem;
  }

  .train-metrics-dialog {
    max-height: calc(100dvh - 1.5rem);
  }

  .train-metrics-dialog__head {
    gap: 0.55rem;
  }

  .train-metrics-section__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }

  .train-metrics-item {
    align-items: flex-start;
  }

  .train-metrics-item__actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .dialog-shell menu {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .dialog-shell menu > button {
    flex: 1 1 140px;
  }

  .sport-picker-card {
    margin-top: 0.35rem;
    padding: 0.5rem;
  }

  .sport-picker-controls {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .sport-select,
  .sport-picker-controls .btn-xs {
    width: 100%;
  }

  /* ── Guided panel ── */
  .guided-panel {
    flex-shrink: 0;
    min-height: auto;
    padding: 0.55rem 0.65rem;
  }

  .exercise-name {
    margin: 0;
    font-size: clamp(0.88rem, 3.5vw, 1.15rem);
  }

  .guided-main-row {
    margin-top: 0.35rem;
    gap: 0.3rem;
  }

  .guided-right {
    padding: 0.4rem 0.5rem;
  }

  .guided-next-duration {
    font-size: clamp(1.1rem, 4.5vw, 1.45rem);
  }

  .guided-time {
    font-size: clamp(2.2rem, 10.5vw, 3.2rem);
  }

  .guided-time.guided-countdown {
    font-size: clamp(2.6rem, 13vw, 4rem);
  }

  .guided-time.guided-prepared {
    font-size: clamp(1.8rem, 8vw, 2.6rem);
  }

  .guided-actions-row {
    margin-top: 0.35rem;
    gap: 0.4rem;
  }

  .session-progress-wrap {
    margin-top: 0.3rem;
  }

  .exercise-progress-track,
  .session-progress-track {
    height: 6px;
  }

  /* ── Add guided CTA ── */
  .add-guided-card {
    gap: 0.65rem;
    padding: 0.7rem 0.9rem;
  }

  .add-guided-btn {
    width: 42px;
    height: 42px;
  }

  .add-guided-label {
    font-size: 0.82rem;
  }

  /* ── Global panel: expands to fill space when no guided session ── */
  .app-shell.no-guided .global-panel {
    flex: 1;
    min-height: 0;
  }

  /* ── History panel: compact collapsed by default ── */
  .history-panel {
    flex-shrink: 0;
    overflow: hidden;
    padding: 0.4rem 0.6rem;
    max-height: none;
  }

  .history-expand-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid rgba(165, 202, 214, 0.15);
    background: none;
    color: var(--text-soft);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: color 160ms, background-color 160ms;
    -webkit-tap-highlight-color: transparent;
  }

  .history-expand-btn:hover {
    color: var(--text-main);
    background: rgba(165, 202, 214, 0.08);
  }

  .history-expand-btn svg {
    transition: transform 280ms ease;
  }

  .history-panel.expanded .history-expand-btn svg {
    transform: rotate(180deg);
  }

  /* List hidden by default; slides open when expanded */
  .history-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 300ms ease;
    margin-top: 0;
  }

  .history-panel.expanded .history-list {
    max-height: 35dvh;
    overflow-y: auto;
    margin-top: 0.35rem;
  }

  /* ── Controls panel: flow at bottom ── */
  .controls-panel {
    flex-shrink: 0;
    position: static;
    bottom: auto;
    padding: 0.45rem 0.55rem;
    gap: 0.35rem;
  }

  /* Compact buttons for mobile */
  .primary-btn,
  .secondary-btn,
  .accent-btn,
  .danger-btn {
    padding: 0.6rem 0.9rem;
    font-size: 0.84rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Very small screens (< 390px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 389px) {
  .global-time {
    font-size: 11vw;
  }

  .guided-time {
    font-size: 9.5vw;
  }

  .guided-time.guided-countdown {
    font-size: 12vw;
  }

  .top-bar h1 {
    font-size: 0.92rem;
  }

  .primary-btn,
  .secondary-btn,
  .accent-btn,
  .danger-btn {
    padding: 0.52rem 0.75rem;
    font-size: 0.8rem;
  }
}
