/* ── training.css ──────────────────────────────────────────────*/

/* === Training page === */

#page-training {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.tr-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tr-tab-btn {
  flex: 1;
  padding: 10px;
  background: var(--surface);
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

[data-theme="dark"] .tr-tab-btn { border-color: rgba(255,255,255,0.16); color: var(--text-secondary); }

.tr-tab-btn--active {
  background: var(--nav-navy);
  border-color: var(--nav-navy);
  color: #fff;
}

/* ── Desktop/medium responsive shell (structural placeholders only) ────────
   Tunable via custom properties so columns/breakpoint can be refined by eye
   without another code change. NOTE: CSS media queries cannot read custom
   properties directly (a browser/spec limitation) — --training-medium-
   breakpoint below is a documented single source of truth for humans, but
   the @media (min-width/max-width) values further down must be kept in sync
   with it by hand if it changes. */
:root {
  --training-club-width: 400px;
  --training-personal-fr: 1.2fr;
  --training-tests-fr: 1fr;
  --training-medium-breakpoint: 1450px;
}

/* ── Desktop 3-column / medium 2-column shell (≥768px, the app's existing
   mobile breakpoint) ──
   .tr-desktop-grid (full 3-column, ≥1450px) and .tr-medium-view (Club column
   + a combined Personal/Tests column, 768–1449px) are both hidden by default
   (mobile shows .tr-mobile-view's tabs instead) and swap in above the
   breakpoint. Whichever grid is active needs overflow: hidden or the page
   double-scrolls alongside each column's own scroll. Each column (and each
   medium-tier tab pane) is a flex column of a fixed-height "top" block plus a
   "feed" block that scrolls independently — the feed block (and its flex
   parent) both need min-height: 0, or — as bit us before on weekBoard.js —
   a flex child with overflow-y: auto refuses to shrink and just grows the
   whole page instead of scrolling, with no console error. */
.tr-desktop-grid { display: none; }
.tr-medium-view { display: none; }

@media (min-width: 768px) {
  .tr-mobile-view { display: none; }

  #page-training {
    max-width: none;
    margin: 0;
    padding: 0;
  }
}

/* Medium tier: Club keeps its own fixed-width column (already comfortable at
   this width); Personal and Tests collapse into one shared column behind a
   small internal tab switcher instead of a third grid column. */
@media (min-width: 768px) and (max-width: 1449px) {
  .tr-medium-view {
    display: grid;
    grid-template-columns: var(--training-club-width) 1fr;
    gap: 16px;
    height: calc(100vh - 56px); /* #sticky-header is 56px tall — css/shared.css */
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden;
  }
}

/* Desktop tier: full 3-column layout, all three columns visible at once. */
@media (min-width: 1450px) {
  .tr-desktop-grid {
    display: grid;
    grid-template-columns: var(--training-club-width) var(--training-personal-fr) var(--training-tests-fr);
    gap: 16px;
    height: calc(100vh - 56px); /* #sticky-header is 56px tall — css/shared.css */
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden;
  }
}

.tr-desktop-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
}

/* Medium tier's internal Personal/Tests tab row, nested inside a
   .tr-desktop-col — reuses .tr-tabs/.tr-tab-btn as-is, just needs to not
   shrink and to sit flush with the column's own padding. */
.tr-desktop-col .tr-tabs {
  flex-shrink: 0;
  margin: 12px 12px 0;
}

/* One of two swappable panes inside the medium tier's combined column —
   toggled via display:none/'' by js/training.js switchTrainingMediumTab,
   same convention as the mobile Club/Personal/Tests tabs. */
.tr-medium-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tr-desktop-col-top {
  flex-shrink: 0;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 0.5px solid var(--border);
}

.tr-desktop-col-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  scrollbar-width: none; /* Firefox: hide scrollbar, keep it scrollable */
}

.tr-desktop-col-feed::-webkit-scrollbar { display: none; } /* Chrome/Safari/Edge */

.tr-desktop-col-feed p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 10px;
}

