:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface2: #1e1e1e;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #888;
  --accent: #4ade80;
  --accent2: #60a5fa;
  --warn: #fbbf24;
  --danger: #f87171;
  --card-r: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
.header {
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.header-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #4ade80, #22d3ee);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.header h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }
.header p { font-size: 13px; color: var(--muted); margin-top: 1px; }

.container { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

/* Upload section */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--card-r);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
  position: relative;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
  background: #0f1f14;
}
.upload-area input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-icon { font-size: 40px; margin-bottom: 12px; }
.upload-area h2 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.upload-area p { color: var(--muted); font-size: 13px; }

.file-selected {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 16px;
}
.file-selected.visible { display: flex; }
.file-name { font-size: 14px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--muted); }
.file-check-icon { font-size: 20px; }

/* Inputs */
.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}
.input-group label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.input-wrap:focus-within { border-color: var(--accent2); }
.input-wrap input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  padding: 10px 14px;
  width: 100%;
  font-weight: 500;
}
.input-unit {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.input-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.analyze-btn {
  margin-top: 24px;
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #000;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: opacity 0.2s, transform 0.1s;
}
.analyze-btn:hover { opacity: 0.9; }
.analyze-btn:active { transform: scale(0.99); }
.analyze-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Status */
.status {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
}
.status.visible { display: flex; }
.status.loading { background: #1a1a2e; border: 1px solid #2d2d5e; color: var(--accent2); }
.status.error { background: #1f0a0a; border: 1px solid #4b1717; color: var(--danger); }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
#results { display: none; margin-top: 40px; }
#results.visible { display: block; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 14px;
  margin-top: 32px;
}
.section-title:first-child { margin-top: 0; }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-r);
  padding: 16px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1; }
.stat-unit { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }

/* VO2 estimates */
.estimate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-r);
  padding: 18px 20px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}
.estimate-method { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.estimate-notes { font-size: 13px; color: var(--muted); line-height: 1.5; }
.estimate-right { text-align: right; }
.estimate-value {
  font-size: 32px; font-weight: 800; line-height: 1;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.estimate-unit { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 6px;
}
.badge-bar-track {
  width: 40px; height: 4px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
}
.badge-bar-fill { height: 100%; border-radius: 2px; }

/* Fitness category */
.fitness-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-r);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.fitness-cat-name {
  font-size: 22px; font-weight: 800;
  background: linear-gradient(90deg, var(--accent), #22d3ee);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.fitness-cat-desc { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* VO2 scale bar */
.vo2-scale {
  flex: 1;
  position: relative;
  height: 8px;
  background: linear-gradient(90deg, #ef4444, #f97316, #eab308, #22c55e, #3b82f6, #8b5cf6);
  border-radius: 4px;
  overflow: visible;
}
.vo2-scale-marker {
  position: absolute;
  top: -4px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--bg);
  transform: translateX(-50%);
  box-shadow: 0 0 0 2px var(--accent);
}

/* Charts */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-r);
  padding: 20px;
  margin-bottom: 12px;
}
.chart-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
canvas { display: block; width: 100%; }

.legend {
  display: flex; gap: 20px; flex-wrap: wrap;
  margin-top: 10px;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-dot { width: 10px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.legend-dot--pace { background: #4ade80; }
.legend-dot--hr { background: #f87171; }

/* No data notice */
.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-r);
  padding: 14px 18px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .analyze-btn, .upload-area { transition: none; }
  .input-wrap { transition: none; }
}

.upload-area:focus-within {
  border-color: var(--accent);
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .inputs { grid-template-columns: 1fr; }
  .header { padding: 16px 20px; }
  .container { padding: 24px 16px; }
  .estimate-card { grid-template-columns: 1fr; }
  .estimate-right { text-align: left; }
}
