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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 12px;
  color: #333;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.sender-container {
  max-width: 600px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.sender-header {
  margin-bottom: 20px;
}

.sender-header > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

h1 {
  color: #667eea;
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

h2 {
  color: #fff;
  margin: 0 0 8px 0;
  font-size: 24px;
}

h3 {
  color: #666;
  margin-bottom: 10px;
}

.server-badge {
  display: inline-block;
  padding: 4px 10px;
  background: #e7f3ff;
  color: #667eea;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #666;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mode-selection {
  margin-bottom: 30px;
}

.button-group {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.btn {
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #5568d3;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #5a6268;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #c82333;
}

.btn:disabled {
  background: #e0e0e0;
  color: #999;
  cursor: not-allowed;
  transform: none;
  opacity: 0.6;
}

.btn.active {
  background: #28a745 !important;
  box-shadow: 0 0 20px rgba(40, 167, 69, 0.5);
  transform: scale(1.02);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(40, 167, 69, 0.5); }
  50% { box-shadow: 0 0 30px rgba(40, 167, 69, 0.8); }
}

.btn-large {
  width: 100%;
  padding: 16px 24px;
  font-size: 18px;
}

.btn-icon {
  padding: 12px 16px;
  font-size: 20px;
  min-width: 48px;
}

.btn-record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
  min-height: 56px;
}

.btn-icon-mic {
  font-size: 24px;
}

.btn-stop {
  min-height: 56px;
}

.btn-back {
  padding: 8px 16px;
  background: #f8f9fa;
  color: #667eea;
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.3s ease;
}

.btn-back:hover {
  background: #e9ecef;
}

.status-panel {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: space-around;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  flex: 1;
  min-width: 100px;
}

.label {
  font-weight: 600;
  color: #888;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status {
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  background: #e9ecef;
  color: #666;
}

.status.connected {
  background: #d4edda;
  color: #155724;
}

.status.active {
  background: #d1ecf1;
  color: #0c5460;
}

.mode-toggle {
  margin-bottom: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 2px solid #e9ecef;
}

.toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  cursor: pointer;
}

.toggle-text {
  font-size: 16px;
  color: #555;
  font-weight: 500;
}

.toggle-info {
  margin: 10px 0 0 30px;
  font-size: 13px;
  color: #777;
  line-height: 1.4;
}

/* Modern Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 12px 0;
  position: relative;
}

.toggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  background: #ccc;
  border-radius: 14px;
  transition: background 0.3s ease;
  margin-right: 12px;
  flex-shrink: 0;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: #667eea;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-label-text {
  font-size: 15px;
  color: #444;
  font-weight: 500;
}

.toggle-container {
  margin-bottom: 12px;
}

.setting-description {
  font-size: 13px;
  color: #777;
  margin: 6px 0 0 60px;
  line-height: 1.4;
}

.control-panel {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.font-size-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 20px;
}

.font-size-controls label {
  color: #666;
  font-size: 16px;
}

#fontSizeSlider {
  flex: 1;
  min-width: 150px;
  height: 6px;
  border-radius: 3px;
  background: #e9ecef;
  outline: none;
  cursor: pointer;
}

#fontSizeSlider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  transition: all 0.2s ease;
}

#fontSizeSlider::-webkit-slider-thumb:hover {
  background: #5568d3;
  transform: scale(1.1);
}

#fontSizeSlider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

#fontSizeSlider::-moz-range-thumb:hover {
  background: #5568d3;
  transform: scale(1.1);
}

#fontSizeValue {
  font-weight: 600;
  color: #667eea;
  min-width: 50px;
  text-align: right;
}

.input-field {
  flex: 1;
  min-width: 200px;
  padding: 14px 16px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.2s ease;
  background: #fafafa;
}

.input-field:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.connection-section,
.recording-section,
.transcription-section,
.settings-section {
  margin-bottom: 24px;
  padding: 20px;
  background: #fafafa;
  border-radius: 12px;
}

.connection-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.connection-input {
  flex: 1;
}

.recording-controls {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.info-card {
  background: #e7f3ff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 20px;
}

.info-item {
  color: #555;
  font-size: 14px;
  line-height: 1.8;
  padding: 4px 0;
}

.info-item strong {
  color: #667eea;
}

.transcription-panel {
  margin-bottom: 20px;
  position: relative;
}

/* Fullscreen styles */
.transcription-panel:fullscreen {
  background: white;
  padding: 40px;
  display: flex;
  flex-direction: column;
}

.transcription-panel:-webkit-full-screen {
  background: white;
  padding: 40px;
  display: flex;
  flex-direction: column;
}

.transcription-panel:-moz-full-screen {
  background: white;
  padding: 40px;
  display: flex;
  flex-direction: column;
}

.transcription-panel:-ms-fullscreen {
  background: white;
  padding: 40px;
  display: flex;
  flex-direction: column;
}

/* Make the output box fill the screen in fullscreen mode */
.transcription-panel:fullscreen .output-box,
.transcription-panel:-webkit-full-screen .output-box,
.transcription-panel:-moz-full-screen .output-box,
.transcription-panel:-ms-fullscreen .output-box {
  max-height: none;
  height: 100%;
  flex: 1;
  font-size: inherit;
}

/* Hide the h3 title in fullscreen for more space */
.transcription-panel:fullscreen h3,
.transcription-panel:-webkit-full-screen h3,
.transcription-panel:-moz-full-screen h3,
.transcription-panel:-ms-fullscreen h3 {
  display: none;
}