.tr-desktop-col-feed-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.tr-banner {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--surface);
}

.tr-banner-photo {
  position: relative;
  min-height: 220px;
  background-color: var(--nav-navy);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
}

.tr-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 45%, rgba(0,0,0,0.7) 100%);
}

.tr-banner-dest {
  position: relative;
  z-index: 1;
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  color: #fff;
  margin: 0;
  padding: 24px;
  width: 100%;
  box-sizing: border-box;
  text-shadow: 0 1px 6px rgba(0,0,0,0.35);
}

.tr-banner-body {
  padding: 16px 24px 20px;
}

.tr-banner-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 16px;
}

.tr-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.tr-bar-fill {
  height: 100%;
  background: var(--nav-navy);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.tr-bar-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
}

.training-quote {
  padding: 8px 0;
  text-align: center;
}
.training-quote__text {
  font-size: 15px;
  font-style: italic;
  color: var(--text);
  margin: 0 0 6px;
}
.training-quote__attr {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
}

.tr-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.tr-btn-primary {
  flex: 1;
  padding: 12px;
  background: var(--nav-navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.tr-btn-primary:hover { background: var(--navy-mid); }

.tr-btn-secondary {
  flex: 1;
  padding: 12px;
  background: var(--surface);
  color: var(--navy-dark);
  border: 1.5px solid var(--navy-dark);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.tr-btn-secondary:hover { background: var(--navy-light); }

.tr-no-period {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.tr-no-period h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--text);
  margin: 0 0 8px;
}

.tr-no-period p {
  font-size: 14px;
  margin: 0 0 20px;
}

.tr-modal-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
  margin: 16px;
  box-sizing: border-box;
  max-height: 90vh;
  overflow-y: auto;
}

.tr-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.tr-modal-title {
  margin: 0;
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  color: var(--text);
}

.tr-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0;
}

.tr-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tr-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tr-check-label {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  cursor: pointer;
}

.tr-input {
  padding: 10px 14px;
  border: 0.5px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  width: 100%;
  background: var(--surface);
  color: var(--text);
}

.tr-input:focus {
  border-color: var(--navy-dark);
}

.tr-strip {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.tr-strip-stat {
  flex: 1;
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}

.tr-strip-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--navy-dark);
  margin-bottom: 4px;
}

.tr-strip-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tr-section-heading {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  color: var(--text);
  margin: 0 0 14px;
}

.tr-leaderboards {
  margin-bottom: 24px;
}

.tr-lb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.tr-lb-card-full {
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 16px;
}

@media (max-width: 600px) {
  .tr-lb-grid {
    grid-template-columns: 1fr;
  }
  .tr-strip {
    gap: 8px;
  }
  .tr-strip-value {
    font-size: 18px;
  }
}

.tr-lb-card {
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 16px;
}

.tr-lb-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.tr-lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}

.tr-lb-row:last-child {
  border-bottom: none;
}

.tr-lb-rank {
  width: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  flex-shrink: 0;
}

.tr-lb-name {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tr-lb-me {
  font-weight: 600;
  color: var(--navy-dark);
}

.tr-lb-val {
  color: var(--text-secondary);
  font-size: 12px;
  flex-shrink: 0;
}

/* Collapsible stat leaderboard cards */
.tr-slb-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.tr-slb-card {
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s;
  user-select: none;
}

.tr-slb-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.tr-slb-card--open {
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.tr-slb-collapsed {
  padding: 12px 16px 8px;
}

.tr-slb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tr-slb-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-dark);
}

.tr-slb-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tr-slb-pos {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy-dark);
  line-height: 1;
}

