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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  padding: 20px 0;
  border-bottom: 1px solid #1a1a2e;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.header h1 span {
  color: #4ecdc4;
}

.header p {
  color: #888;
  font-size: 0.95rem;
  margin-top: 4px;
}

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  background: #12121e;
  border-radius: 12px;
  margin-bottom: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
  transition: background 0.3s;
}

.status-dot.connected {
  background: #4ecdc4;
  box-shadow: 0 0 8px #4ecdc466;
}

.status-dot.listening {
  background: #f7b731;
  animation: pulse 1.5s infinite;
}

.status-dot.speaking {
  background: #4ecdc4;
  animation: pulse 0.8s infinite;
}

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

.status-text {
  font-size: 0.9rem;
  color: #aaa;
  flex: 1;
}

/* Connection Quality Indicator */
.connection-quality {
  display: flex;
  gap: 3px;
  align-items: center;
}

.quality-dot {
  width: 6px;
  border-radius: 2px;
  background: #333;
  transition: background 0.3s;
}

.quality-dot:nth-child(1) { height: 8px; }
.quality-dot:nth-child(2) { height: 12px; }
.quality-dot:nth-child(3) { height: 16px; }

.quality-dot.good {
  background: #4ecdc4;
}

/* Hazard Alert Banner */
.hazard-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  margin-bottom: 0;
  background: transparent;
  border-radius: 12px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.hazard-banner.visible {
  max-height: 60px;
  opacity: 1;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.hazard-banner.critical {
  background: #ff4444;
  color: #fff;
  animation: bannerPulse 0.5s ease 3;
}

.hazard-banner.warning {
  background: #ff9800;
  color: #000;
}

.hazard-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.hazard-text {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}

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

/* Camera Section */
.camera-section {
  position: relative;
  margin-bottom: 12px;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  aspect-ratio: 16/9;
  border: 3px solid transparent;
  transition: border-color 0.2s;
}

.camera-section.hazard-flash {
  border-color: #ff4444;
  animation: hazardBorder 0.4s ease 4;
}

@keyframes hazardBorder {
  0%, 100% { border-color: #ff4444; box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); }
  50% { border-color: #ff0000; box-shadow: 0 0 20px 4px rgba(255, 68, 68, 0.4); }
}

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

.camera-section canvas {
  display: none;
}

.camera-overlay {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.camera-badge {
  background: #000000aa;
  color: #4ecdc4;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.mode-badge {
  background: #000000aa;
  color: #f7b731;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Orientation Guidance Bar */
.orientation-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  margin-bottom: 0;
  background: transparent;
  border-radius: 10px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.orientation-bar.visible {
  max-height: 44px;
  opacity: 1;
  padding: 8px 16px;
  margin-bottom: 8px;
}

.orientation-bar.good {
  background: #1a2a2e;
}

.orientation-bar.warning {
  background: #2a2000;
  border: 1px solid #f7b73144;
  animation: orientPulse 2s ease-in-out infinite;
}

.orientation-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.orientation-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: #aaa;
}

.orientation-bar.warning .orientation-text {
  color: #f7b731;
}

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

/* Mode Switcher */
.mode-switcher {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
  padding: 6px;
  background: #12121e;
  border-radius: 14px;
}

.mode-btn {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #888;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mode-btn:hover {
  color: #ccc;
  background: #1a1a2e;
}

.mode-btn.active {
  color: #4ecdc4;
  background: #1a2a2e;
  border-color: #4ecdc433;
}

.mode-icon {
  font-size: 1rem;
}

/* Language Bar */
.language-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.lang-label {
  font-size: 0.85rem;
  color: #888;
  font-weight: 500;
}

.lang-select {
  padding: 8px 12px;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  background: #12121e;
  color: #e0e0e0;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.lang-select:focus {
  border-color: #4ecdc4;
}

.lang-select option {
  background: #12121e;
  color: #e0e0e0;
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.btn {
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #4ecdc4;
  color: #0a0a0f;
}

.btn-primary:hover {
  background: #45b7b0;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #2a2a3a;
  color: #555;
  cursor: not-allowed;
  transform: none;
}

.btn-danger {
  background: #ff6b6b;
  color: #fff;
}

.btn-danger:hover {
  background: #ee5a5a;
}

.btn-danger:disabled {
  background: #2a2a3a;
  color: #555;
  cursor: not-allowed;
}

/* Calibrate Button */
.btn-calibrate {
  background: #2a2a3a;
  color: #f7b731;
  border: 1px solid #f7b73144;
}

.btn-calibrate:hover {
  background: #3a3a4a;
  border-color: #f7b731;
}

/* Calibration Toast */
.calibration-toast {
  text-align: center;
  padding: 0;
  margin: 0;
  background: #1a2a00;
  border: 1px solid #4ecdc444;
  border-radius: 10px;
  font-size: 0.85rem;
  color: #4ecdc4;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.calibration-toast.visible {
  max-height: 50px;
  opacity: 1;
  padding: 10px 16px;
  margin-bottom: 12px;
}

/* Emergency SOS Button */
.sos-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  margin-bottom: 16px;
  border: 2px solid #ff444444;
  border-radius: 14px;
  background: #1a0a0a;
  color: #ff6b6b;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

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

.sos-btn:not(:disabled):hover {
  background: #2a0a0a;
  border-color: #ff4444;
}

.sos-btn:not(:disabled):active {
  transform: scale(0.98);
}

.sos-btn.active {
  background: #ff4444;
  color: #fff;
  border-color: #ff4444;
  animation: sosPulse 1s ease-in-out infinite;
}

.sos-icon {
  font-size: 1.3rem;
}

.sos-text {
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.sos-hint {
  font-size: 0.7rem;
  font-weight: 400;
  color: #ff6b6b88;
  position: absolute;
  bottom: 4px;
  right: 12px;
}

.sos-btn.active .sos-hint {
  color: #ffffffaa;
}

@keyframes sosPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.4); }
  50% { box-shadow: 0 0 20px 8px rgba(255, 68, 68, 0.2); }
}

/* SOS Location Banner */
.sos-location {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: #1a1000;
  border: 1px solid #f7b73144;
  border-radius: 10px;
  font-size: 0.8rem;
  color: #f7b731;
}

.sos-location.visible {
  display: flex;
}

.sos-location-text {
  flex: 1;
}

/* Audio Visualizer */
.visualizer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 30px;
  margin-bottom: 20px;
}

.visualizer-bar {
  width: 4px;
  height: 4px;
  background: #4ecdc4;
  border-radius: 2px;
  transition: height 0.1s;
}

.visualizer.active .visualizer-bar {
  animation: visualize 0.5s ease-in-out infinite alternate;
}

.visualizer.active .visualizer-bar:nth-child(1) { animation-delay: 0s; }
.visualizer.active .visualizer-bar:nth-child(2) { animation-delay: 0.1s; }
.visualizer.active .visualizer-bar:nth-child(3) { animation-delay: 0.2s; }
.visualizer.active .visualizer-bar:nth-child(4) { animation-delay: 0.15s; }
.visualizer.active .visualizer-bar:nth-child(5) { animation-delay: 0.05s; }

@keyframes visualize {
  from { height: 4px; }
  to { height: 24px; }
}

/* Transcript */
.transcript-section {
  background: #12121e;
  border-radius: 16px;
  padding: 20px;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
}

.transcript-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  margin-bottom: 12px;
}

.transcript-entry {
  padding: 8px 0;
  border-bottom: 1px solid #1a1a2e;
  font-size: 0.95rem;
  line-height: 1.5;
}

.transcript-entry:last-child {
  border-bottom: none;
}

.transcript-entry.agent {
  color: #4ecdc4;
}

.transcript-entry.user {
  color: #f7b731;
}

/* Hazard-level transcript coloring */
.transcript-entry.hazard-critical {
  color: #ff4444;
  font-weight: 600;
}

.transcript-entry.hazard-warning {
  color: #ff9800;
}

.transcript-empty {
  color: #444;
  text-align: center;
  padding: 40px 0;
  font-size: 0.95rem;
}

/* Scrollbar */
.transcript-section::-webkit-scrollbar {
  width: 6px;
}
.transcript-section::-webkit-scrollbar-track {
  background: transparent;
}
.transcript-section::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 12px;
  }
  .header h1 {
    font-size: 1.5rem;
  }
  .btn {
    padding: 12px 24px;
    font-size: 0.9rem;
  }
  .mode-btn {
    padding: 8px 6px;
    font-size: 0.78rem;
  }
  .mode-icon {
    font-size: 0.9rem;
  }
}
