:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel-2: #1e2740;
  --text: #e8ecf4;
  --muted: #8a93a8;
  --accent: #4f8cff;
  --danger: #e5534b;
  --border: #2a3350;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; margin: 0; }
.subtitle { color: var(--muted); font-size: 13px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge[data-status="open"] { border-color: var(--accent); color: var(--accent); }
.badge[data-status="in_progress"] { border-color: #e6b450; color: #e6b450; }
.badge[data-status="done"] { border-color: #4caf7d; color: #4caf7d; }

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.active { outline: 2px solid var(--accent); }

/* ---------- Dashboard ---------- */
.dashboard {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1200px;
}
@media (max-width: 900px) { .dashboard { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.panel h2 { margin-top: 0; font-size: 16px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.form-grid .btn { grid-column: 1 / -1; }

.intervention-list { display: flex; flex-direction: column; gap: 14px; }
.empty { color: var(--muted); }

.intervention-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.ic-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ic-title { margin: 0; font-size: 15px; }
.ic-meta { color: var(--muted); font-size: 13px; margin: 6px 0; }
.ic-desc { font-size: 13px; margin: 6px 0; white-space: pre-wrap; }
.ic-sessions { font-size: 12px; color: var(--muted); margin: 8px 0; }
.ic-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Room ---------- */
.room-body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.room-layout { display: flex; flex: 1; min-height: 0; }

.stage-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.stage {
  position: relative;
  flex: 1;
  background: #000;
  overflow: hidden;
}
#stage-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
#annotation-canvas { position: absolute; pointer-events: none; }
#annotation-canvas.draw-enabled { pointer-events: auto; cursor: crosshair; }

.stage-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px;
}
.stage-empty.hidden { display: none; }

.pip {
  position: absolute; right: 16px; bottom: 16px;
  width: 200px; aspect-ratio: 4/3;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  z-index: 5;
}
.pip.hidden { display: none; }
.pip video { width: 100%; height: 100%; object-fit: cover; }
.pip-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 11px; padding: 2px 8px;
  background: rgba(0,0,0,0.55);
}

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.toolbar label { font-size: 12px; color: var(--muted); }
.toolbar input[type="color"] {
  width: 32px; height: 32px; padding: 2px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-2); cursor: pointer;
}

.sidebar {
  width: 300px;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  min-height: 0;
}
.participants {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  display: flex; flex-direction: column; gap: 4px;
}
.participants .p-name { color: var(--text); }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-msg { font-size: 13px; line-height: 1.35; }
.chat-msg .who { font-weight: 600; margin-right: 6px; }
.chat-msg .time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.chat-msg.system { color: var(--muted); font-style: italic; }

.chat-form {
  display: flex; gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
}

@media (max-width: 800px) {
  .room-layout { flex-direction: column; }
  .sidebar { width: 100%; height: 240px; border-left: none; border-top: 1px solid var(--border); }
  .pip { width: 130px; }
}
