/* --- Reset & Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=DM+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap');

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

:root {
  --bg: #06070d;
  --bg-gradient: linear-gradient(135deg, #06070d 0%, #0c1220 40%, #0a0f1e 100%);
  --surface: rgba(15, 20, 35, 0.7);
  --surface-solid: #0f1423;
  --surface-2: rgba(22, 30, 50, 0.8);
  --glass: rgba(15, 20, 40, 0.55);
  --glass-border: rgba(60, 80, 130, 0.25);
  --border: rgba(45, 55, 80, 0.5);
  --text: #e8ecf4;
  --text-dim: #7a849b;
  --text-muted: #4a5168;
  --accent: #00d4aa;
  --accent-glow: rgba(0, 212, 170, 0.15);
  --accent-hover: #00f0c0;
  --accent-2: #3b82f6;
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-display: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --shadow-glow: 0 0 30px rgba(0, 212, 170, 0.08);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--glass-border);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.page-host, .page-host body,
.page-viewer, .page-viewer body {
  height: 100%;
  overflow: hidden;
}

.hidden { display: none !important; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: #fff;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #00b894 100%);
  box-shadow: 0 2px 16px rgba(0, 212, 170, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 4px 24px rgba(0, 212, 170, 0.4);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.btn-secondary:hover {
  background: rgba(30, 40, 65, 0.9);
  border-color: var(--glass-border);
}
.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #be123c 100%);
  box-shadow: 0 2px 12px rgba(244, 63, 94, 0.2);
}
.btn-danger:hover { box-shadow: 0 4px 20px rgba(244, 63, 94, 0.35); }
.btn-large {
  padding: 15px 40px;
  font-size: 16px;
  border-radius: var(--radius-lg);
}
.btn-small { padding: 7px 16px; font-size: 13px; }

/* --- Landing Page --- */
.page-landing {
  background: var(--bg-gradient);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Ambient glow orbs */
.page-landing::before,
.page-landing::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.page-landing::before {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 212, 170, 0.08) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  animation: float-orb 20s ease-in-out infinite;
}
.page-landing::after {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.06) 0%, transparent 70%);
  bottom: -50px;
  left: -50px;
  animation: float-orb 25s ease-in-out infinite reverse;
}

@keyframes float-orb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 32px;
  position: relative;
  z-index: 1;
}

.landing-header {
  text-align: center;
  margin-bottom: 56px;
  animation: fade-up 0.6s ease-out;
}
.landing-logo {
  width: 100px;
  height: 100px;
  border-radius: 22px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.3s ease;
}
.landing-logo:hover { transform: scale(1.05) rotate(-2deg); }

.landing-header h1 {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 50%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle {
  color: var(--text-dim);
  margin-top: 12px;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* Cards */
.landing-cards {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  animation: fade-up 0.6s ease-out 0.15s both;
}
.card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 340px;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  border-color: rgba(0, 212, 170, 0.2);
}
.card h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}
.card p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}
.card-icon {
  font-size: 36px;
  margin-bottom: 18px;
  display: inline-block;
  filter: saturate(1.3);
}