.tr-slb-arrow {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.tr-slb-arrow--up {
  color: #16a34a;
}

[data-theme="dark"] .tr-slb-arrow--up { color: #86efac; }

.tr-slb-arrow--down {
  color: #dc2626;
}

[data-theme="dark"] .tr-slb-arrow--down { color: #fca5a5; }

.tr-slb-see-all {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-align: right;
}

.tr-slb-expanded {
  border-top: 0.5px solid var(--border);
  padding: 4px 16px 12px;
}

.tr-slb-list {
  margin-top: 8px;
}

.tr-slb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}

.tr-slb-row:last-child {
  border-bottom: none;
}

.tr-slb-row--me .tr-slb-name {
  font-weight: 600;
  color: var(--navy-dark);
}

.tr-slb-rank {
  width: 22px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  flex-shrink: 0;
}

.tr-slb-name {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tr-slb-val {
  color: var(--text-secondary);
  font-size: 12px;
  flex-shrink: 0;
}

.tr-slb-empty {
  padding: 12px 0;
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
}

.tr-slb-toggle {
  display: block;
  margin: 12px auto 0;
  padding: 8px 20px;
  background: #f3f4f6;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

[data-theme="dark"] .tr-slb-toggle { background: rgba(255,255,255,0.08); }

.tr-slb-toggle:hover {
  background: #e5e7eb;
}

[data-theme="dark"] .tr-slb-toggle:hover { background: rgba(255,255,255,0.14); }

.tr-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-tertiary);
  font-size: 14px;
}

.tr-km-preview {
  font-size: 12px;
  color: var(--navy-dark);
  margin-top: 6px;
  min-height: 16px;
  font-weight: 500;
}

/* Activity-type filter pills above the Mine tab's "My training log" list —
   same active/inactive treatment as .tr-tab-btn (navy fill when selected)
   but pill-shaped and left-aligned since there are more than two-three
   options and they shouldn't stretch to fill the row. */
.tr-logfilter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.tr-logfilter-row::-webkit-scrollbar {
  display: none;
}

.tr-logfilter-pill {
  flex-shrink: 0;
  padding: 6px 12px;
  background: var(--surface);
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #6b7280;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

[data-theme="dark"] .tr-logfilter-pill { border-color: rgba(255,255,255,0.16); color: var(--text-secondary); }

.tr-logfilter-pill--active {
  background: var(--nav-navy);
  border-color: var(--nav-navy);
  color: #fff;
}

.tr-feed {
  margin-bottom: 32px;
}

.tr-feed-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.tr-feed-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.tr-feed-entry:last-child {
  border-bottom: none;
}

.tr-feed-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tr-feed-who {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 80px;
}

.tr-feed-km {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  flex-shrink: 0;
}

.tr-feed-date {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.tr-feed-note {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
}

.tr-feed-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.tr-feed-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tr-feed-row1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tr-feed-verb {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
}

.tr-feed-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tr-feed-time {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.tr-feed-pending {
  font-size: 13px;
  color: #92400e;
}

[data-theme="dark"] .tr-feed-pending { color: var(--mix-text); }

.tr-feed-photo {
  max-height: 120px;
  max-width: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  margin-top: 6px;
}

.tr-feed-edit {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.tr-feed-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.tr-feed-delete:hover {
  color: #991b1b;
}

[data-theme="dark"] .tr-feed-delete:hover { color: #fca5a5; }

.tr-strip-heading {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
}

.tr-review-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fef9c3;
  border: 0.5px solid #ca8a04;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #854d0e;
  font-weight: 500;
}

[data-theme="dark"] .tr-review-bar { background: rgba(202,138,4,0.18); border-color: rgba(202,138,4,0.45); color: #fde047; }

.tr-review-btn {
  background: #854d0e;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

[data-theme="dark"] .tr-review-btn { background: var(--mix); }

.tr-review-panel {
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}

.tr-review-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border);
  flex-wrap: wrap;
  font-size: 13px;
}

.tr-review-entry:last-child {
  border-bottom: none;
}

.tr-review-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.tr-approve-btn {
  background: #dcfce7;
  color: #166534;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

[data-theme="dark"] .tr-approve-btn { background: rgba(22,163,74,0.18); color: #86efac; }

.tr-reject-btn {
  background: #fee2e2;
  color: #991b1b;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

[data-theme="dark"] .tr-reject-btn { background: rgba(239,68,68,0.18); color: #fca5a5; }

.tr-pending-badge {
  font-size: 11px;
  color: #854d0e;
  background: #fef9c3;
  border-radius: 20px;
  padding: 2px 7px;
  font-weight: 600;
  flex-shrink: 0;
}

[data-theme="dark"] .tr-pending-badge { color: var(--mix-text); background: var(--mix-bg); }

.tr-verified-badge {
  font-size: 11px;
  color: #166534;
  background: #dcfce7;
  border-radius: 20px;
  padding: 2px 7px;
  font-weight: 600;
  flex-shrink: 0;
}

[data-theme="dark"] .tr-verified-badge { background: rgba(22,163,74,0.18); color: #86efac; }

.tr-rejected-badge {
  font-size: 11px;
  color: #991b1b;
  background: #fee2e2;
  border-radius: 20px;
  padding: 2px 7px;
  font-weight: 600;
  flex-shrink: 0;
}

[data-theme="dark"] .tr-rejected-badge { background: rgba(239,68,68,0.18); color: #fca5a5; }

.tr-plan-circles {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-bottom: 6px;
  padding-top: 4px;
}

.tr-plan-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  flex-shrink: 0;
}

.tr-plan-circle.filled {
  background: var(--nav-navy);
  border-color: var(--nav-navy);
}

.training-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--nav-navy);
  color: white;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 100px;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.training-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.training-milestone-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 190ms ease-out;
}

.training-milestone-overlay--visible {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 200ms ease-out;
}

.training-milestone-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  max-height: 65vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 190ms ease-out;
  z-index: 401;
}

.training-milestone-sheet--visible {
  transform: translateY(0);
  transition: transform 300ms var(--spring-ease);
}

.training-milestone-photo-wrap {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
  flex-shrink: 0;
  background: var(--nav-navy);
}

.training-milestone-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.training-milestone-photo-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.1) 60%, transparent 100%);
  display: flex;
  align-items: flex-end;
  padding: 20px;
}

.training-milestone-dest-name {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.45);
  line-height: 1.2;
  margin: 0;
}

.training-milestone-body {
  padding: 24px;
}

.training-milestone-emoji {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}

.training-milestone-heading {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--navy-dark);
  margin: 0 0 8px;
}

.training-milestone-sub {
  font-size: 14px;
  color: var(--text-tertiary);
  text-align: center;
  margin: 0 0 4px;
  line-height: 1.5;
}

.training-milestone-btn {
  width: 100%;
  padding: 13px;
  background: var(--nav-navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 20px;
  display: block;
}

/* Banner journey link */
.tr-bar-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.training-banner-journey-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.4);
  backdrop-filter: blur(4px);
  cursor: pointer;
  z-index: 2;
  white-space: nowrap;
}

/* Journey modal */
.journey-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  align-items: center;
  justify-content: center;
}

.journey-modal-card {
  background: var(--surface);
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.journey-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.journey-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.journey-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0 2px;
}

.journey-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
}

