/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #222;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --sub: #888;
  --accent: #f5a623;
  --accent2: #e8533f;
  --strava: #fc4c02;
  --green: #59cd90;
  --blue: #70b8ff;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Nav ---- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.3px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.unit-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.unit-btn {
  background: transparent;
  border: none;
  color: var(--sub);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.03em;
}

.unit-btn:hover {
  background: var(--surface2);
  color: var(--fg);
}

.unit-btn--active {
  background: var(--accent);
  color: #fff;
}

.nav-athlete {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sub);
  font-size: 13px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ---- Container ---- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #000; }
.btn-ghost    { background: transparent; color: var(--sub); border: 1px solid var(--border); }
.btn-strava   { background: var(--strava); color: #fff; font-size: 15px; padding: 12px 24px; }

/* ---- Login ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.login-sub { color: var(--sub); margin-bottom: 24px; }

.login-features {
  list-style: none;
  text-align: left;
  margin: 0 auto 28px;
  max-width: 280px;
}
.login-features li {
  padding: 5px 0;
  color: var(--sub);
  font-size: 13px;
}
.login-features li::before { content: "✓  "; color: var(--green); }

.login-note  { margin-top: 16px; font-size: 11px; color: var(--sub); }
.login-error {
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #2a0a0a;
  border: 1px solid #7f1d1d;
  border-radius: var(--radius);
  color: #fca5a5;
  font-size: 13px;
  line-height: 1.5;
}

/* ---- Dashboard ---- */
/* ---- Home page ---- */

/* Hero banner */
.home-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(120deg, rgba(245,166,35,.12) 0%, var(--surface) 55%);
  border: 1px solid rgba(245,166,35,.22);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 16px;
}
.home-banner-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(245,166,35,.4);
  flex-shrink: 0;
}
.home-banner-body { flex: 1; min-width: 0; }
.home-banner-name {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-banner-sub {
  color: var(--sub);
  font-size: 13px;
  margin-top: 4px;
}
.home-banner-week {
  text-align: right;
  flex-shrink: 0;
}
.home-banner-week-num {
  display: block;
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.home-banner-week-label {
  display: block;
  font-size: 11px;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 4px;
}

/* Stat strip label */
.home-stat-strip-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  margin-top: 16px;
}

/* Stat strip */
.home-stat-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 4px;
}
.home-stat-strip--ytd { border-color: rgba(245,166,35,.25); }
.home-stat-item {
  padding: 16px 20px;
  border-right: 1px solid var(--border);
}
.home-stat-item:last-child { border-right: none; }
.home-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}
.home-stat-label {
  font-size: 11px;
  color: var(--sub);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Lower two-column layout */
.home-lower {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.home-lower-card {
  display: flex;
  flex-direction: column;
}
.home-card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
}
.home-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.home-card-title-row .home-card-title { margin-bottom: 0; }
.home-card-link {
  font-size: 12px;
  color: var(--accent);
}
.home-card-empty {
  color: var(--sub);
  font-size: 13px;
}

/* PMC numbers strip */
.pmc-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}
.pmc-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
  text-align: center;
  position: relative;
  cursor: default;
}
.pmc-item:last-child { border-right: none; }
.pmc-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #f0f0f0;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 6px;
  width: 240px;
  white-space: normal;
  text-align: left;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.pmc-item[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #333;
  z-index: 200;
  pointer-events: none;
}
.pmc-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  position: relative;
}
.pmc-sign {
  font-size: 13px;
  font-weight: 400;
  vertical-align: super;
  line-height: 0;
}
.pmc-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 4px;
}
.pmc-desc {
  font-size: 9px;
  color: var(--sub);
  opacity: 0.6;
  margin-top: 2px;
  white-space: nowrap;
}
.pmc-tsb--fresh  { color: var(--green); }
.pmc-tsb--tired  { color: var(--accent2); }
.pmc-tsb--neutral{ color: var(--text); }

.pmc-chart-wrap {
  margin-top: 14px;
}
.pmc-chart-controls {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.pmc-period-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--sub);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.pmc-period-btn:hover { border-color: var(--accent); color: var(--accent); }
.pmc-period-btn.active { border-color: var(--accent); color: var(--accent); }

