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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #0d0000 0%, #4a0000 50%, #2a0000 100%);
  color: #ffffff;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.container {
  width: 100%;
  max-width: 1400px;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.4rem;
}

.subtitle {
  color: #ffcdd2;
  font-size: 1rem;
}

/* Language selectors */
.controls {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.language-selector {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.language-selector label {
  font-size: 0.85rem;
  color: #ffcdd2;
  font-weight: 500;
}

.language-selector select {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1rem;
  min-width: 160px;
  width: 100%;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.language-selector select:focus {
  border-color: #ef9a9a;
}

.language-selector select option {
  background: #8B0000;
  color: #fff;
}

.swap-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.4rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.swap-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Mic button */
.mic-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.5rem;
}

.mic-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 2rem;
  border-radius: 40px;
  border: none;
  background: #b71c1c;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.mic-btn:hover {
  background: #9a0007;
  box-shadow: 0 4px 20px rgba(183, 28, 28, 0.4);
}

.mic-btn.recording {
  background: #d32f2f;
  animation: pulse 1.5s infinite;
}

.mic-btn.recording:hover {
  background: #c62828;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(211, 47, 47, 0); }
}

.mic-icon {
  flex-shrink: 0;
}

.status {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: #ffcdd2;
  min-height: 1.2em;
}

/* Text size selector */
.text-size-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.text-size-label {
  font-size: 0.8rem;
  color: #ffcdd2;
  margin-right: 0.2rem;
}

.text-size-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffcdd2;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.text-size-btn:hover {
  background: rgba(239, 154, 154, 0.2);
  color: #fff;
}

.text-size-btn.active {
  background: rgba(239, 154, 154, 0.3);
  border-color: #ef9a9a;
  color: #fff;
}

/* Text size classes */
.transcript-content.size-small { font-size: 0.8rem; }
.transcript-content.size-normal { font-size: 0.95rem; }
.transcript-content.size-large { font-size: 1.25rem; }
.transcript-content.size-vlarge { font-size: 1.6rem; }
.transcript-content.size-vvlarge { font-size: 2.2rem; }
.transcript-content.size-vvvlarge { font-size: 3rem; }

/* Transcript panels */
.transcript-area {
  display: grid;
  grid-template-columns: 1fr 6px 1fr;
  gap: 0;
}

/* Tablet */
@media (max-width: 900px) {
  body {
    padding: 1rem 0.75rem;
  }
  .controls {
    gap: 0.6rem;
    margin-bottom: 1.25rem;
  }
  .mic-section {
    margin-bottom: 1.25rem;
  }
  .transcript-panel {
    height: 55vh;
  }
}

/* Mobile */
@media (max-width: 640px) {
  body {
    padding: 0.75rem 0.5rem;
  }
  .container {
    width: 100%;
  }
  .controls {
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  .language-selector {
    width: calc(50% - 2rem);
  }
  .language-selector select {
    min-width: unset;
    width: 100%;
    font-size: 0.9rem;
    padding: 0.5rem 0.6rem;
  }
  .mic-section {
    margin-bottom: 1rem;
  }
  .mic-btn {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
  }
  .transcript-area {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .resize-handle {
    display: none;
  }
  .transcript-panel {
    height: 45vh;
  }
  .text-size-group {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .language-selector {
    width: 100%;
  }
  .controls {
    flex-direction: column;
    align-items: center;
  }
  .swap-btn {
    transform: rotate(90deg);
  }
  .transcript-panel {
    height: 40vh;
  }
}

/* Resize handle */
.resize-handle {
  width: 6px;
  cursor: col-resize;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  transition: background 0.2s;
  position: relative;
}

.resize-handle:hover,
.resize-handle.dragging {
  background: rgba(239, 154, 154, 0.5);
}

.resize-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 30px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
}

/* Panel header with pop-out button */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ef9a9a;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.popout-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffcdd2;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.popout-btn:hover {
  background: rgba(239, 154, 154, 0.25);
  color: #fff;
}

.transcript-panel.popped-out .transcript-content {
  opacity: 0.3;
  position: relative;
}

.popout-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  align-items: center;
  justify-content: center;
  color: #ffcdd2;
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  z-index: 1;
}

.transcript-panel.popped-out .popout-overlay {
  display: flex;
}

.transcript-panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1rem;
  height: 65vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.transcript-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  word-wrap: break-word;
}

/* Speaker segments */
.speaker-segment {
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.speaker-segment:last-child {
  border-bottom: none;
}

.speaker-segment.nonfinal {
  opacity: 0.5;
}

.speaker-segment.seg-original .seg-text {
  color: #fff;
  font-weight: 600;
  background: rgba(239, 154, 154, 0.15);
  border-left: 3px solid #ef9a9a;
  padding-left: 0.5rem;
  border-radius: 0 4px 4px 0;
}

.speaker-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #ffcdd2;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.seg-text {
  color: #ffffff;
  margin-bottom: 0.3rem;
  line-height: 1.6;
}

.seg-translation {
  color: #ffffff;
  line-height: 1.6;
}

.lang-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.lang-badge.badge-translation {
  background: rgba(129, 199, 132, 0.15);
  color: #81c784;
}