[data-theme="dark"] .journey-modal-body {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--surface);
}

[data-theme="dark"] .journey-modal-body::-webkit-scrollbar {
  width: 8px;
}

[data-theme="dark"] .journey-modal-body::-webkit-scrollbar-track {
  background: var(--surface);
}

[data-theme="dark"] .journey-modal-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

[data-theme="dark"] .journey-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

.journey-modal-timeline {
  padding: 16px;
}

.journey-modal-summary {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 12px 0 4px;
}

/* Timeline rows */
.journey-stop-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0 16px;
  position: relative;
}

.journey-stop-row--last {
  padding-bottom: 6px;
}

.journey-stop-row:not(.journey-stop-row--last)::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 22px;
  bottom: 0;
  width: 1px;
  background: #e2e8f0;
}

[data-theme="dark"] .journey-stop-row:not(.journey-stop-row--last)::after { background: var(--border-strong); }

.journey-stop-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  margin-top: 1px;
}

.journey-stop-icon--start {
  background: #1e293b;
}

[data-theme="dark"] .journey-stop-icon--start { background: rgba(255,255,255,0.25); }

.journey-stop-icon--reached {
  background: #22c55e;
  color: #fff;
}

.journey-stop-icon--current {
  background: #f59e0b;
  animation: journey-pulse 1.5s ease-in-out infinite;
}

