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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: #16162a;
  --accent-primary: #6c5ce7;
  --accent-secondary: #a29bfe;
  --accent-success: #00d26a;
  --accent-warning: #ffc048;
  --accent-danger: #ff4757;
  --text-primary: #ffffff;
  --text-secondary: #b8b8d4;
  --text-muted: #6c6c8a;
  --border-color: #2a2a4a;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100vh;
  overflow: hidden;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  height: 48px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 1.25rem;
}

.logo h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.highlight {
  color: var(--accent-primary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-tertiary);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-primary);
}

.btn-logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
  margin-left: 0.25rem;
}

.btn-logout:hover {
  opacity: 1;
}

.nickname {
  color: var(--accent-secondary);
  font-weight: 600;
  font-size: 0.8rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-primary);
}

.btn-logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
  margin-left: 0.25rem;
}

.btn-logout:hover {
  opacity: 1;
}

.nickname {
  color: var(--accent-secondary);
  font-weight: 600;
  font-size: 0.8rem;
}

.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.landing-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.landing-content {
  text-align: center;
  max-width: 500px;
}

.landing-content h2 {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-content p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.permissions-check {
  margin-bottom: 1rem;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #7c6cf0);
  color: white;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.5);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-color);
}

.btn-large {
  padding: 0.85rem 2.5rem;
  font-size: 1.1rem;
  border-radius: var(--radius);
}

.btn-next {
  background: linear-gradient(135deg, var(--accent-success), #00e676);
  color: #000;
  padding: 0.5rem 1.5rem;
}

.btn-start {
  background: linear-gradient(135deg, var(--accent-primary), #7c6cf0);
  color: white;
  padding: 0.5rem 1.5rem;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn-start:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.5);
}

.btn-next:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 210, 106, 0.4);
}

.btn-stop {
  background: linear-gradient(135deg, var(--accent-danger), #ff6b7a);
  color: white;
  padding: 0.5rem 1.25rem;
}

.btn-stop:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-send {
  background: var(--accent-primary);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-secondary);
}

.btn-cancel {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  margin-top: 1rem;
}

.btn-cancel:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.btn-mic, .btn-cam {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  width: 40px;
  height: 40px;
}

.btn-mic:hover, .btn-cam:hover {
  background: var(--border-color);
}

.btn-mic.muted, .btn-cam.disabled {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
}

.btn-icon {
  font-size: 1.1rem;
}

.chat-screen {
  flex: 1;
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  min-height: 0;
  overflow: hidden;
}

.video-section {
  flex: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.video-main-container {
  flex: 1;
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
  min-height: 0;
}

.video-main-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-pip-container {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 180px;
  height: 135px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--accent-primary);
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.video-pip-container:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(108, 92, 231, 0.4);
}

.video-pip-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-pip-container .camera-off-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.video-pip-container .camera-off-overlay .cam-off-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
  opacity: 0.7;
}

.video-pip-container .camera-off-overlay .cam-off-text {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.video-pip-container.camera-disabled .camera-off-overlay {
  display: flex;
}

.video-pip-container .video-label {
  bottom: 4px;
  left: 4px;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
}

.video-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.remote-label {
  background: rgba(108, 92, 231, 0.8);
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.video-placeholder p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  min-width: 280px;
  max-width: 380px;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-header h3 {
  font-size: 0.95rem;
}

.chat-status {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.chat-status.connected {
  background: rgba(0, 210, 106, 0.2);
  color: var(--accent-success);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.message {
  max-width: 85%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  word-wrap: break-word;
  animation: messageSlide 0.2s ease;
  font-size: 0.9rem;
}

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

.message.system {
  align-self: center;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  max-width: 100%;
}

.message.sent {
  align-self: flex-end;
  background: var(--accent-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.received {
  align-self: flex-start;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message .sender {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-bottom: 0.15rem;
}

.typing-indicator {
  padding: 0.4rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: italic;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-input-container {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-input-container input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.chat-input-container input:focus {
  border-color: var(--accent-primary);
}

.chat-input-container input:disabled {
  opacity: 0.5;
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  height: 56px;
}

.searching-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(5px);
}

.searching-content {
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

.searching-content h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.searching-content p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer {
  text-align: center;
  padding: 0.4rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  .chat-screen {
    flex-direction: column;
  }

  .video-section {
    flex: none;
    height: 45%;
  }

  .video-pip-container {
    width: 120px;
    height: 90px;
    bottom: 10px;
    right: 10px;
  }

  .chat-section {
    max-width: 100%;
    min-width: auto;
    flex: 1;
  }

  .landing-content h2 {
    font-size: 1.5rem;
  }

  .stats {
    gap: 1.5rem;
  }

  .header {
    padding: 0.5rem 1rem;
  }
}

@media (max-width: 600px) {
  .video-section {
    height: 40%;
  }

  .video-pip-container {
    width: 100px;
    height: 75px;
    bottom: 8px;
    right: 8px;
  }

  .chat-section {
    min-width: auto;
  }

  .controls {
    flex-wrap: wrap;
    gap: 0.4rem;
    height: auto;
    padding: 0.5rem;
  }

  .btn-next {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
  }

  .btn-stop {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }
}
