:root {
  --bg: #16181c;
  --panel: #1f2228;
  --panel2: #272b33;
  --line: #353a44;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #3d8bfd;
  --cursor: #e5383b;
  --paper: #fbfbf8;
  --side-w: 420px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: grid; grid-template-rows: auto 1fr auto; overflow: hidden;
}
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .02em; margin-right: 4px; }
.brand a { color: var(--muted); text-decoration: none; }
.brand strong { color: #96c5ff; font-size: 10px; border: 1px solid #5884b0; border-radius: 3px; padding: 2px 4px; }
.upload { border: 1px solid var(--line); border-radius: 5px; padding: 4px 8px; cursor: pointer; color: var(--text); }
.upload:hover { border-color: #56607a; }
.upload input { display: none; }
#fileStatus { color: var(--muted); font-size: 11px; max-width: 280px; }
.sep { width: 1px; height: 24px; background: var(--line); }
label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
label.check { cursor: pointer; }
select, button, input[type=range] { font: inherit; color: var(--text); }
select {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 5px;
  padding: 3px 6px; max-width: 210px;
}
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 5px;
  padding: 3px 9px; cursor: pointer; min-width: 32px; height: 27px;
}
button:hover { border-color: #56607a; }
button.play { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 44px; }
.clock { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; min-width: 86px; }
.clock span { font: 600 18px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.clock small { color: var(--muted); font-family: ui-monospace, Menlo, monospace; }

main { position: relative; min-height: 0; }
.eeg-wrap { position: absolute; inset: 0; background: var(--paper); }
#eeg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.loading {
  position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.65); color: #fff;
  padding: 3px 9px; border-radius: 4px; font-size: 12px;
}
.hidden { display: none !important; }

/* video sovrapposto al tracciato, spostabile e ridimensionabile */
.side {
  position: absolute; top: 30px; right: 12px; width: var(--side-w); z-index: 5;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); border-radius: 6px; overflow: hidden;
}
.video-box { position: relative; background: #000; aspect-ratio: 4 / 3; }
.video-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-box video.standby { visibility: hidden; }
.novideo {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); background: #0b0c0e; text-align: center; padding: 10px;
}
.drag { position: absolute; left: 0; right: 0; top: 0; height: 40%; cursor: move; }
.resize {
  position: absolute; left: 0; bottom: 0; width: 18px; height: 18px; cursor: nesw-resize;
  background: linear-gradient(45deg, transparent 50%, rgba(255,255,255,.55) 50%, rgba(255,255,255,.55) 60%, transparent 60%, transparent 70%, rgba(255,255,255,.55) 70%, rgba(255,255,255,.55) 80%, transparent 80%);
  transform: scaleX(-1); opacity: 0; transition: opacity .15s;
}
.video-tools {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 24px; background: linear-gradient(transparent, rgba(0,0,0,.75));
  opacity: 0; transition: opacity .15s;
}
.video-box:hover .video-tools, .video-box:hover .resize { opacity: 1; }
.video-tools button { background: rgba(0,0,0,.4); border-color: rgba(255,255,255,.2); }
.video-tools span { flex: 1; color: #ccc; font-size: 11px; text-align: right; }
.video-tools input { width: 90px; }

.timeline-wrap { height: 54px; background: var(--panel); border-top: 1px solid var(--line); position: relative; }
#timeline { width: 100%; height: 100%; display: block; cursor: pointer; }

@media (max-width: 1100px) {
  :root { --side-w: 300px; }
}
