:root {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-elevated: #1a2234;
  --bg-hover: #232d42;
  --border: #273248;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --cyan: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  overflow: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

/* Connect View */
#connect-view {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 45%),
              radial-gradient(circle at bottom left, rgba(6, 182, 212, 0.1), transparent 45%),
              var(--bg-main);
}

.connect-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 8px 20px var(--accent-glow);
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand span {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.dot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot.offline { background: var(--danger); }

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input.id-input {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  font-family: 'Consolas', 'Courier New', monospace;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
  padding: 13px;
  font-size: 15px;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.alert {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.alert-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

/* Session View */
#session-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #000;
}

.session-toolbar {
  height: 48px;
  background: rgba(17, 24, 39, 0.96);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 20;
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.session-badge strong { color: var(--text-primary); }

.toolbar-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
}

.badge-count {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

.session-body {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05070c;
  overflow: hidden;
  outline: none;
}

#remote-video, #remote-canvas {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: default;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(9, 13, 22, 0.85);
  z-index: 5;
  text-align: center;
  padding: 24px;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Side Panel (Chat / Files / Clipboard) */
.side-panel {
  width: 340px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.panel-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

.panel-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px;
  gap: 10px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  user-select: text;
}

.chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-bubble.me {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.chat-bubble.peer {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.chat-meta {
  font-size: 10px;
  opacity: 0.75;
  margin-bottom: 2px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input-row input {
  flex: 1;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

.file-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
}

.file-item-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.file-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-bar {
  height: 6px;
  background: var(--bg-main);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.1s;
}

textarea.clip-box {
  width: 100%;
  flex: 1;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  color: var(--text-primary);
  font-size: 13px;
  resize: none;
  outline: none;
  user-select: text;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  z-index: 100;
}