.journey-stop-icon--upcoming {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  box-sizing: border-box;
}

[data-theme="dark"] .journey-stop-icon--upcoming { background: var(--surface); border-color: var(--border-strong); }

.journey-stop-body {
  flex: 1;
  min-width: 0;
}

.journey-stop-name {
  display: block;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.journey-stop-remain {
  font-size: 12px;
  color: #f59e0b;
  margin-top: 2px;
}

.journey-stop-dist {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  margin-top: 1px;
  flex-shrink: 0;
}

@keyframes journey-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

@media (max-width: 640px) {
  .journey-modal-overlay {
    align-items: flex-end;
  }

  .journey-modal-card {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 88svh;
  }
}

/* ── Leaderboard card: new elements ── */

.tr-lb-grid .tr-lb-card-full {
  grid-column: 1 / -1;
}

.tr-lb-empty-note {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 4px 0 8px;
}

.tr-lb-divider {
  height: 0.5px;
  background: var(--border);
  margin: 6px 0;
}

.tr-lb-rank--pos {
  font-size: 11px !important;
  color: var(--text-tertiary) !important;
  font-weight: 500;
}

.tr-lb-you {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 11px;
}

.tr-lb-full-btn {
  display: block;
  width: 100%;
  text-align: right;
  background: none;
  border: none;
  padding: 8px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--navy-dark);
  cursor: pointer;
  font-family: inherit;
}

.tr-lb-full-btn:hover {
  text-decoration: underline;
}

.tr-lb-see-all-btn {
  display: block;
  margin: 14px auto 0;
  padding: 8px 22px;
  background: #f3f4f6;
  border: 1.5px solid #d1d5db;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-dark);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

[data-theme="dark"] .tr-lb-see-all-btn { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.16); }

.tr-lb-see-all-btn:hover {
  background: #e5e7eb;
}

[data-theme="dark"] .tr-lb-see-all-btn:hover { background: rgba(255,255,255,0.14); }

/* ── Leaderboard modals ── */

.tr-lb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 601px) {
  .tr-lb-modal-overlay {
    align-items: center;
  }
}

.tr-lb-modal-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 601px) {
  .tr-lb-modal-sheet {
    border-radius: 16px;
    max-width: 480px;
    max-height: 80vh;
  }
}

.tr-lb-modal-sheet--wide {
  max-height: 90vh;
}

@media (min-width: 601px) {
  .tr-lb-modal-sheet--wide {
    max-width: 600px;
    max-height: 600px;
  }
}

.tr-lb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}

.tr-lb-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-dark);
}

.tr-lb-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  font-family: inherit;
}

.tr-lb-modal-close:hover {
  color: var(--text-secondary);
}

.tr-lb-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.tr-lb-modal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 0.5px solid var(--border);
}

.tr-lb-modal-row:last-child {
  border-bottom: none;
}

.tr-lb-modal-row--me {
  background: #f0f4ff;
}

[data-theme="dark"] .tr-lb-modal-row--me { background: rgba(59,130,246,0.15); }

.tr-lb-modal-rank {
  width: 28px;
  font-size: 14px;
  text-align: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.tr-lb-modal-name {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tr-lb-modal-name--me {
  font-weight: 700;
  color: var(--navy-dark);
}

.tr-lb-modal-val {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.tr-lb-modal-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.tr-lb-modal-sticky-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 0.5px solid var(--border);
  background: #f0f4ff;
  flex-shrink: 0;
}

[data-theme="dark"] .tr-lb-modal-sticky-user { background: rgba(59,130,246,0.15); }

.tr-lb-modal-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 16px 16px 8px;
}

.tr-lb-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 4px;
}