/* Insights list inside the card */
.home-insights-list { display: flex; flex-direction: column; gap: 10px; }
.home-insight-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
}
.home-insight-row.insight-chip--positive  { background: rgba(89,205,144,.1);  border: 1px solid rgba(89,205,144,.2); }
.home-insight-row.insight-chip--warning   { background: rgba(232,83,63,.1);   border: 1px solid rgba(232,83,63,.2); }
.home-insight-row.insight-chip--suggestion{ background: rgba(112,184,255,.1); border: 1px solid rgba(112,184,255,.2); }
.home-insight-row.insight-chip--neutral   { background: var(--surface2);      border: 1px solid var(--border); }
.home-insight-icon { font-size: 16px; flex-shrink: 0; line-height: 1.45; }
.home-insight-text { flex: 1; }

/* Profile inside card */
.home-profile-identity {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.home-profile-archetype {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.home-profile-level { font-size: 13px; color: var(--text); }
.home-profile-score { color: var(--sub); font-size: 12px; }
.home-profile-desc {
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 16px;
  line-height: 1.5;
}
.home-profile-bars { display: flex; flex-direction: column; gap: 8px; }
.home-bar-row {
  display: grid;
  grid-template-columns: 40px 1fr 90px;
  align-items: center;
  gap: 10px;
}
.home-bar-label { font-size: 11px; color: var(--sub); text-align: right; }
.home-bar-track {
  background: var(--surface2);
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
}
.home-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.home-bar-value { font-size: 11px; color: var(--sub); white-space: nowrap; }
.home-profile-note { font-size: 11px; color: var(--sub); margin-top: 14px; }

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.dashboard-header h2 { font-size: 22px; font-weight: 700; }

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sub { color: var(--sub); font-size: 13px; margin-top: 2px; }

.empty-state {
  padding: 60px;
  text-align: center;
  color: var(--sub);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.filter-search-icon {
  position: absolute;
  left: 10px;
  color: var(--sub);
  pointer-events: none;
}

.filter-input {
  width: 100%;
  padding: 7px 32px 7px 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.filter-input:focus { border-color: var(--accent); }
.filter-input::placeholder { color: var(--sub); }

.filter-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--sub);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  line-height: 1;
}
.filter-clear:hover { color: var(--text); }

.filter-dates {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 12px;
  color: var(--sub);
  white-space: nowrap;
}

.filter-date {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.filter-date:focus { border-color: var(--accent); }

.filter-reset {
  font-size: 12px;
  padding: 5px 10px;
}

/* ---- Activity table ---- */
.activity-table-wrap { overflow-x: auto; }

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.activity-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--sub);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.activity-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.activity-row { cursor: pointer; transition: background 0.1s; }
.activity-row:hover { background: var(--surface2); }

.activity-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.activity-table .date { color: var(--sub); font-size: 12px; }
.activity-table .name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.sport-badge { margin-right: 4px; }

.hard { color: var(--accent2); font-weight: 600; }
.mod  { color: var(--accent); }

.btn-load-peaks {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}
.btn-load-peaks:hover { background: var(--border); }

/* ---- Sync banner ---- */
.sync-banner {
  margin-top: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--sub);
  font-size: 13px;
}
.hidden { display: none; }

/* ---- Activity detail ---- */
.activity-header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.activity-header-left { flex: 1; min-width: 0; }
.activity-header h2 { font-size: 22px; font-weight: 700; margin: 6px 0 4px; }
.back-link { color: var(--sub); font-size: 13px; }
.back-link:hover { color: var(--text); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.metric-card.highlight { border-color: var(--accent); }
.metric-card.metric-hard { border-color: var(--accent2); }
.metric-card.metric-mod  { border-color: var(--accent); }

.metric-label { font-size: 11px; color: var(--sub); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.metric-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 2px; }

.chart-wrap {
  position: relative;
  height: 300px;
  margin-top: 16px;
}

/* ---- Peaks table ---- */
.peaks-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}
.peaks-table th {
  text-align: left;
  padding: 6px 10px;
  color: var(--sub);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.peaks-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.peaks-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.zone-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}

/* ---- Load prompt ---- */
.load-prompt {
  padding: 40px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.load-prompt p { color: var(--sub); margin-bottom: 14px; }

/* ---- Strava link ---- */
.strava-link {
  text-align: right;
  margin-top: 8px;
  font-size: 12px;
}
.strava-link a { color: var(--strava); }

/* ---- Nav links ---- */
.nav-links {
  display: flex;
  gap: 4px;
  margin-left: 24px;
}
.nav-link {
  padding: 5px 12px;
  border-radius: var(--radius);
  color: var(--sub);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); text-decoration: none; }

/* ---- PR Table ---- */
.pr-card { padding: 0; overflow: hidden; }

.pr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.pr-table th {
  text-align: left;
  padding: 12px 20px;
  color: var(--sub);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}
.pr-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.pr-table th.sortable:hover { color: var(--text); }
.pr-table th.sort-active { color: var(--accent); }
.sort-icon { font-style: normal; }
.pr-table th.num { text-align: right; }

.pr-row td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.pr-row:last-child td { border-bottom: none; }
.pr-row--linked { cursor: pointer; transition: background 0.1s; }
.pr-row--linked:hover { background: var(--surface2); }

.pr-duration {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  width: 90px;
}
.pr-watts {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.pr-pct { font-variant-numeric: tabular-nums; }
.pr-activity-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pr-activity-name a { color: var(--text); text-decoration: none; }
.pr-activity-name a:hover { color: var(--accent); }
.pr-date { color: var(--sub); font-size: 12px; white-space: nowrap; }
.pr-empty { color: var(--sub); font-size: 12px; }
.num { text-align: right; }

.pr-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--sub);
}
.pr-hint a { color: var(--accent); }

