/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a12;
  --surface: #14141f;
  --surface-2: #1e1e2e;
  --border: #2a2a3e;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --primary: #4f46e5;
  --primary-hover: #6366f1;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --radius: 8px;
  --radius-lg: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  overflow: hidden;
}

.hidden { display: none !important; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
  color: #fff;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-large { padding: 14px 36px; font-size: 16px; }
.btn-small { padding: 6px 14px; font-size: 13px; }

/* --- Landing Page --- */
.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.landing-header {
  text-align: center;
  margin-bottom: 48px;
}
.landing-header h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.subtitle {
  color: var(--text-dim);
  margin-top: 8px;
  font-size: 16px;
}
.landing-cards {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 320px;
  text-align: center;
}
.card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}
.card p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 20px;
}
.card-icon {
  font-size: 32px;
  margin-bottom: 16px;
}
.join-form {
  display: flex;
  gap: 8px;
}
.join-form input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-size: 14px;
}
.join-form input:focus {
  outline: none;
  border-color: var(--primary);
}

/* --- Setup / Connect Screen --- */
.setup-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  max-width: 420px;
}
.setup-card h1, .setup-card h2 {
  margin-bottom: 12px;
}
.setup-card p {
  color: var(--text-dim);
  margin-bottom: 24px;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Host Sharing Screen --- */
.sharing-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 48px;
  z-index: 10;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-center {
  position: relative;
  display: flex;
  align-items: center;
}
.room-link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: monospace;
  font-size: 13px;
  transition: border-color 0.15s;
  user-select: all;
}
.room-link-box:hover { border-color: var(--primary); }
.copy-icon { font-size: 14px; opacity: 0.6; }
.copied-toast {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  padding: 4px 10px;
  background: var(--success);
  color: #fff;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.live { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.error { background: var(--danger); }

/* Video preview */
.preview-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}
.preview-container video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.preview-container canvas {
  position: absolute;
  pointer-events: none;
}
.preview-container canvas.drawing {
  pointer-events: auto;
  cursor: crosshair;
}

/* Viewer panel */
.viewer-panel {
  position: absolute;
  top: 48px;
  right: 0;
  width: 220px;
  height: calc(100% - 48px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px;
  z-index: 5;
}
.viewer-panel h3 { font-size: 14px; margin-bottom: 12px; color: var(--text-dim); }
.viewer-panel ul { list-style: none; }
.viewer-panel li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.viewer-panel li .revoke-btn {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* --- Toolbar (annotations) --- */
.toolbar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  z-index: 10;
}
.tool-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}
.tool-btn:hover { background: var(--surface-2); }
.tool-btn.active { background: var(--primary); }
.color-picks {
  display: flex;
  gap: 4px;
  padding: 0 4px;
}
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; }
.toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* --- Viewer Screen --- */
.viewing-screen {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
}
.video-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.video-container video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.video-container canvas {
  position: absolute;
  pointer-events: none;
}
.video-container canvas.drawing {
  pointer-events: auto;
  cursor: crosshair;
}

/* Host cursor overlay */
.host-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  transition: left 0.05s linear, top 0.05s linear;
}

/* Viewer toolbar */
.viewer-toolbar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(20, 20, 31, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  z-index: 30;
  opacity: 1;
  transition: opacity 0.3s;
}
.viewing-screen.toolbar-hidden .viewer-toolbar {
  opacity: 0;
  pointer-events: none;
}
.viewing-screen.toolbar-hidden:hover .viewer-toolbar,
.viewing-screen.toolbar-hidden .viewer-toolbar:hover {
  opacity: 1;
  pointer-events: auto;
}

.control-status {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
  padding: 0 4px;
}

/* Viewer status */
.viewer-status {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(20, 20, 31, 0.8);
  border-radius: var(--radius);
  font-size: 12px;
  z-index: 30;
}

/* --- Modal --- */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  background: rgba(0,0,0,0.5);
  z-index: 100;
}
.modal-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  text-align: center;
  max-width: 400px;
}
.modal-body p { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* --- Remote Control Active --- */
.video-container.remote-control-active video {
  cursor: none;
}
