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

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
}

.portal-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
  overflow: hidden;
}

/* Avatar Section */
.avatar-section {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  padding: 10px 20px 20px 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

#avatarCanvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.emotion-indicator {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #667eea;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#emotionLabel {
  display: inline-block;
}

/* Controls Section */
.controls-section {
  flex: 0 0 auto;
  background: white;
  padding: 20px;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  max-height: 50vh;
  overflow-y: auto;
}

.control-group {
  margin-bottom: 16px;
}

.control-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #667eea;
  text-transform: uppercase;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

/* Buttons */
.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 100px;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon {
  font-size: 16px;
}

/* Emotion Buttons */
.emotion-buttons {
  gap: 8px;
}

.emotion-btn {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  background: white;
  color: #333;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 80px;
}

.emotion-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.emotion-btn.active {
  border-color: #667eea;
  background: #667eea;
  color: white;
}

/* Text Input */
#textInput {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.3s ease;
}

#textInput:focus {
  outline: none;
  border-color: #667eea;
}

/* Transcript */
.transcript {
  background: #f9f9f9;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  min-height: 40px;
  font-size: 13px;
  color: #666;
}

.transcript.has-content {
  background: #f0f2ff;
  border-color: #667eea;
  color: #333;
}

/* Status */
.status {
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  min-height: 20px;
  display: none;
}

.status.show {
  display: block;
}

.status.info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.status.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

/* Responsive Design */
@media (min-width: 768px) {
  .portal-container {
    flex-direction: row;
  }

  .avatar-section {
    flex: 1;
    border-radius: 0;
  }

  .controls-section {
    flex: 0 0 400px;
    border-radius: 0;
    max-height: 100vh;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
  }

  .emotion-btn {
    min-width: auto;
  }

  .button-group.action-buttons {
    flex-direction: column;
  }

  .btn {
    min-width: auto;
  }
}

@media (max-width: 480px) {
  .portal-container {
    gap: 0;
  }

  .controls-section {
    padding: 16px;
  }

  .btn {
    padding: 10px 12px;
    font-size: 13px;
    min-width: 80px;
  }

  .emotion-btn {
    padding: 8px 10px;
    font-size: 12px;
    min-width: 70px;
  }

  .emotion-indicator {
    bottom: 10px;
    left: 10px;
    font-size: 12px;
    padding: 6px 12px;
  }

  .avatar-section {
    padding: 10px;
  }
}

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

.btn-recording {
  animation: spin 2s linear infinite;
}

/* Combined Camera + Vision Box */
.camera-vision-box {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 140px;
  border: 2px solid #00ff00;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 4px 20px rgba(0, 255, 0, 0.4);
  z-index: 9999;
}

.camera-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-label {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(0, 0, 0, 0.7);
  color: #00ff00;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  pointer-events: none;
}

/* Status Indicator - Professional, subtle */
.status-indicator {
  position: fixed;
  top: 10px;
  right: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #00ff00;
  box-shadow: 0 0 8px #00ff00;
  z-index: 1000;
}

/* Emotion Detection Panel */
.emotion-detection {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid #e0e0e0;
}

.emotion-bar {
  display: grid;
  grid-template-columns: 70px 1fr 50px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.emotion-bar:last-child {
  margin-bottom: 0;
}

.emotion-name {
  font-weight: 500;
  color: #333;
  text-align: right;
}

.emotion-bar-fill {
  height: 20px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.emotion-bar-value {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.emotion-score {
  font-weight: 600;
  color: #667eea;
  text-align: right;
  min-width: 40px;
}

/* Active camera button */
.btn-active {
  background: #4caf50 !important;
  color: white !important;
}

/* Demo Mode Indicator */
body.demo-mode::before {
  content: '🚀 DEMO MODE';
  position: fixed;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  background: #ff6b00;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
  z-index: 999999;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.latency{font-size:12px;color:#fff;background:#000000cc;padding:4px 8px;border-radius:6px;display:inline-block;margin:6px 0}
