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

:root {
  --bg:      #0d0d0d;
  --bg1:     #111111;
  --bg2:     #1a1a1a;
  --border:  #2a2a2a;
  --text:    #d0d0d0;
  --muted:   #666666;
  --accent:  #3a3a3a;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* ── Top bar ─────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 12px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 38px;
}

#topbar label { color: var(--muted); margin-right: 4px; }

select {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 3px 6px;
  font-family: inherit;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  min-width: 280px;
}

select:focus { border-color: #555; }

#meta {
  color: var(--muted);
  font-size: 11px;
  margin-left: 8px;
}

/* ── Timeline ─────────────────────────────────────────────── */
#timeline-wrap {
  flex-shrink: 0;
  position: relative;
}

#timeline-canvas {
  display: block;
  width: 100%;
  height: 28px;
  cursor: pointer;
  background: var(--bg2);
}

#timeline-canvas:hover { opacity: 0.9; }

/* ── Panel headers ────────────────────────────────────────── */
.panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 10px;
  background: var(--bg1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  height: 22px;
}

.panel-hdr span { color: var(--muted); font-size: 11px; letter-spacing: 1px; }

/* ── Main layout: signals | topo ──────────────────────────── */
#main-wrap {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

#signals-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* ── EEG panel ────────────────────────────────────────────── */
#eeg-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#eeg-canvas {
  flex: 1;
  display: block;
  width: 100%;
  min-height: 0;
  background: #050505;
}

/* ── Topo panel ───────────────────────────────────────────── */
#topo-section {
  width: 210px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}

#topo-canvas {
  display: block;
  width: 100%;
  height: 210px;
  flex-shrink: 0;
  background: #0d0d0d;
}

/* ── Event log ────────────────────────────────────────────── */
#event-log {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  cursor: pointer;
  border-bottom: 1px solid #161616;
}

.event-row:hover  { background: #1a1a1a; }
.event-row.current { background: #1a1a2e; }

.event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-time {
  color: #555;
  font-size: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 38px;
}

.event-label {
  color: #777;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Floating tooltip ─────────────────────────────────────── */
#tt {
  position: fixed;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #ccc;
  font: 10px monospace;
  padding: 3px 8px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

#tt.hidden { display: none; }

/* ── ECG / EDA panels ─────────────────────────────────────── */
#ecg-wrap, #eda-wrap {
  flex-shrink: 0;
}

#ecg-canvas, #eda-canvas {
  display: block;
  width: 100%;
  height: 72px;
  background: #050505;
}

/* ── Controls bar ─────────────────────────────────────────── */
#controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  background: var(--bg1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  height: 36px;
}

button {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 3px 9px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.4;
  transition: background 0.1s;
}

button:hover:not(:disabled) { background: var(--accent); }
button.active { background: #2d2d2d; border-color: #555; color: #eee; }
button:disabled { opacity: 0.3; cursor: default; }

#btn-play {
  width: 30px;
  font-size: 13px;
  padding: 3px 5px;
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

#time-display {
  color: #888;
  margin-left: auto;
  letter-spacing: 1px;
  font-size: 12px;
}

/* ── Loading overlay ─────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  letter-spacing: 2px;
  color: #888;
  z-index: 100;
}

#loading.hidden { display: none; }

/* ── About popup ──────────────────────────────────────────── */
#about-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#about-overlay.hidden { display: none; }

#about-box {
  background: #161616;
  border: 1px solid #333;
  padding: 24px 28px;
  min-width: 340px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#about-hdr {
  font-size: 13px;
  letter-spacing: 2px;
  color: #888;
  text-transform: uppercase;
}

#about-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #bbb;
  font-size: 12px;
  line-height: 1.6;
}

#about-body ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#about-body a {
  color: #6aa;
  text-decoration: none;
}

#about-body a:hover { text-decoration: underline; }

#about-close { align-self: flex-end; }

/* ── Legend overlay on EEG canvas ────────────────────────── */
#eeg-legend {
  position: absolute;
  bottom: 4px;
  right: 8px;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

#eeg-legend span {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 2px;
  opacity: 0.7;
}