/* ---- Zones page ---- */
.zones-card { padding: 0; overflow: hidden; }

.zones-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.zones-table th {
  text-align: left;
  padding: 11px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sub);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.zones-table th.num { text-align: right; }
.zones-bar-head { width: 220px; }

.zones-row td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.zones-row:last-child td { border-bottom: none; }

.zone-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}
.zones-pct  { text-align: right; color: var(--sub); font-size: 13px; white-space: nowrap; }
.zones-watts { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.zones-wpkg { text-align: right; font-variant-numeric: tabular-nums; color: var(--sub); white-space: nowrap; }

.zones-bar-cell { padding-right: 24px; }
.zones-bar-track {
  position: relative;
  height: 10px;
  background: var(--surface2);
  border-radius: 5px;
  overflow: hidden;
  width: 200px;
}
.zones-bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 5px;
  opacity: 0.85;
}

.zones-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--sub);
}
.zones-note a { color: var(--accent); }

/* ---- Config page ---- */
.config-card { max-width: 860px; }
.config-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 40px;
}

.config-section { padding: 4px 0 8px; }
.config-section h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--sub); margin-bottom: 16px; }

.config-field { margin-bottom: 8px; }
.config-field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.config-hint { font-size: 12px; color: var(--sub); margin-bottom: 10px; }

.config-input-row { display: flex; align-items: center; gap: 8px; }
.config-input {
  width: 140px;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s;
}
.config-input:focus { border-color: var(--accent); }
.config-unit { color: var(--sub); font-size: 13px; }
.config-derived { margin-top: 8px; font-size: 12px; color: var(--sub); }
.config-derived strong { color: var(--accent); }

.config-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.config-actions { display: flex; gap: 10px; margin-top: 24px; }

