:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #666;
  --accent: #fc4c02; /* Strava orange */
  --low: #22c55e;
  --medium: #f59e0b;
  --high: #ef4444;
  --unknown: #6b7280;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.logo { font-weight: 700; color: var(--accent); text-decoration: none; font-size: 16px; }
.nav-links { display: flex; gap: 20px; }
.nav-links a { color: var(--muted); text-decoration: none; }
.nav-links a:hover { color: var(--text); }
.nav-links a.nav-active { color: var(--text); border-bottom: 2px solid var(--accent); padding-bottom: 2px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }

.hero { text-align: center; padding: 80px 24px; }
.hero h1 { font-size: 48px; color: var(--accent); margin-bottom: 12px; }
.hero p { color: var(--muted); margin-bottom: 32px; font-size: 16px; }

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 20px; }

.athlete-header { display: flex; align-items: center; gap: 12px; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; margin-top: 24px; }
section h3:first-child { margin-top: 0; }

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.btn-danger-sm {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
}
.btn-danger-sm:hover { color: var(--high); }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* Athlete grid */
.athlete-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.athlete-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s;
}
.athlete-card:hover { border-color: var(--accent); }
.athlete-card-self { border-color: #3b82f644; }
.badge-you { font-size: 10px; background: #1e3a5f; color: #60a5fa; padding: 1px 5px; border-radius: 3px; font-weight: 600; vertical-align: middle; }
.athlete-card-body { display: flex; flex-direction: column; gap: 4px; }
.metrics { display: flex; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; margin-top: 4px; }

/* Risk */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.badge-low { background: #14532d; color: var(--low); }
.badge-medium { background: #451a03; color: var(--medium); }
.badge-high { background: #450a0a; color: var(--high); }
.badge-unknown { background: var(--border); color: var(--muted); }

.risk-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}
.risk-card.risk-low { border-color: var(--low); }
.risk-card.risk-medium { border-color: var(--medium); }
.risk-card.risk-high { border-color: var(--high); }
.risk-level { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.risk-card.risk-low .risk-level { color: var(--low); }
.risk-card.risk-medium .risk-level { color: var(--medium); }
.risk-card.risk-high .risk-level { color: var(--high); }
.risk-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.risk-metrics div { display: flex; flex-direction: column; }
.risk-metrics label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.risk-metrics value { font-size: 22px; font-weight: 600; }
.risk-metrics small { font-size: 11px; color: var(--muted); margin-top: 2px; }
.alert { background: #450a0a; color: var(--high); border-radius: 4px; padding: 8px 12px; margin-top: 12px; font-size: 13px; }
.pain-flag { color: var(--high); font-size: 12px; }

/* Plan */
.plan-form { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.form-row { display: flex; gap: 8px; }
.form-row input, .form-row select { flex: 1; }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
}
textarea { resize: vertical; }

.plan-list { display: flex; flex-direction: column; gap: 6px; }
.plan-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.plan-item.plan-easy { border-left-color: var(--low); }
.plan-item.plan-tempo { border-left-color: var(--medium); }
.plan-item.plan-interval { border-left-color: var(--accent); }
.plan-item.plan-long { border-left-color: #a855f7; }
.plan-item.plan-race { border-left-color: var(--high); }
.plan-date { font-size: 11px; color: var(--muted); min-width: 70px; }
.plan-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.plan-body span { font-size: 12px; color: var(--muted); }
.plan-body p { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Activities */
.activity-list { display: flex; flex-direction: column; gap: 6px; }
.activity-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  gap: 12px;
}
.act-date { font-size: 11px; color: var(--muted); min-width: 70px; }
.act-body { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.act-body strong { flex-basis: 100%; }
.act-body span { font-size: 12px; color: var(--muted); }
.act-desc { flex-basis: 100%; font-size: 12px; color: var(--muted); font-style: italic; margin-top: 4px; }

/* Comments */
.comments-list { display: flex; flex-direction: column; gap: 8px; }
.comment { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 10px 12px; }
.comment.comment-pain { border-color: var(--high); }
.comment.comment-fatigue { border-color: var(--medium); }
.comment .date { font-size: 11px; color: var(--muted); margin-right: 8px; }
.comment .name { font-size: 12px; color: var(--text); margin-right: 8px; }
.comment p { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 6px; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; }
.tag-pain { background: #450a0a; color: var(--high); }
.tag-fatigue { background: #451a03; color: var(--medium); }
.tag-surface { background: var(--border); color: var(--muted); }

.muted { color: var(--muted); font-size: 13px; }

/* ===== ATHLETE DETAIL HEADER ===== */
.athlete-detail-header { align-items: flex-start; margin-bottom: 20px; }
.avatar-lg { width: 52px; height: 52px; }
.athlete-header-info { display: flex; flex-direction: column; gap: 6px; }
.athlete-meta-row { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-goal { background: #1e3a5f; color: #60a5fa; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.block-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 700; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}
.card-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }

/* ===== THREE-COL READINESS ROW ===== */
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 28px; }
@media (max-width: 900px) { .three-col { grid-template-columns: 1fr; } }

/* ===== RACE CARD ===== */
.race-card-primary { display: flex; flex-direction: column; gap: 6px; }
.race-name { font-size: 18px; font-weight: 700; }
.race-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.race-date { font-size: 13px; color: var(--muted); }
.race-countdown { font-size: 12px; font-weight: 700; color: var(--accent); background: #fc4c0222; padding: 2px 8px; border-radius: 4px; }
.race-passed { color: var(--low); background: #14532d22; }
.race-location { font-size: 12px; color: var(--muted); }
.race-goal-time { font-size: 13px; color: var(--text); }
.badge-dist { background: #1e3a5f; color: #60a5fa; font-size: 11px; padding: 2px 7px; border-radius: 4px; font-weight: 600; }

/* ===== READINESS GAUGE ===== */
.readiness-card { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.readiness-gauge { position: relative; width: 110px; height: 110px; }
.gauge-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.gauge-fill { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dasharray .4s; }
.gauge-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; line-height: 1.2;
}
.gauge-score { font-size: 26px; font-weight: 800; }
.gauge-label { font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.readiness-details { font-size: 11px; color: var(--muted); list-style: none; width: 100%; }
.readiness-details li { padding: 3px 0; border-bottom: 1px solid var(--border); }
.readiness-details li:last-child { border-bottom: none; }
.info-legend { margin-top: 12px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.info-legend-title { font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.info-legend-rows { display: grid; grid-template-columns: 10px 1fr; gap: 3px 6px; align-items: center; font-size: 11px; color: var(--muted); }
.info-legend-sub { font-size: 10px; color: var(--muted); margin-top: 6px; line-height: 1.4; opacity: .7; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ===== RISK SUMMARY COMPACT ===== */
.risk-summary-card { }
.risk-level-big { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.risk-summary-card.risk-low .risk-level-big { color: var(--low); }
.risk-summary-card.risk-medium .risk-level-big { color: var(--medium); }
.risk-summary-card.risk-high .risk-level-big { color: var(--high); }
.risk-summary-card.risk-unknown .risk-level-big { color: var(--muted); }
.risk-metrics-compact { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.risk-metrics-compact div { display: flex; flex-direction: column; }
.risk-metrics-compact label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.risk-metrics-compact value { font-size: 18px; font-weight: 600; }
.risk-metrics-compact small { font-size: 10px; color: var(--muted); }
.risk-metrics-compact .small-val { font-size: 13px; }

/* ===== RACE LIST ===== */
.race-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.race-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.race-item.race-primary { border-left-color: var(--accent); }
.race-item-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.race-item-name { font-weight: 600; font-size: 13px; }
.race-item-date { font-size: 11px; color: var(--muted); }
.race-item-actions { display: flex; align-items: center; gap: 8px; }
.badge-dist-sm { background: var(--border); color: var(--muted); font-size: 10px; padding: 1px 6px; border-radius: 3px; }
.badge-primary-race { background: #fc4c0222; color: var(--accent); font-size: 9px; padding: 2px 6px; border-radius: 3px; font-weight: 700; letter-spacing: .05em; }
.badge-trail { background: #16532722; color: #4ade80; font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; }

/* ===== COLLAPSIBLE ADD FORMS ===== */
.add-form-details { margin-top: 8px; }
.add-form-details summary { cursor: pointer; list-style: none; display: inline-block; }
.add-form-details summary::-webkit-details-marker { display: none; }
.add-form-details .plan-form { margin-top: 10px; }
.btn-secondary-sm {
  font-size: 12px; color: var(--muted); background: none; border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 4px; cursor: pointer;
}
.btn-secondary-sm:hover { color: var(--text); border-color: var(--muted); }
.btn-ghost-sm { font-size: 11px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 0 4px; }
.btn-ghost-sm:hover { color: var(--accent); }
.btn-secondary {
  font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 5px; cursor: pointer; text-decoration: none;
}
.btn-secondary:hover { color: var(--text); border-color: var(--muted); }
.form-check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.form-check input[type=checkbox] { width: auto; }

/* ===== LIMITING FACTORS ===== */
.lf-form { gap: 12px; }
.lf-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.lf-row:last-of-type { border-bottom: none; }
.lf-row.lf-top { background: #fc4c0208; border-radius: 4px; padding: 8px; margin: 0 -8px; border-bottom: none; }
.lf-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lf-name { font-size: 13px; font-weight: 600; }
.lf-desc { font-size: 11px; color: var(--muted); }
.lf-scale { display: flex; align-items: center; gap: 5px; }
.lf-dot { cursor: pointer; }
.lf-dot-visual {
  display: block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent; transition: all .15s;
}
.lf-dot:hover .lf-dot-visual { border-color: var(--muted); }
.lf-dot-active .lf-dot-visual { background: var(--muted); border-color: var(--muted); }
.lf-dot-limiting .lf-dot-visual { background: var(--accent); border-color: var(--accent); }
.lf-val { font-size: 11px; color: var(--muted); min-width: 14px; text-align: right; }

/* ===== CYCLE TIMELINE ===== */
.cycle-timeline {
  position: relative;
  height: 52px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.cycle-bar {
  position: absolute;
  top: 6px;
  height: 28px;
  border: 1px solid;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 6px;
  overflow: hidden;
  min-width: 20px;
}
.cycle-bar-label { font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cycle-timeline-axis {
  position: absolute;
  bottom: 2px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
}

/* ===== CYCLE LIST ===== */
.cycle-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.cycle-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 4px;
  padding: 10px 12px;
}
.cycle-item-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.cycle-item-name { font-weight: 600; font-size: 13px; }
.cycle-item-dates { font-size: 11px; color: var(--muted); }
.cycle-item-desc { font-size: 11px; color: var(--muted); margin-top: 4px; font-style: italic; }

/* ===== BLOCK TEMPLATES GRID ===== */
.block-templates-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 600px) { .block-templates-grid { grid-template-columns: 1fr; } }
.block-template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.block-template-name { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.block-template-split { font-size: 10px; color: var(--muted); margin-bottom: 5px; }
.block-template-sessions { list-style: none; padding: 0; }
.block-template-sessions li { font-size: 10px; color: var(--muted); padding: 1px 0; }
.block-template-sessions li::before { content: '· '; color: var(--border); }

/* Block type colors */
.block-base { border-color: #3b82f6; }
.block-build { border-color: #f59e0b; }
.block-speed { border-color: #a855f7; }
.block-peak { border-color: #fc4c02; }
.block-taper { border-color: #22c55e; }
.block-recovery { border-color: #6b7280; }
