:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #eaf2fa;
  background: #0c121c;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
header { border-bottom: 1px solid #273345; }
.header-inner { max-width: 1160px; margin: auto; padding: 20px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 800; letter-spacing: -.8px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; background: white; }
.brand span { color: #37d7a0; }
.pill { background: #17283a; color: #b9d8ce; border: 1px solid #275348; padding: 7px 12px; border-radius: 30px; font-size: 13px; white-space: nowrap; }
main, footer { max-width: 1160px; margin: auto; padding: 28px; }
h1 { font-size: clamp(26px, 4vw, 36px); letter-spacing: -1px; margin: 4px 0 6px; }
h2 { font-size: 22px; margin: 0 0 12px; }
h3 { font-size: 18px; }
p { color: #aabbd0; overflow-wrap: anywhere; }
nav { display: flex; gap: 8px; margin: 24px 0; }
button, .upload, select, input { font: inherit; color: inherit; }
button, .upload { cursor: pointer; border: 1px solid #36485d; border-radius: 12px; background: #182332; padding: 10px 16px; min-height: 44px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
button.active, button.primary, .upload { background: #126f59; border-color: #21a77e; color: white; }
button:disabled { opacity: .45; cursor: default; }
@media (hover: hover) { button:not(:disabled):hover, .upload:hover { filter: brightness(1.15); } }
:focus-visible { outline: 3px solid #37d7a0; outline-offset: 3px; }
section[hidden], [hidden] { display: none !important; }
.card { background: #141e2c; border: 1px solid #263446; border-radius: 18px; padding: 24px; margin-bottom: 18px; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stats .card { border-top: 3px solid #8fb9ff; }
.stats .card:nth-child(2) { border-top-color: #c59cff; }
.stats .card:nth-child(3) { border-top-color: #f4c665; }
.label { font-size: 14px; color: #aabbd0; }
.value { font-size: 30px; font-weight: 800; margin-top: 8px; overflow-wrap: anywhere; }
.unit { font-size: 14px; color: #aabbd0; }
.muted { color: #aabbd0; }
.error { color: #ff9d9d; }
.success { color: #59e1b0; }
select, input:not([type=checkbox]):not([type=range]):not([type=file]) { background: #182332; border: 1px solid #36485d; border-radius: 9px; padding: 10px; min-height: 44px; min-width: 0; max-width: 100%; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: #37d7a0; flex-shrink: 0; }
input[type=range] { width: 100%; min-height: 44px; accent-color: #37d7a0; cursor: pointer; }
.filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin: 18px 0; }
.filters label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filters label:has(input[type=checkbox]), label:has(> input[type=checkbox]) { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; min-height: 44px; }
#loadSettingsForm .filters label { flex: 1 1 180px; }
#loadLegend { align-items: center; }
.scroll { overflow: auto; }
details { margin: 18px 0; }
summary { cursor: pointer; padding: 12px 0; min-height: 44px; font-weight: 600; }
.workout-button { display: block; width: 100%; text-align: left; margin: 10px 0; padding: 16px; overflow-wrap: anywhere; }
.summary-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.summary-metrics .card { margin: 0; padding: 16px; }
.summary-metrics .value { font-size: 24px; }
dialog { background: #141e2c; color: #eaf2fa; border: 1px solid #355d58; border-radius: 20px; width: min(1040px, calc(100vw - 40px)); max-height: calc(100dvh - 48px); padding: 24px; overflow: auto; overscroll-behavior: contain; }
dialog::backdrop { background: #000b; }
#close { position: sticky; top: 0; z-index: 2; float: right; background: #182332; }
#detailTitle { padding-right: 125px; overflow-wrap: anywhere; }
#trainingName { flex: 1 1 180px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.detail-grid > div { min-width: 0; }
.detail-chart, .load-history-svg, .route-map { display: block; width: 100%; background: #0e1723; border-radius: 12px; }
.load-history-svg { min-width: 0; touch-action: pan-y; }
.route-map { min-height: 240px; border: 1px solid #273345; margin-top: 12px; }
.chart-readout { min-height: 28px; margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.chart-control { display: block; margin-top: 8px; color: #aabbd0; font-size: 14px; }
.detail-chart { touch-action: pan-y; }
#status, #watchStatus { white-space: pre-line; }
#nameStatus:empty { display: none; }
.drop { border: 2px dashed #355d58; text-align: center; padding: 36px 16px; border-radius: 16px; background: #11232a; }
a { color: #8fb9ff; }
footer { color: #8fa3ba; font-size: 13px; padding-top: 0; }
@media (max-width: 900px) {
  .header-inner, main, footer { padding-left: 22px; padding-right: 22px; }
  .card { padding: 20px; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .header-inner { padding: 16px; gap: 8px; }
  .brand { font-size: 22px; gap: 8px; }
  .brand img { width: 44px; height: 44px; border-radius: 12px; }
  .pill { font-size: 12px; padding: 6px 8px; }
  main { padding: 22px 16px; }
  footer { padding: 0 16px 24px; }
  nav { display: grid; grid-template-columns: 1fr 1fr; }
  nav button { padding: 10px 8px; }
  .stats { gap: 8px; }
  .stats .card { padding: 12px 10px; }
  .stats .label { font-size: 13px; }
  .stats .value { font-size: 26px; }
  .stats p { font-size: 12px; margin-bottom: 0; }
  .card { padding: 16px; }
  .summary-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .summary-metrics .card { padding: 12px; }
  .summary-metrics .value { font-size: 22px; }
  dialog { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; padding: 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  #detailTitle { font-size: 23px; }
  .detail-grid { gap: 12px; }
  .filters { gap: 8px; }
  .route-map { min-height: 260px; }
}
@media (max-width: 360px) {
  .stats { grid-template-columns: 1fr; }
  .pill { white-space: normal; text-align: center; }
}
