:root {
  --bg: #f7f5f4;
  --panel: #ffffff;
  --text: #1c1b1f;
  --muted: #6b6770;
  --border: #e6e1df;
  --accent: #c8102e;
  --accent-soft: #fbe9ec;
  --paper: #fff8f8;
  --grid-minor: #f6d9dc;
  --grid-major: #eeb3b9;
  --trace: #16151a;
  --p: rgba(47, 126, 216, 0.22);
  --qrs: rgba(214, 39, 40, 0.24);
  --t: rgba(44, 160, 44, 0.22);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141316;
    --panel: #1d1c20;
    --text: #ece9ee;
    --muted: #a19ca6;
    --border: #2f2d33;
    --accent: #ff5a6e;
    --accent-soft: #3a1d23;
    --paper: #1f1a1c;
    --grid-minor: #33272a;
    --grid-major: #4d3337;
    --trace: #f1eef3;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 20px; }

.hero { padding-block: 40px 24px; }
.hero h1 { margin: 0; font-size: 2.4rem; letter-spacing: -0.02em; }
.hero h1::before { content: "🫀 "; }
.tagline { margin: 2px 0 12px; font-size: 1.15rem; color: var(--accent); font-weight: 600; }
.lede { max-width: 760px; margin: 0 0 10px; }
.privacy, .links { margin: 4px 0; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
h2 { margin: 0 0 12px; font-size: 1.1rem; }

.status { margin-bottom: 16px; }
.status-text { font-weight: 600; }
.status-note { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.status.busy .bar-fill { animation: pulse 1.2s ease-in-out infinite; }
.status.error .status-text { color: var(--accent); }
@keyframes pulse { 50% { opacity: 0.45; } }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 130px; padding: 20px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 12px; transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.disabled { opacity: 0.5; pointer-events: none; }
.drop-title { font-weight: 600; }
.drop-hint { color: var(--muted); font-size: 0.85rem; }

.examples { margin-top: 16px; }
.examples-label { color: var(--muted); font-size: 0.9rem; }
.example-list { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.example {
  display: flex; flex-direction: column; gap: 6px; width: 180px; padding: 6px; cursor: pointer;
  background: var(--panel); color: var(--text); font: inherit; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: 10px;
}
.example:hover { border-color: var(--accent); }
.example:disabled { opacity: 0.5; cursor: wait; }
.example img { width: 100%; aspect-ratio: 22 / 16; object-fit: cover; border-radius: 6px; }

.grid-2 { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; }
.grid-2 > .panel { margin-bottom: 20px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; gap: 0; } }
.detections { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); }

.findings { list-style: none; padding: 0; margin: 0 0 14px; }
.findings li { padding: 6px 10px; border-radius: 8px; margin-bottom: 6px; background: var(--bg); }
.findings li::before { margin-right: 8px; }
.findings .info::before { content: "🟢"; }
.findings .moderate::before { content: "🟠"; }
.findings .severe::before { content: "🔴"; }

.measures { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.measures th, .measures td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.measures th { color: var(--muted); font-weight: 600; }
.measures td:nth-child(2) { font-variant-numeric: tabular-nums; font-weight: 600; }
.meta { color: var(--muted); font-size: 0.82rem; }
.not-assessed { margin: 8px 0 14px; color: var(--muted); font-size: 0.9rem; }
.not-assessed summary { cursor: pointer; }

button.secondary {
  font: inherit; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
}
button.secondary:hover { background: var(--accent-soft); }

.waves-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.legend { color: var(--muted); font-size: 0.85rem; }
.key { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; }
.key.p { background: var(--p); outline: 1px solid rgba(47, 126, 216, 0.6); }
.key.qrs { background: var(--qrs); outline: 1px solid rgba(214, 39, 40, 0.6); }
.key.t { background: var(--t); outline: 1px solid rgba(44, 160, 44, 0.6); }

.leads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 860px) { .leads { grid-template-columns: repeat(2, 1fr); } }
.lead-cell { position: relative; }
.lead-cell canvas { width: 100%; height: 130px; display: block; border-radius: 6px; }
.lead-name { position: absolute; top: 4px; left: 8px; font-weight: 700; font-size: 0.8rem; }
.lead-missing { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 0.8rem; }
.rhythm { margin-top: 8px; }
.rhythm .lead-cell canvas { height: 150px; }

.how ol { padding-left: 20px; margin: 0 0 10px; }
.how li { margin-bottom: 6px; }
.tech { color: var(--muted); font-size: 0.85rem; margin: 0; }
.disclaimer { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 10px 0 40px; }

.res-warning {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 8px;
  background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent); font-size: 0.9rem;
}
