:root {
  --bg-primary: #0a0d14;
  --bg-chat: #07090e;
  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --status-green: #10b981;
  --status-red: #ef4444;
  --text-main: #f3f4f6;
  --text-muted: #8892b0;
  --border-color: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(15, 22, 36, 0.85);
  --glass-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  box-shadow: var(--glass-shadow);
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  flex-shrink: 0;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.session-selector-container {
  position: relative;
  display: flex;
  align-items: center;
}

.session-dropdown {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 32px 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s ease;
}

.session-dropdown:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.session-dropdown:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.session-selector-container::after {
  content: "";
  position: absolute;
  right: 12px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--text-muted);
  pointer-events: none;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.connected {
  background-color: var(--status-green);
  box-shadow: 0 0 10px var(--status-green);
}

.dot.disconnected {
  background-color: var(--status-red);
  box-shadow: 0 0 10px var(--status-red);
}

.header-action-btn {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.header-action-btn.active {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.header-action-btn:active {
  transform: scale(0.95);
}

/* Main Layout */
.main-layout {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Chat Messenger Panel */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-chat);
  overflow: hidden;
  position: relative;
}

.chat-header {
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.chat-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Messages History Scroll Area */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message Bubble Styles */
.msg-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.msg-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

.msg-bubble.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.msg-bubble.assistant code {
  font-family: 'Fira Code', monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent-cyan);
}

.msg-bubble.assistant pre {
  font-family: 'Fira Code', monospace;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.msg-timestamp {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 6px;
  text-align: right;
  display: block;
}

.msg-bubble.assistant .msg-timestamp {
  color: var(--text-muted);
}

.sys-bubble {
  align-self: center;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 14px;
  border-radius: 12px;
  text-align: center;
  max-width: 90%;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Presets Row */
.presets-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.presets-row::-webkit-scrollbar {
  display: none;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.preset-btn:active {
  background: var(--accent-indigo);
  color: #fff;
  border-color: var(--accent-indigo);
}

/* Chat Input Bar */
.chat-input-bar {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--border-color);
  gap: 12px;
  flex-shrink: 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

#chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 10px 16px;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

#chat-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.send-btn {
  background: var(--accent-indigo);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.send-btn:active {
  transform: scale(0.9);
  background: var(--accent-purple);
}

/* Collapsible Visual Stream Panel */
.screencast-container {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 1px solid var(--border-color);
}

.screencast-container.hidden {
  transform: translateX(100%);
}

.screencast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
}

.screencast-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.screencast-control-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.screencast-control-btn.active-pointer {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.15);
}

.screencast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding-left: 6px;
}

.viewer-area {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  overflow: hidden;
  background: #000;
}

.canvas-wrapper {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#screen-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

#gesture-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.keyboard-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--border-color);
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

.keyboard-bar input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.keyboard-bar input:focus {
  border-color: var(--accent-indigo);
}

.keyboard-bar button {
  background: var(--accent-indigo);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

/* Side-by-side split on tablet and desktop screens */
@media (min-width: 900px) {
  .screencast-container {
    position: relative;
    max-width: 480px;
    transform: none !important;
  }
  .screencast-container.hidden {
    display: none;
  }
  .screencast-close {
    display: none;
  }
}