.btn-danger { background: #7f1d1d; color: #fca5a5; border: 1px solid #991b1b; }
.btn-danger:hover { background: #991b1b; }

/* ---- Edit power panel ---- */
.edit-power-wrap { margin-top: 28px; }

.edit-power-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--sub);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.edit-power-toggle:hover { color: var(--text); border-color: var(--accent); }

.edit-power-panel {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.edit-name-field {
  margin-bottom: 16px;
}
.edit-name-field label {
  display: block;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.edit-name-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.edit-name-input:focus { border-color: var(--accent); }

.edit-power-fields {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.edit-field label {
  display: block;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.edit-power-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.save-banner {
  background: #1a3a1a;
  border: 1px solid #2d6b2d;
  color: var(--green);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 20px;
  max-width: 520px;
}

/* ---- PR Table — expand / top-20 detail ---- */
.pr-expand-th {
  width: 36px;
}

.pr-expand-cell {
  width: 36px;
  text-align: center;
  padding: 0 4px !important;
}

.pr-expand-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--sub);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
  line-height: 1.4;
  transition: border-color 0.15s, color 0.15s;
}
.pr-expand-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pr-detail-row > td {
  padding: 0 !important;
  background: var(--bg);
  cursor: default;
}

.pr-detail-cell {
  padding: 14px 20px 18px 20px !important;
  border-bottom: 2px solid var(--border);
}

.pr-detail-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
}

.pr-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pr-mini-table thead th {
  color: var(--sub);
  font-weight: 500;
  text-align: left;
  padding: 4px 10px 6px;
  border-bottom: 1px solid var(--border);
}
.pr-mini-table thead th.num { text-align: right; }

.pr-mini-row { cursor: pointer; }
.pr-mini-row:hover td { background: var(--surface2); }
.pr-mini-row td {
  padding: 6px 10px;
  border-bottom: 1px solid #1c1c1c;
  color: var(--text);
}
.pr-mini-row td.num { text-align: right; }
.pr-mini-row a { color: var(--text); text-decoration: none; }
.pr-mini-row a:hover { color: var(--accent); text-decoration: underline; }
.pr-mini-row:last-child td { border-bottom: none; }

/* ============================================================
   Training Load — heatmap calendar
   ============================================================ */
.cal-scroll { overflow-x: auto; padding-bottom: 4px; }

.cal-outer {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
}

/* Mon–Sun labels on the left */
.cal-dow-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 22px;   /* align with grid rows after month-label row */
}
.cal-dow-labels span {
  height: 16px;
  line-height: 16px;
  font-size: 10px;
  color: var(--sub);
  text-align: right;
  padding-right: 6px;
  white-space: nowrap;
}

.cal-right { display: flex; flex-direction: column; }

/* Month label row */
.cal-month-label {
  font-size: 11px;
  color: var(--sub);
  white-space: nowrap;
}

.cal-day-num {
  font-size: 9px;
  color: var(--sub);
  opacity: 0.55;
  width: 16px;
  text-align: center;
  display: inline-block;
  line-height: 1;
}

/* Week columns */
.cal-grid { display: flex; gap: 2px; }
.cal-week { display: flex; flex-direction: column; gap: 2px; }

/* Individual cells */
.cal-cell {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cal-future  { background: transparent; border: 1px solid #222; }
.cal-clickable { cursor: pointer; }
.cal-multi { cursor: pointer; }
.cal-cell:hover { opacity: 0.8; outline: 1px solid var(--accent); }

/* TSS intensity levels */
.tss-0 { background: var(--surface2); }
.tss-1 { background: #1d5c35; }
.tss-2 { background: #27a24f; }
.tss-3 { background: #c07600; }
.tss-4 { background: #b83030; }

/* Legend (inline with h3) */
.cal-legend-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 14px;
  font-size: 12px;
  font-weight: 400;
  color: var(--sub);
  vertical-align: middle;
}
.cal-leg-cell {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}
.cal-leg-label { font-size: 11px; color: var(--sub); margin-right: 4px; }

/* Hover tooltip */
.cal-tooltip {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}

/* ============================================================
   Training Load — weekly summary table
   ============================================================ */
.weekly-table-wrap { overflow-x: auto; }

.weekly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.weekly-table thead th {
  color: var(--sub);
  font-weight: 500;
  text-align: left;
  padding: 6px 12px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.weekly-table thead th.num { text-align: right; }
.weekly-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid #1e1e1e;
  color: var(--text);
}
.weekly-table tbody td.num { text-align: right; }
.weekly-row--current td { background: #1e1a12; }

.weekly-week-cell { white-space: nowrap; }
.weekly-current-badge {
  margin-left: 8px;
  font-size: 11px;
  background: #3a2800;
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 10px;
}

.weekly-tss-col { min-width: 160px; }
.weekly-tss-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.weekly-tss-bar-track {
  width: 80px;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.weekly-tss-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.weekly-tss-val { min-width: 32px; text-align: right; }

/* ============================================================
   Settings — FTP suggestions
   ============================================================ */
.ftp-suggestions {
  margin-top: 16px;
  background: #151f15;
  border: 1px solid #2a3d2a;
  border-radius: var(--radius);
  padding: 14px 16px;
}
.ftp-suggest-heading {
  font-size: 13px;
  color: var(--sub);
  margin-bottom: 12px;
}
.ftp-suggest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid #1e2e1e;
}
.ftp-suggest-row:last-child { border-bottom: none; }
.ftp-suggest-info { display: flex; flex-direction: column; gap: 2px; }
.ftp-suggest-label { font-size: 14px; font-weight: 500; color: var(--text); }
.ftp-suggest-source { font-size: 12px; color: var(--sub); }
.ftp-suggest-action {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ftp-delta { font-size: 13px; font-weight: 600; }
.ftp-delta--up   { color: var(--green); }
.ftp-delta--down { color: var(--accent2); }

.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
}

/* ============================================================
   Training Load — period tabs
   ============================================================ */
.tl-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.tl-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sub);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.tl-tab:hover { color: var(--text); }
.tl-tab--active { color: var(--accent); border-bottom-color: var(--accent); }

.tl-view { padding-top: 4px; }

/* ============================================================
   Training Load — calendar header (range buttons + legend)
   ============================================================ */
.cal-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.cal-header h3 { margin: 0; font-size: 15px; font-weight: 700; }

/* 1M / 3M / 6M / 12M pill buttons */
.cal-range-bar {
  display: flex;
  gap: 4px;
}
.cal-range-btn {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.cal-range-btn:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.cal-range-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* Push legend to the right on wide screens */
.cal-header .cal-legend-wrap { margin-left: auto; }

/* ============================================================
   Training Load — picking hint
   ============================================================ */
.cal-pick-hint {
  font-size: 12px;
  color: var(--accent);
  padding: 6px 0 4px;
  font-style: italic;
}

/* ============================================================
   Training Load — range summary banner
   ============================================================ */
.cal-range-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 14px;
  background: #1e1800;
  border: 1px solid #3a2e00;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
}
.range-dates {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.range-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text);
}
.range-stats span { white-space: nowrap; }
.range-clear-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--sub);
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.range-clear-btn:hover { color: var(--text); border-color: var(--text); }

/* ============================================================
   Training Load — calendar cell selection states
   ============================================================ */

/* While picking, show pointer on all cells */
.cal-picking .cal-cell:not(.cal-future) { cursor: crosshair; }

/* Hover preview while picking (cells between start and cursor) */
.cal-cell.cal-preview {
  background: rgba(245, 166, 35, 0.25) !important;
}

/* Selected start / end anchors */
.cal-cell.cal-sel-s,
.cal-cell.cal-sel-e {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: var(--accent) !important;
  border-radius: 3px;
}

/* Cells between start and end */
.cal-cell.cal-in-range {
  background: rgba(245, 166, 35, 0.35) !important;
  border-radius: 0;
}

/* ============================================================
   Training Load — weekly table: dimmed rows outside selection
   ============================================================ */
#weeklyTbody tr.week-out {
  opacity: 0.2;
}

/* ============================================================
   Insights panel (dashboard)
   ============================================================ */
.insights-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.insight-chip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  flex: 1 1 280px;
  max-width: 520px;
}
.insight-chip--positive  { border-color: #2d6b2d; background: #0f1f0f; }
.insight-chip--warning   { border-color: #7f3d00; background: #1e0e00; }
.insight-chip--suggestion{ border-color: #1a3a5c; background: #0a1520; }
.insight-chip--neutral   { border-color: var(--border); background: var(--surface); }

.insight-icon { font-size: 16px; flex-shrink: 0; line-height: 1.4; }
.insight-text { color: var(--text); line-height: 1.5; }

/* ============================================================
   Power Profile card (peaks page)
   ============================================================ */
.profile-card { margin-bottom: 20px; }

.profile-header {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.profile-identity { flex: 0 0 auto; max-width: 320px; }

.profile-archetype {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}

.profile-level {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.profile-score { color: var(--sub); font-weight: 400; font-size: 13px; }

.profile-desc {
  font-size: 13px;
  color: var(--sub);
  line-height: 1.5;
  margin-bottom: 10px;
}

.profile-no-weight {
  font-size: 12px;
  color: var(--sub);
  font-style: italic;
}
.profile-no-weight a { color: var(--accent); }

/* Bars */
.profile-bars { flex: 1 1 260px; display: flex; flex-direction: column; gap: 10px; }

.profile-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-bar-label {
  font-size: 12px;
  color: var(--sub);
  width: 44px;
  flex-shrink: 0;
  text-align: right;
}

.profile-bar-track {
  flex: 1;
  height: 12px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: hidden;
}

.profile-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
}

.profile-bar-value {
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 120px;
}

.profile-note {
  margin-top: 16px;
  font-size: 11px;
  color: var(--sub);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* ============================================================
   Hamburger nav button (desktop: hidden)
   ============================================================ */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Nav collapse wrapper — desktop: flex row filling remaining space */
.nav-collapse {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
}

/* ============================================================
   Mobile — breakpoint ≤ 768 px
   ============================================================ */
@media (max-width: 768px) {

  /* --- Nav --- */
  .nav {
    flex-wrap: wrap;
    height: auto;
    padding: 0 16px;
  }

  .nav-brand { padding: 14px 0; }

  .nav-hamburger { display: flex; }

  /* Collapse: hidden by default, shown when .open */
  .nav-collapse {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 8px 0 14px;
    border-top: 1px solid var(--border);
    gap: 0;
  }
  .nav-collapse.open { display: flex; }

  .nav-links {
    flex-direction: column;
    width: 100%;
    margin-left: 0;
    gap: 0;
  }
  .nav-link {
    display: block;
    width: 100%;
    padding: 11px 8px;
    border-radius: 6px;
    font-size: 15px;
  }

  .nav-right {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 8px;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
  }
  /* Action buttons in nav fill width on mobile */
  .nav-right .btn { width: 100%; justify-content: center; font-size: 14px; min-height: 42px; }

  .nav-athlete { font-size: 14px; }
  .avatar { width: 32px; height: 32px; }

  /* --- Container --- */
  .container { padding: 20px 14px 60px; }

  /* --- Dashboard page --- */
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 16px;
  }
  .dashboard-actions { margin-top: 4px; }

  /* Filter bar stacks vertically */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .filter-search { max-width: 100%; }
  .filter-dates { flex-wrap: wrap; }

  /* Activity table: hide non-essential columns */
  .col-hide-sm { display: none !important; }

  /* Name cell: full flex on mobile */
  .activity-table .name { max-width: none; }

  /* Sortable headers need a bigger tap target */
  .activity-table th { padding: 10px 8px; font-size: 12px; }
  .activity-table td { padding: 10px 8px; font-size: 12px; }

  /* --- Activity detail page --- */
  .activity-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  /* Edit panel: stack fields */
  .edit-power-fields { flex-direction: column; gap: 12px; }
  .edit-power-actions { flex-direction: column; align-items: stretch; }
  .edit-power-actions .btn { width: 100%; justify-content: center; }

  .metric-value { font-size: 18px; }

  /* Peaks table zone chip hidden on mobile to save space */
  .peaks-table .col-hide-sm,
  .peaks-table th.col-hide-sm { display: none !important; }

  /* --- PR Table --- */
  .pr-table th, .pr-table td { padding: 10px 10px; font-size: 13px; }
  .pr-watts { font-size: 16px; }

  /* --- Zones table --- */
  .zones-table th, .zones-table td { padding: 10px 12px; font-size: 13px; }

  /* --- General buttons — larger touch targets --- */
  .btn { min-height: 40px; }
  .btn-load-peaks { min-height: 34px; padding: 5px 10px; font-size: 12px; }

  /* Login card: less padding */
  .login-card { padding: 32px 20px; }

  /* Config card full width on mobile */
  .config-card { max-width: 100%; }
  .config-two-col { grid-template-columns: 1fr; gap: 0; }

  /* Weekly table scroll */
  .weekly-table-wrap { -webkit-overflow-scrolling: touch; }

  /* Calendar header: stack on mobile */
  .cal-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .cal-header .cal-legend-wrap { margin-left: 0; }

  /* Insights */
  .insight-chip { flex: 1 1 100%; max-width: 100%; }

  /* Power profile */
  .profile-header { flex-direction: column; gap: 20px; }
  .profile-identity { max-width: 100%; }
  .profile-bar-value { min-width: 90px; }

  /* Home page */
  .home-lower { grid-template-columns: 1fr; }
  .home-stat-strip { grid-template-columns: repeat(3, 1fr); }
  .home-stat-item:nth-child(3) { border-right: none; }
  .home-stat-item:nth-child(4),
  .home-stat-item:nth-child(5) { border-top: 1px solid var(--border); }
  .home-banner-week { display: none; }
}

/* ============================================================
   Extra-small — breakpoint ≤ 480 px
   ============================================================ */
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-wrap { height: 220px; }
  .card { padding: 14px 14px; }
  .pr-activity-name { max-width: 120px; }
  .home-banner { padding: 18px 16px; gap: 12px; }
  .home-banner-avatar { width: 48px; height: 48px; }
  .home-banner-name { font-size: 18px; }
  .home-banner-week-num { font-size: 26px; }
  .home-stat-strip { grid-template-columns: repeat(2, 1fr); }
  .home-stat-item:nth-child(2) { border-right: none; }
  .home-stat-item:nth-child(3) { border-right: 1px solid var(--border); border-top: 1px solid var(--border); }
  .home-stat-item:nth-child(4) { border-top: 1px solid var(--border); }
  .home-stat-item:nth-child(5) { border-right: none; border-top: 1px solid var(--border); }
  .home-lower { grid-template-columns: 1fr; }
  .home-stat-value { font-size: 18px; }
}

/* ---- AI Coach ---- */
.coach-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px - 48px);
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 0 0;
}

.coach-header {
  margin-bottom: 20px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}

.chat-message { display: flex; }
.chat-message--user  { justify-content: flex-end; }
.chat-message--assistant { justify-content: flex-start; }

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message--user .chat-bubble {
  background: var(--accent);
  color: #000;
  border-bottom-right-radius: 4px;
}

.chat-message--assistant .chat-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble--thinking {
  color: var(--sub);
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
}

.chat-suggestion {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.chat-suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 0 16px;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 14px;
  resize: none;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s;
}

.chat-input:focus {
  border-color: var(--accent);
}

.chat-send {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #000;
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.chat-send:hover  { opacity: 0.85; }
.chat-send:disabled { opacity: 0.4; cursor: default; }

/* History button */
.chat-history-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.chat-history-btn:hover { color: var(--accent); }

/* History panel */
.coach-history-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}
.coach-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.coach-history-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 2px 4px;
}
.coach-history-close:hover { color: var(--text); }
.coach-history-list {
  max-height: 280px;
  overflow-y: auto;
}
.coach-history-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
}
.coach-history-item:last-child { border-bottom: none; }
.coach-history-item:hover { background: var(--row-hover); }
.coach-history-q {
  display: block;
  font-size: 0.83rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.coach-history-date {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}
.coach-history-empty {
  padding: 16px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Markdown rendering inside chat bubbles */
.chat-md { display: block; }
.chat-md p { margin: 0 0 4px; }
.chat-md p:last-child { margin-bottom: 0; }
.chat-md .chat-md-heading {
  font-weight: 700;
  margin: 8px 0 4px;
  color: inherit;
}
.chat-md .chat-md-heading:first-child { margin-top: 0; }
.chat-md .chat-md-list {
  margin: 4px 0 6px 16px;
  padding: 0;
}
.chat-md .chat-md-list li { margin-bottom: 2px; }
.chat-md code {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.85em;
  font-family: monospace;
}
