:root {
  --bg: #0a0a0c;
  --surface: #131318;
  --surface-alt: #1a1a22;
  --border: rgba(255,255,255,0.06);
  --border-glow: rgba(0,224,180,0.15);
  --text: #f0f0f5;
  --text-dim: #6b6b80;
  --text-muted: #44445a;
  --accent: #00e0b4;
  --accent-dim: rgba(0,224,180,0.12);
  --accent-glow: rgba(0,224,180,0.25);
  --red: #ff4466;
  --red-dim: rgba(255,68,102,0.12);
  --red-glow: rgba(255,68,102,0.25);
  --orange: #ff9940;
  --blue: #4488ff;
  --purple: #a78bfa;
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; top: -40%; left: -20%; width: 80%; height: 80%;
  background: radial-gradient(ellipse, rgba(0,224,180,0.04) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
body::after {
  content: '';
  position: fixed; bottom: -30%; right: -20%; width: 70%; height: 70%;
  background: radial-gradient(ellipse, rgba(255,68,102,0.03) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

.app {
  position: relative; z-index: 1;
  max-width: 1040px; margin: 0 auto; padding: 32px 24px 48px;
}

/* ── Header ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 12px;
}
.logo { display: flex; align-items: center; gap: 14px; }
.logo-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #00b894);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.logo-icon svg { width: 24px; height: 24px; fill: var(--bg); }
.logo-text { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.logo-text span { color: var(--accent); }

.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--text-dim);
  transition: all 0.3s ease;
}
.badge.on { border-color: var(--border-glow); color: var(--accent); background: var(--accent-dim); }
.badge.on.hr { border-color: rgba(255,68,102,0.15); color: var(--red); background: var(--red-dim); }
.badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted); transition: all 0.3s ease;
}
.badge.on .badge-dot {
  background: var(--accent); box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
.badge.on.hr .badge-dot {
  background: var(--red); box-shadow: 0 0 8px var(--red-glow);
}
.badge:not(.on) { cursor: pointer; }
.badge:not(.on):hover { border-color: rgba(255,255,255,0.12); color: var(--text); }
.badge-close {
  display: none; background: none; border: none; padding: 2px;
  cursor: pointer; color: inherit; opacity: 0.45; margin-left: 4px;
  border-radius: 4px; line-height: 0; transition: opacity 0.2s;
}
.badge-close svg { width: 11px; height: 11px; }
.badge-close:hover { opacity: 1; }
.badge.on .badge-close { display: flex; align-items: center; }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Buttons ── */
.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.btn {
  padding: 10px 22px; font-size: 14px; font-weight: 600;
  font-family: 'Outfit', sans-serif; border: none; border-radius: 100px;
  cursor: pointer; transition: all 0.25s ease;
  display: flex; align-items: center; gap: 8px; letter-spacing: 0.2px;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #00c9a2);
  color: var(--bg); box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(0,224,180,0.35); }
.btn-hr {
  background: linear-gradient(135deg, var(--red), #e03355);
  color: #fff; box-shadow: 0 4px 16px var(--red-glow);
}
.btn-hr:hover { box-shadow: 0 6px 28px rgba(255,68,102,0.4); }
.btn-danger {
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(255,68,102,0.2);
}
.btn-danger:hover { background: rgba(255,68,102,0.18); }
.btn-ghost {
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); border-color: rgba(255,255,255,0.1); }
.btn-export {
  background: rgba(167,139,250,0.12); color: var(--purple);
  border: 1px solid rgba(167,139,250,0.2);
}
.btn-export:hover { background: rgba(167,139,250,0.2); }
.btn-pause {
  background: rgba(255,153,64,0.12); color: var(--orange);
  border: 1px solid rgba(255,153,64,0.2);
}
.btn-pause:hover { background: rgba(255,153,64,0.22); border-color: rgba(255,153,64,0.35); }
.btn-pause.is-paused {
  background: rgba(255,153,64,0.22); color: var(--orange);
  border-color: rgba(255,153,64,0.4);
}
.btn svg { width: 18px; height: 18px; }

/* ── Hero area ── */
.hero-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 24px;
}
.hero-card {
  text-align: center; padding: 32px 16px; position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color 0.4s ease;
}
.hero-card::before {
  content: ''; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 220px; height: 220px; border-radius: 50%;
  pointer-events: none; opacity: 0; transition: opacity 0.5s ease;
}
.hero-card.active::before { opacity: 1; }
.hero-card.speed-card::before { background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%); }
.hero-card.speed-card.active { border-color: rgba(0,224,180,0.12); }
.hero-card.hr-card::before { background: radial-gradient(circle, var(--red-dim) 0%, transparent 70%); }
.hero-card.hr-card.active { border-color: rgba(255,68,102,0.12); }

.hero-label {
  font-size: 12px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 2px; color: var(--text-muted); margin-bottom: 8px;
}
.hero-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 68px; font-weight: 600; letter-spacing: -3px;
  line-height: 1; color: var(--text); transition: color 0.3s ease;
  position: relative;
}
.hero-card.speed-card.active .hero-value { color: var(--accent); }
.hero-card.hr-card.active .hero-value { color: var(--red); }
.hero-unit {
  font-family: 'Outfit', sans-serif;
  font-size: 16px; font-weight: 400; color: var(--text-dim);
  margin-top: 6px; letter-spacing: 1px;
}

.heart-icon {
  display: inline-block; font-size: 22px;
  animation: none; margin-right: 2px; vertical-align: middle;
}
.hr-card.active .heart-icon { animation: heartbeat 0.8s ease-in-out infinite; }
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.25); }
  30% { transform: scale(1); }
  45% { transform: scale(1.15); }
  60% { transform: scale(1); }
}

