/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #F8F8F8;
  color: #111;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
}

/* === Mode Banner === */
#mode-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 100;
}

#mode-banner.es {
  background: #E67E22;
}

#mode-banner.en {
  background: #2980B9;
}

/* === Header === */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-top: 4px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Status dot */
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  background: #999;
  flex-shrink: 0;
}

.status-dot.listening {
  background: #27AE60;
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.paused {
  background: #E74C3C;
  animation: none;
}

.status-dot.connecting {
  background: #F39C12;
  animation: pulse 0.8s ease-in-out infinite;
}

.status-dot.error {
  background: #E74C3C;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

#status-label {
  font-size: 14px;
  color: #555;
  font-weight: 500;
}

/* Mic selector */
.mic-label {
  font-size: 13px;
  color: #777;
}

#mic-select {
  font-size: 13px;
  max-width: 200px;
  padding: 4px 8px;
  border: 1px solid #CCC;
  border-radius: 6px;
  background: #FFF;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Audio Level Meter === */
#level-meter-container {
  width: 100%;
  height: 4px;
  background: #E0E0E0;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

#level-meter {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #27AE60, #2ECC71);
  border-radius: 2px;
  transition: width 80ms ease-out;
}

/* === Error Banner === */
#error-banner {
  background: #E74C3C;
  color: #FFF;
  padding: 10px 16px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

#error-banner.hidden {
  display: none;
}

/* === Transcript Area === */
#transcript-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  -webkit-overflow-scrolling: touch;
}

/* Utterance block */
.utterance {
  margin-bottom: 24px;
}

.utterance-original {
  font-size: 24px;
  color: #666;
  line-height: 1.4;
  margin-bottom: 4px;
}

.utterance-translated {
  font-size: 28px;
  font-weight: 600;
  color: #111;
  line-height: 1.4;
  border-left: 3px solid #DDD;
  padding-left: 12px;
}

/* Interim (partial) text */
.utterance-interim {
  font-size: 24px;
  color: #999;
  font-style: italic;
  line-height: 1.4;
}

/* Translation pending indicator */
.utterance-translating {
  font-size: 20px;
  color: #BBB;
  font-style: italic;
  padding-left: 15px;
}

.utterance-translating::after {
  content: '';
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* Translation error fallback */
.utterance-translation-error {
  font-size: 22px;
  color: #CCC;
  font-style: italic;
  padding-left: 15px;
}

/* === Jump to Latest Button === */
#jump-to-latest {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: #333;
  color: #FFF;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#jump-to-latest.hidden {
  display: none;
}

#jump-to-latest:active {
  background: #555;
}

/* === Controls === */
#controls {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  flex-shrink: 0;
}

.control-btn {
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.15s ease, opacity 0.15s ease;
}

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

.pause-btn {
  flex: 2;
  height: 60px;
  color: #FFF;
}

.pause-btn.listening {
  background: #27AE60;
}

.pause-btn.listening:active:not(:disabled) {
  background: #1E8449;
}

.pause-btn.paused {
  background: #E74C3C;
}

.pause-btn.paused:active:not(:disabled) {
  background: #C0392B;
}

.clear-btn {
  flex: 1;
  height: 60px;
  background: #ECF0F1;
  color: #555;
}

.clear-btn:active:not(:disabled) {
  background: #D5DBDB;
}

/* === Mode Indicator === */
#mode-indicator {
  text-align: center;
  font-size: 13px;
  color: #999;
  padding: 8px 0 12px;
  flex-shrink: 0;
}

/* === Utility === */
.hidden {
  display: none !important;
}

/* === Responsive: Tablet (481-768px) === */
@media (max-width: 768px) {
  body {
    max-width: 100%;
    padding: 0 12px;
  }

  .pause-btn, .clear-btn {
    height: 64px;
    font-size: 20px;
    min-height: 44px;
  }

  #mic-select {
    max-width: 160px;
  }
}

/* === Responsive: Phone (<480px) === */
@media (max-width: 480px) {
  body {
    padding: 0 8px;
  }

  #header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .header-right {
    width: 100%;
  }

  #mic-select {
    flex: 1;
    max-width: none;
  }

  #controls {
    flex-direction: column;
    gap: 8px;
  }

  .pause-btn, .clear-btn {
    width: 100%;
    min-height: 44px;
  }

  .utterance-original {
    font-size: 20px;
  }

  .utterance-translated {
    font-size: 24px;
  }

  .utterance-interim {
    font-size: 20px;
  }
}
