/* cardio feature styles. OWNER: cardio workstream. */
#cardioRoot { --cd-strength: var(--tile-blue); --cd-strength-soft: #dbeafe; --cd-missed: var(--danger); }
:root[data-theme="dark"] #cardioRoot, :root[data-theme="dark"] .cd-modal { --cd-strength-soft: rgba(37, 99, 235, 0.22); }
#cardioRoot .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
#cardioRoot .dot.cardio, #cardioRoot .dot.z2 { background: var(--accent); }
#cardioRoot .dot.strength { background: var(--cd-strength); }
#cardioRoot .dot.all { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--acc-300); }
.cd-loading { text-align: center; padding: 40px; }
.cd-sub { font-size: 14px; font-weight: 700; margin: 20px 0 4px; }
.cd-footnote { margin: 14px 0 0; line-height: 1.5; }

/* hero */
.cd-hero { display: grid; grid-template-columns: 1fr; gap: 0 18px; margin-bottom: 18px; }
@media (min-width: 900px) { .cd-hero { grid-template-columns: 1.1fr 1fr; } .cd-hero .panel { margin-bottom: 0; } }
.cd-hero-main { display: flex; align-items: center; gap: 24px; }
.cd-hero-ring .dr { width: 156px; }
.cd-hero-ring .dr-in b { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; }
.cd-hero-ring .dr-in span { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.cd-hero-keys { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cd-hero-keys span { display: inline-flex; align-items: center; gap: 6px; }
.cd-hero-keys i { width: 8px; height: 8px; border-radius: 50%; }
.cd-hero-keys i.z2 { background: #0ea5e9; }
.cd-hero-keys i.last { background: var(--panel); border: 1.6px solid #9ca3af; box-sizing: border-box; }
.cd-tiles .stat-label { width: 100%; }
.cd-delta { margin-left: auto; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.2); color: #fff; white-space: nowrap; }
.cd-spark-tile { width: 100%; height: 26px; display: block; margin-top: 6px; position: relative; z-index: 1; overflow: visible; }
.cd-spark-tile .l { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.cd-spark-tile .a { fill: rgba(255, 255, 255, 0.12); }
.cd-spark-tile circle { fill: #fff; stroke: rgba(255, 255, 255, 0.35); stroke-width: 3; }
.cd-dots { display: flex; gap: 5px; margin-top: 8px; position: relative; z-index: 1; }
.cd-dots i { width: 13px; height: 13px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.5); box-sizing: border-box; }
.cd-dots i.on { background: var(--accent); border: 0; box-shadow: 0 0 0 2px rgba(var(--acc-500-rgb), 0.3); }
.cd-tile-note { font-size: 11.5px; font-weight: 600; color: rgba(255, 255, 255, 0.75); margin-top: 6px; position: relative; z-index: 1; }
.cd-hero-text { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.cd-hero-value { font-size: 44px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.cd-hero-sub { font-size: 14px; font-weight: 500; }
.cd-type-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cd-type-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); padding: 5px 10px; border-radius: 999px; }
.cd-type-chip b { color: var(--text); }
.cd-type-chip .ico { width: 14px; height: 14px; }
.cd-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cd-tiles .stat-card { min-height: 112px; margin: 0; }
.cd-tiles .stat-value { font-size: 30px; letter-spacing: -0.03em; line-height: 1.1; }
.cd-tiles .stat-unit { font-size: 13px; }

.cd-two { display: grid; grid-template-columns: 1fr; gap: 0 18px; align-items: start; }
@media (min-width: 900px) { .cd-two { grid-template-columns: 1fr 1fr; } }
.cd-two > .panel { margin-bottom: 18px; min-width: 0; }

/* weekly plan */
.cd-plan-days { display: flex; flex-direction: column; margin-top: 14px; }
.cd-plan-day { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); }
.cd-plan-day:first-child { border-top: none; }
.cd-plan-dayname { font-size: 13px; font-weight: 700; color: var(--muted); }
.cd-plan-items { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.cd-session { display: inline-flex; align-items: center; gap: 6px; border: none; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--text); background: var(--accent-soft); padding: 7px 12px 7px 9px; border-radius: 999px; cursor: pointer; max-width: 100%; }
.cd-session span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-session b { font-weight: 700; color: var(--accent-dark); }
.cd-session .ico { width: 15px; height: 15px; flex-shrink: 0; }
.cd-session:hover { filter: brightness(0.96); }
.cd-session.k-tempo, .cd-session.k-intervals { background: #fef3c7; }
.cd-session.k-tempo b, .cd-session.k-intervals b { color: #b45309; }
.cd-session.k-long { background: #e0e7ff; }
.cd-session.k-long b { color: #4338ca; }
:root[data-theme="dark"] .cd-session.k-tempo, :root[data-theme="dark"] .cd-session.k-intervals { background: rgba(245, 158, 11, 0.18); }
:root[data-theme="dark"] .cd-session.k-tempo b, :root[data-theme="dark"] .cd-session.k-intervals b { color: #fbbf24; }
:root[data-theme="dark"] .cd-session.k-long { background: rgba(99, 102, 241, 0.2); }
:root[data-theme="dark"] .cd-session.k-long b { color: #a5b4fc; }
:root[data-theme="dark"] .cd-session b { color: var(--accent); }
.cd-add-mini { width: 30px; height: 30px; border-radius: 50%; border: 1.5px dashed var(--border); background: transparent; color: var(--muted); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; line-height: 1; }
.cd-add-mini:hover { border-color: var(--accent); color: var(--accent-dark); }
.cd-modal .chip { font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.cd-modal select { width: 100%; }
.cd-error { color: var(--danger) !important; margin: 0 0 10px; }

/* Zone 2 */
.cd-zone-range { font-size: 46px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.cd-zone-range span { color: var(--muted); margin: 0 2px; }
.cd-zone-range small { font-size: 16px; font-weight: 700; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.cd-zone-src { margin: 8px 0 12px; line-height: 1.5; }
.cd-zone-form { background: var(--panel-2); border-radius: 20px; padding: 12px 16px; }
.cd-zone-form summary { cursor: pointer; font-size: 13px; font-weight: 700; list-style: none; }
.cd-zone-form summary::-webkit-details-marker { display: none; }
.cd-zone-form summary::before { content: '▸ '; color: var(--muted); }
.cd-zone-form[open] summary::before { content: '▾ '; }
.cd-zone-form form { margin-top: 12px; }
.cd-zone-form p { margin: 0 0 10px; }
.cd-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; }
.cd-form-grid .field { margin-bottom: 10px; font-size: 12px; }
.cd-form-grid input { width: 100%; min-width: 0; }
.cd-recent { display: flex; flex-direction: column; }
.cd-recent-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.cd-recent-row:first-child { border-top: none; }
.cd-recent-row .icon-tile { width: 38px; height: 38px; border-radius: 13px; margin: 0; flex-shrink: 0; }
.cd-recent-row .icon-tile .ico { width: 18px; height: 18px; }
.cd-recent-main { flex: 1; min-width: 0; }
.cd-recent-title { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-recent-hr { display: flex; flex-direction: column; align-items: flex-end; min-width: 52px; }
.cd-recent-hr b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cd-recent-hr span { font-size: 10.5px; color: var(--muted); }
.cd-recent-hr .cd-nohr { font-size: 11px; font-weight: 700; background: var(--badge-bg); padding: 3px 8px; border-radius: 999px; }
.cd-z2-badge { font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 8px; padding: 4px 6px; min-width: 28px; text-align: center; }
.cd-z2-badge.off { background: transparent; }

/* calendar */
.cd-ics .ico { width: 15px; height: 15px; }
.cd-cal-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 10px; }
.cd-cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: center; margin-bottom: 6px; }
.cd-cal-weeklabel { display: none; }
.cd-cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
.cd-cal-day { background: var(--panel-2); border-radius: 16px; padding: 8px; min-height: 96px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cd-cal-day.is-today { box-shadow: inset 0 0 0 2px var(--accent); background: var(--panel); }
.cd-cal-day.is-past { opacity: 0.92; }
.cd-cal-date { display: flex; align-items: baseline; gap: 6px; }
.cd-cal-date b { font-size: 15px; font-weight: 700; }
.cd-cal-dow { display: none; font-size: 12px; font-weight: 700; color: var(--muted); }
.cd-cal-day.is-today .cd-cal-date b { color: var(--accent-dark); }
.cd-cal-items { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cd-cal-rest { font-size: 11px; color: var(--muted); display: none; }
.cd-cal-item { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 4px 6px; border-radius: 8px; min-width: 0; background: var(--panel); color: var(--text); border-left: 3px solid var(--accent); }
.cd-cal-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-cal-item i { font-style: normal; font-weight: 700; flex-shrink: 0; }
.cd-cal-item.strength { border-left-color: var(--cd-strength); }
.cd-cal-item.is-done.cardio { background: var(--accent); color: #fff; border-left-color: var(--accent); }
.cd-cal-item.is-done.strength { background: var(--cd-strength); color: #fff; }
.cd-cal-item.extra.cardio { background: var(--accent-soft); color: var(--accent-dark); }
.cd-cal-item.extra.strength { background: var(--cd-strength-soft); color: var(--cd-strength); }
:root[data-theme="dark"] .cd-cal-item.extra.cardio { color: var(--accent); }
:root[data-theme="dark"] .cd-cal-item.extra.strength { color: #93c5fd; }
.cd-cal-item.is-missed { color: var(--muted); background: transparent; border-left-color: var(--cd-missed); }
.cd-cal-item.is-missed span { text-decoration: line-through; }
.cd-cal-item.is-missed i { color: var(--cd-missed); }
.cd-cal-item.is-today { box-shadow: inset 0 0 0 1px var(--accent); }

/* progression chart */
.cd-legend { display: flex; gap: 14px; color: var(--muted); font-weight: 600; }
.cd-chart { position: relative; height: 170px; margin: 18px 0 8px 34px; }
.cd-chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; }
.cd-chart-tick { border-top: 1px dotted var(--border); height: 0; position: relative; }
.cd-chart-tick:last-child { border-top: 1px solid var(--border); }
.cd-chart-tick span { position: absolute; left: -34px; top: -8px; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cd-chart-target { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--text); opacity: 0.35; z-index: 1; pointer-events: none; }
.cd-chart-target span { position: absolute; right: 0; top: -18px; font-size: 10.5px; font-weight: 700; }
.cd-chart-bars { position: relative; height: 100%; display: grid; align-items: end; gap: 6px; }
.cd-chart-col { height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.cd-chart-bar { width: 100%; max-width: 34px; background: var(--accent-soft); border-radius: 10px 10px 6px 6px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.cd-chart-z2 { background: var(--accent); width: 100%; }
.cd-chart-col.is-current .cd-chart-bar { box-shadow: inset 0 0 0 2px var(--accent), 0 4px 10px rgba(var(--acc-500-rgb), 0.25); }
.cd-chart-bar { position: relative; overflow: visible; }
.cd-chart-z2 { border-radius: 4px 4px 6px 6px; }
.cd-chart-best { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 700; color: var(--accent-dark); white-space: nowrap; }
.cd-chart-avg { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--muted); opacity: 0.6; z-index: 1; pointer-events: none; }
.cd-chart-avg span { position: absolute; left: 0; top: -17px; font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--panel); padding: 0 4px; border-radius: 4px; }
.cd-chart-labels span.is-current { color: var(--text); font-weight: 700; }
.cd-chart-labels { display: grid; gap: 6px; margin: 0 0 6px 34px; }
.cd-chart-labels span { font-size: 10.5px; color: var(--muted); font-weight: 600; text-align: center; white-space: nowrap; }
.cd-next { display: flex; align-items: center; gap: 16px; background: var(--panel-2); border-radius: 20px; padding: 14px 16px; margin: 16px 0; }
.cd-next-num { display: flex; flex-direction: column; align-items: center; min-width: 76px; }
.cd-next-num b { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.cd-next-num span { font-size: 11px; color: var(--muted); text-align: center; }
.cd-next-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.cd-eff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.cd-eff { border: 1px solid var(--border); border-radius: 20px; padding: 14px; min-width: 0; }
.cd-eff-head { display: flex; gap: 10px; align-items: center; }
.cd-eff-head .icon-tile { width: 36px; height: 36px; border-radius: 12px; margin: 0; }
.cd-eff-head .icon-tile .ico { width: 18px; height: 18px; }
.cd-eff-title { font-weight: 700; font-size: 14px; }
.cd-eff-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 10px; }
.cd-eff-value span { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: 0; }
.cd-spark { width: 100%; height: 54px; display: block; margin: 6px 0; }
.cd-spark path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.cd-spark path.cd-spark-dot { stroke-width: 7; } /* a round dot that the stretched SVG can't squash */
.cd-eff-trend { font-size: 12px; font-weight: 700; color: var(--muted); }
.cd-eff-trend.up { color: var(--accent-dark); }
.cd-eff-trend.down { color: var(--danger); }
:root[data-theme="dark"] .cd-eff-trend.up { color: var(--accent); }

/* dark mode: keep dark tiles and soft bars visible on the dark page */
:root[data-theme="dark"] .cd-tiles .tile-dark, :root[data-theme="dark"] .cd-eff .icon-tile.dark { background: #2a2e34; }
:root[data-theme="dark"] .cd-chart-bar { background: rgba(var(--acc-500-rgb), 0.26); }

/* phone */
@media (max-width: 600px) {
  .cd-hero-main { gap: 16px; }
  .cd-hero-ring .dr { width: 124px; }
  .cd-hero-ring .dr-in b { font-size: 26px; }
  .cd-hero-value { font-size: 32px; }
  .cd-tiles .stat-card { min-height: 96px; }
  .cd-tiles .stat-value { font-size: 24px; }
  .cd-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cd-zone-range { font-size: 38px; }
  /* calendar becomes one compact row per day, grouped by week */
  .cd-cal-head { display: none; }
  .cd-cal-weekwrap { margin-bottom: 12px; }
  .cd-cal-weeklabel { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 4px 2px 6px; text-transform: uppercase; letter-spacing: 0.04em; }
  .cd-cal-week { display: flex; flex-direction: column; gap: 4px; }
  .cd-cal-day { min-height: 0; flex-direction: row; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 14px; }
  .cd-cal-date { width: 56px; flex-shrink: 0; }
  .cd-cal-dow { display: inline; }
  .cd-cal-items { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .cd-cal-rest { display: inline; }
  .cd-cal-day.is-empty { padding-top: 4px; padding-bottom: 4px; background: transparent; }
  .cd-chart { height: 140px; }
  .cd-chart-bars, .cd-chart-labels { gap: 3px; }
  .cd-next { flex-direction: column; align-items: flex-start; gap: 8px; }
  .cd-next-num { flex-direction: row; align-items: baseline; gap: 6px; }
}

/* Pace or speed at the same heart rate */
.cd-same { display: flex; flex-direction: column; gap: 1px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line, rgba(0, 0, 0, .06)); }
.cd-same b { font-size: 14px; font-weight: 700; }
.cd-same-arr { color: var(--accent); }
/* Garmin's five heart rate zones under the Zone 2 bar. */
.cd-zc-zones { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 10px; }
.cd-zc-zones span { display: grid; text-align: center; font-size: 11px; color: var(--muted); padding: 5px 2px; border-radius: 8px; background: var(--panel-2, rgba(0,0,0,.04)); font-variant-numeric: tabular-nums; }
.cd-zc-zones b { font-size: 11.5px; color: var(--text); }
.cd-zc-zones span.on { background: var(--accent-soft); color: var(--accent-dark); }
.cd-zc-zones span.on b { color: var(--accent-dark); }