.hr-zone {
  margin-top: 12px; display: flex; align-items: center;
  justify-content: center; gap: 8px; font-size: 12px;
  font-weight: 600; letter-spacing: 0.5px; opacity: 0;
  transition: opacity 0.3s ease;
}
.hr-card.active .hr-zone { opacity: 1; }
.hr-zone-dot {
  width: 8px; height: 8px; border-radius: 50%;
  transition: background 0.3s ease;
}

/* ── Metrics grid ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  transition: all 0.3s ease; position: relative; overflow: hidden;
}
.metric-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0; transition: opacity 0.4s ease;
}
.metric-card:hover::before { opacity: 0.5; }
.metric-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px; font-size: 14px;
}
.metric-icon.green { background: var(--accent-dim); color: var(--accent); }
.metric-icon.blue { background: rgba(68,136,255,0.12); color: var(--blue); }
.metric-icon.orange { background: rgba(255,153,64,0.12); color: var(--orange); }
.metric-icon.red { background: var(--red-dim); color: var(--red); }
.metric-label {
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 5px;
}
.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px; font-weight: 600; letter-spacing: -1px;
  display: flex; align-items: baseline; gap: 5px;
}
.metric-unit {
  font-family: 'Outfit', sans-serif;
  font-size: 12px; font-weight: 400; color: var(--text-muted);
}

/* ── Charts row ── */
.charts-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 20px;
}
.chart-wrapper {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.chart-header { margin-bottom: 14px; }
.chart-title {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
.chart-title .dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.green { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.dot.red { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }
.chart-canvas-wrap { position: relative; width: 100%; height: 200px; }
.chart-canvas-wrap canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* ── Recording indicator ── */
.rec-bar {
  display: none; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 20px; margin-bottom: 24px;
  font-size: 13px; font-weight: 500; color: var(--text-dim);
}
.rec-bar.active { display: flex; border-color: rgba(255,68,102,0.15); }
.rec-bar.active.paused { border-color: rgba(255,153,64,0.25); }
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 10px var(--red-glow);
  animation: pulse-dot 1s ease-in-out infinite;
}
.rec-bar.paused .rec-dot {
  background: var(--orange); box-shadow: 0 0 8px rgba(255,153,64,0.4);
  animation: none;
}
.rec-bar .rec-count { font-family: 'JetBrains Mono', monospace; color: var(--text); }
.rec-pause-label {
  display: none; font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; color: var(--orange); margin-left: 2px;
}
.rec-bar.paused .rec-pause-label { display: inline; }

/* ── Debug ── */
.debug-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13px; color: var(--text-muted);
  margin-bottom: 8px; user-select: none;
}
.debug-toggle:hover { color: var(--text-dim); }
.debug-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--text-muted); max-height: 180px; overflow-y: auto;
  white-space: pre-wrap; line-height: 1.7; display: none;
}
.debug-panel.open { display: block; }
.debug-panel::-webkit-scrollbar { width: 4px; }
.debug-panel::-webkit-scrollbar-track { background: transparent; }
.debug-panel::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.header { animation: fadeUp 0.5s ease both; }
.controls { animation: fadeUp 0.5s ease 0.05s both; }
.hero-row { animation: fadeUp 0.5s ease 0.1s both; }
.metrics { animation: fadeUp 0.5s ease 0.15s both; }
.charts-row { animation: fadeUp 0.5s ease 0.2s both; }

@media (max-width: 700px) {
  .app { padding: 20px 16px 36px; }
  .hero-row { grid-template-columns: 1fr; }
  .hero-value { font-size: 52px; }
  .charts-row { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric-value { font-size: 20px; }
  .controls { gap: 8px; }
  .btn { padding: 9px 16px; font-size: 13px; }
  .logo-text { font-size: 18px; }
}