@media (max-width: 600px) {
  .tr-lb-modal-grid {
    grid-template-columns: 1fr;
  }
}

.tr-lb-modal-card {
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px;
}

/* ── Activity feed: like button ── */

.tr-feed-like-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.tr-feed-like-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 2px 0;
  line-height: 1;
  transition: transform 0.1s;
}

.tr-feed-like-btn:active {
  transform: scale(1.3);
}

.tr-feed-like-count {
  font-size: 13px;
  color: var(--text-tertiary);
}


/* ── Activity feed masonry ── */
.feed-masonry {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.feed-col {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tr-feed-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tr-feed-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.tr-feed-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.tr-feed-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.tr-feed-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tr-feed-inline-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.tr-feed-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.tr-feed-pills .tr-feed-note {
  width: 100%;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
  text-overflow: clip;
}

.tr-feed-like-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tr-feed-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}

.tr-feed-pill--intense {
  background: #fff7ed;
  color: #c2410c;
}

[data-theme="dark"] .tr-feed-pill--intense { background: rgba(234,88,12,0.18); color: #fdba74; }

.tr-feed-pill--plan {
  background: #f0fdf4;
  color: #15803d;
}

[data-theme="dark"] .tr-feed-pill--plan { background: rgba(22,163,74,0.18); color: #86efac; }

/* Combined water-outing card (js/training.js buildOutingCard) — squad/boat/
   crew-count pills alongside the existing activity-type pill, which keeps
   its own inline per-type colour. */
.tr-feed-pill--info {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

[data-theme="dark"] .tr-feed-pill--info { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

.tr-feed-outing-icon {
  background: #6b7280;
}

/* Expandable water-outing card, Personal column (js/training.js
   buildFeedCard's outingData branch) — "new" highlight + crew/summary/
   feedback panel. */
.tr-feed-card--new {
  border-color: #7c3aed;
  box-shadow: 0 0 0 1px rgba(124,58,237,0.25);
}

[data-theme="dark"] .tr-feed-card--new { border-color: #a78bfa; box-shadow: 0 0 0 1px rgba(167,139,250,0.3); }

.tr-feed-pill--new {
  background: #7c3aed;
  color: #fff;
  letter-spacing: 0.04em;
}

[data-theme="dark"] .tr-feed-pill--new { background: #a78bfa; color: #1e1033; }

.tr-feed-expand-toggle {
  align-self: flex-start;
  margin-top: 2px;
  padding: 0;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #5b21b6);
  cursor: pointer;
}

.tr-feed-expand-toggle:hover {
  text-decoration: underline;
}

.tr-feed-expand-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.tr-feed-expand-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.tr-feed-expand-crew {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tr-feed-expand-crew-row {
  display: flex;
  gap: 8px;
  font-size: 13px;
}

.tr-feed-expand-crew-label {
  min-width: 60px;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.tr-feed-expand-crew-name {
  color: var(--text);
  font-weight: 500;
}

.tr-feed-expand-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}

.tr-feed-expand-empty {
  color: var(--text-tertiary);
  font-style: italic;
}

.tr-feed-photo-wrap {
  display: block;
  text-decoration: none;
  flex-shrink: 0;
}

.tr-feed-photo-img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
}

.tr-feed-load-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 0;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.tr-feed-load-more:hover {
  background: var(--bg);
}

@media (max-width: 600px) {
  .tr-feed-card--nophoto .tr-feed-card-body {
    padding: 10px;
  }

  .tr-feed-card--nophoto .tr-feed-inline-avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
}

/* ── Mine tab: intensity heatmap + stats card ──
   Distinct "tr-heatmap-*" naming on purpose — css/captain-heatmap.css (the
   unrelated captain availability-overview heatmap) uses its own "hm-*"
   classes; the two must never get confused in a future search/edit. Stacked
   by default (same order as mobile: stats on top, heatmap below), side by
   side once there's room. */
.tr-personal-top-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

/* Deliberately its own breakpoint, not the page's 768px (mobile <-> medium/
   desktop) or 1450px (medium <-> desktop) tiers used elsewhere in this file
   — see --training-medium-breakpoint above. In the medium tier the Personal
   column's actual width is (viewport - club column - gaps - padding), so it
   keeps shrinking well below 768px's own trigger point; row layout starts
   clipping/wrapping the Stats card's three-stat strip once that column
   drops under ~1030px wide. Scoped to just this row + its two cards so it
   can be tuned by eye (same convention as --training-medium-breakpoint)
   without touching the .tr-mobile-view/.tr-medium-view/.tr-desktop-grid
   tier switches above. */
@media (min-width: 1030px) {
  .tr-personal-top-row {
    flex-direction: row;
  }

  /* Stats card absorbs whatever width is left over; the heatmap card
     shrink-to-fits its grid's own content width instead of taking an equal
     flex share. min-width: 0 on both lets either compress past its content
     size at tight widths — the heatmap defers to .tr-heatmap-grid's own
     horizontal scroll rather than overflowing the row. */
  .tr-heatmap-card {
    flex: 0 1 auto;
    min-width: 0;
  }

  .tr-stats-card {
    flex: 1 1 0%;
    min-width: 0;
  }
}

.tr-heatmap-card,
.tr-stats-card {
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 14px 16px;
}

.tr-heatmap-caption,
.tr-stats-caption {
  font-size: 11px;
  color: var(--text-tertiary);
  margin: -6px 0 10px;
}

/* Stats card's three stat blocks reuse .tr-strip/.tr-strip-stat/
   .tr-strip-value/.tr-strip-label as-is (see renderSummaryStrip's "Your
   stats" strip) for typographic consistency — flex:1 per block fills
   whatever width the card has. */
.tr-stats-card .tr-strip {
  margin-bottom: 0;
}

.tr-heatmap-body {
  display: flex;
  gap: 4px;
}

/* One label per grid row (days), not per column — matches the grid's actual
   rows-are-days/columns-are-weeks orientation below. Height/gap mirror
   .tr-heatmap-cell/.tr-heatmap-col exactly so each label lines up with its
   row. */
.tr-heatmap-daylabels {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.tr-heatmap-daylabel {
  height: 10px;
  line-height: 10px;
  font-size: 9px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.tr-heatmap-grid {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 2px;
  min-width: 0;
}

.tr-heatmap-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.tr-heatmap-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--nav-navy);
}

/* No activity: a neutral filled square (not an opacity step off --nav-navy)
   so the grid shape stays visible even for an all-empty window. Buckets 1-4
   are the same accent token used elsewhere for general app accents/badges
   (see base.css's --nav-navy comment) at increasing opacity — a simple,
   theme-safe intensity ramp with no colours to revisit once this column's
   own dark-mode pass happens. */
.tr-heatmap-cell--0 { background: var(--border-strong); }
.tr-heatmap-cell--1 { opacity: 0.35; }
.tr-heatmap-cell--2 { opacity: 0.55; }
.tr-heatmap-cell--3 { opacity: 0.78; }
.tr-heatmap-cell--4 { opacity: 1; }

/* ── Mine tab: feedback received ── */

.tr-feedback-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tr-feedback-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
}

.tr-feedback-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tr-feedback-coach {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.tr-feedback-type-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}

.tr-feedback-type-pill--personal {
  background: #dbeafe;
  color: #1e40af;
}

[data-theme="dark"] .tr-feedback-type-pill--personal { background: rgba(59,130,246,0.18); color: #93c5fd; }

.tr-feedback-type-pill--crew {
  background: #dcfce7;
  color: #166534;
}

[data-theme="dark"] .tr-feedback-type-pill--crew { background: rgba(22,163,74,0.18); color: #86efac; }

.tr-feedback-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 6px;
  white-space: pre-wrap;
}

.tr-feedback-session {
  font-size: 12px;
  color: var(--text-tertiary);
}