.output-box {
  min-height: 250px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  background: white;
  border-radius: 12px;
  border: 2px solid #e9ecef;
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.output-box:empty::before {
  content: 'Transcription will appear here...';
  color: #bbb;
  font-style: italic;
  font-size: 14px;
}

.info {
  margin-top: 30px;
  padding: 20px;
  background: #e7f3ff;
  border-left: 4px solid #667eea;
  border-radius: 6px;
}

.info ul {
  margin-left: 20px;
  margin-top: 10px;
}

.info li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.info-box {
  padding: 15px;
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  border-radius: 6px;
  margin-top: 20px;
}

.info-box p {
  color: #856404;
  line-height: 1.5;
}

.transcript-line {
  margin-bottom: 10px;
  padding: 8px;
  background: white;
  border-radius: 4px;
  border-left: 3px solid #667eea;
}

.sender-name {
  font-weight: 700;
  color: #667eea;
  margin-right: 8px;
}

.transcript-line.interim {
  opacity: 0.6;
  border-left-color: #ccc;
}

.transcript-line.deduplicated {
  background: #fff3e0;
  border-left-color: #ff9800;
  position: relative;
}

.transcript-line.deduplicated::before {
  content: '🔗';
  position: absolute;
  right: 10px;
  top: 8px;
  font-size: 16px;
  opacity: 0.7;
}

.transcript-line.deduplicated .sender-name {
  color: #ff9800;
}

.timestamp {
  font-size: 12px;
  color: #999;
  margin-right: 10px;
}

/* Audio Level Meter */
.audio-level-meter {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 2px solid #e9ecef;
}

.audio-level-label {
  font-weight: 600;
  color: #666;
  font-size: 14px;
  min-width: 80px;
}

.audio-level-bar-container {
  flex: 1;
  height: 24px;
  background: #e9ecef;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.audio-level-bar {
  height: 100%;
  background: linear-gradient(90deg, #28a745 0%, #ffc107 70%, #dc3545 100%);
  width: 0%;
  transition: width 0.1s ease;
  border-radius: 12px;
}

.audio-level-value {
  font-weight: 700;
  color: #667eea;
  min-width: 50px;
  text-align: right;
  font-size: 16px;
}

/* QR Scanner Modal */
.qr-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
}

.qr-modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.btn-close-qr {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1001;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.btn-close-qr:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.qr-header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

.qr-header h2 {
  font-size: 28px;
  margin-bottom: 8px;
}

.qr-header p {
  font-size: 16px;
  opacity: 0.9;
}

.qr-video-container {
  position: relative;
  max-width: 500px;
  width: 90%;
}

#qrVideo {
  width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#qrCanvas {
  display: none;
}

.qr-status {
  margin-top: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: white;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.3s ease;
}

/* Mobile Responsive Styles */
@media (max-width: 600px) {
  body {
    padding: 8px;
  }

  .container {
    padding: 16px;
    border-radius: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .header {
    margin-bottom: 16px;
  }

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

  .btn {
    width: 100%;
  }

  .control-panel {
    flex-direction: column;
  }

  .input-field {
    width: 100%;
  }

  .status-panel {
    gap: 8px;
    padding: 12px;
  }

  .status-item {
    min-width: 80px;
  }

  .connection-section,
  .recording-section,
  .transcription-section,
  .settings-section {
    padding: 16px;
    margin-bottom: 16px;
  }

  .recording-controls {
    flex-direction: column;
  }

  .btn-stop {
    width: 100%;
  }

  .output-box {
    min-height: 200px;
    max-height: 300px;
    font-size: 15px;
  }

  .qr-header h2 {
    font-size: 24px;
  }

  .qr-header p {
    font-size: 14px;
  }

  .btn-close-qr {
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
  }
}

/* Landscape mobile optimization */
@media (max-width: 900px) and (orientation: landscape) {
  .output-box {
    max-height: 200px;
  }

  .qr-modal-content {
    padding: 10px;
  }

  .qr-header {
    margin-bottom: 15px;
  }

  .qr-header h2 {
    font-size: 20px;
  }
}

/* Audio Controls Panel */
.audio-controls-panel {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  border: 2px solid #e9ecef;
}

.audio-controls-panel h3 {
  margin-bottom: 15px;
  color: #667eea;
}

.audio-controls-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.audio-control-item {
  background: white;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.audio-sender-label {
  font-weight: 600;
  color: #667eea;
  min-width: 150px;
  font-size: 14px;
}

.audio-volume-label {
  font-size: 14px;
  color: #666;
  margin-left: auto;
}

.audio-volume-slider {
  width: 150px;
  height: 6px;
  border-radius: 3px;
  background: #e9ecef;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.audio-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  transition: all 0.2s ease;
}

.audio-volume-slider::-webkit-slider-thumb:hover {
  background: #764ba2;
  transform: scale(1.2);
}

.audio-volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.audio-volume-slider::-moz-range-thumb:hover {
  background: #764ba2;
  transform: scale(1.2);
}

.audio-volume-value {
  font-size: 14px;
  color: #666;
  min-width: 40px;
  font-weight: 600;
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 8px;
}

/* Mobile responsive audio controls */
@media (max-width: 600px) {
  .audio-control-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .audio-sender-label {
    min-width: auto;
  }

  .audio-volume-label {
    margin-left: 0;
  }

  .audio-volume-slider {
    width: 100%;
  }
}