/* Join form */
.join-form {
  display: flex;
  gap: 8px;
}
.join-form input {
  flex: 1;
  padding: 11px 16px;
  background: rgba(6, 7, 13, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: all var(--transition);
}
.join-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.join-form input::placeholder { color: var(--text-muted); }

/* How it works */
.landing-info {
  margin-top: 56px;
  max-width: 720px;
  text-align: center;
  animation: fade-up 0.6s ease-out 0.3s both;
}
.landing-info h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
  letter-spacing: -0.3px;
}
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  text-align: left;
}
.info-item {
  padding: 20px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  transition: all 0.3s ease;
}
.info-item:hover {
  border-color: rgba(0, 212, 170, 0.15);
  background: rgba(15, 20, 40, 0.65);
}
.info-item strong {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.info-item p {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}
@media (max-width: 600px) {
  .info-grid { grid-template-columns: 1fr; }
  .landing-header h1 { font-size: 32px; }
  .landing-cards { flex-direction: column; align-items: center; }
}

/* Disclaimer */
.disclaimer {
  margin-top: 40px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  max-width: 500px;
  line-height: 1.6;
  animation: fade-up 0.6s ease-out 0.45s both;
}

/* Animations */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Setup / Connect Screen --- */
.setup-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-gradient);
}
.setup-card {
  background: var(--glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 48px;
  text-align: center;
  max-width: 440px;
  box-shadow: var(--shadow-card);
  animation: fade-up 0.4s ease-out;
}
.setup-card h1, .setup-card h2 {
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}
.setup-card h1 { font-size: 28px; }
.setup-card h2 { font-size: 22px; }
.setup-card p {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 14px;
}
.audio-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 20px;
  margin-bottom: 0;
  line-height: 1.5;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid rgba(0, 212, 170, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 50px;
  z-index: 10;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-left { font-size: 13px; }
.topbar-center {
  position: relative;
  display: flex;
  align-items: center;
}
.room-link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  background: rgba(6, 7, 13, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'DM Mono', 'Fira Code', monospace;
  font-size: 12px;
  transition: all var(--transition);
  user-select: all;
  color: var(--text-dim);
}
.room-link-box:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  color: var(--text);
}
.copy-icon { font-size: 13px; opacity: 0.5; }
.copied-toast {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  padding: 5px 14px;
  background: var(--accent);
  color: #000;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3);
}

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-dot.live {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}
.status-dot.error { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 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: 50px;
  right: 0;
  width: 240px;
  height: calc(100% - 50px);
  background: var(--surface-solid);
  border-left: 1px solid var(--border);
  padding: 20px;
  z-index: 5;
  animation: slide-in-right 0.2s ease-out;
}
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.viewer-panel h3 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.viewer-panel ul { list-style: none; }
.viewer-panel li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.viewer-panel li .revoke-btn {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  margin-left: 4px;
}
.viewer-panel li .revoke-btn:hover { background: var(--danger-hover); }

/* --- Toolbar (annotations) --- */
.toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  z-index: 10;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.tool-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
}
.tool-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.tool-btn.active {
  background: var(--accent);
  color: #000;
  box-shadow: 0 2px 8px rgba(0, 212, 170, 0.3);
}
.color-picks {
  display: flex;
  gap: 4px;
  padding: 0 6px;
}
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 8px rgba(255, 255, 255, 0.2); }
.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

/* --- Viewer Screen --- */
.viewing-screen {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
}
.video-container {
  position: relative;
  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 (legacy, kept for backward compat) */
.host-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  transition: left 0.05s linear, top 0.05s linear;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Remote cursors container */
.remote-cursors {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* Individual remote cursor */
.remote-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  transition: left 0.05s linear, top 0.05s linear;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.remote-cursor-label {
  position: absolute;
  left: 16px;
  top: 14px;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.9;
}

/* Viewer toolbar */
.viewer-toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  z-index: 30;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.viewing-screen.toolbar-hidden .viewer-toolbar {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  pointer-events: none;
}
.viewing-screen.toolbar-hidden:hover .viewer-toolbar,
.viewing-screen.toolbar-hidden .viewer-toolbar:hover {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.control-status {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  padding: 0 6px;
  letter-spacing: 0.02em;
}

/* Viewer status */
.viewer-status {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  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: 100px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  animation: fade-in 0.2s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-body {
  background: var(--surface-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 28px 36px;
  text-align: center;
  max-width: 420px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: fade-up 0.3s ease-out;
}
.modal-body p {
  margin-bottom: 20px;
  font-size: 15px;
}
.modal-body strong { color: var(--accent); }
.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* --- Remote Control Active --- */
.video-container.remote-control-active video {
  cursor: none;
}
.video-container.host-paused {
  position: relative;
}
.video-container.host-paused::after {
  content: 'Host is selecting a new source...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--glass);
  backdrop-filter: blur(20px);
  color: var(--text);
  padding: 20px 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  z-index: 10;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.video-container.host-paused video {
  opacity: 0.2;
  filter: blur(2px);
}
