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

html,
body {
  height: 100%;
  background: #0a0a0a;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.02em;
}

.subtitle {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #666;
}

.audio-publish-section {
  width: 100%;
  max-width: 1280px;
  margin-bottom: 24px;
  padding: 16px;
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
}

.section-head {
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
}

.section-desc {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #666;
  line-height: 1.5;
}

.audio-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.control-label {
  font-size: 0.85rem;
  color: #888;
}

.audio-select {
  min-width: 180px;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: #e0e0e0;
  background: #141414;
  border: 1px solid #333;
  border-radius: 8px;
  outline: none;
}

.audio-select:focus {
  border-color: #5cb85c;
}

.btn-start,
.btn-stop,
.btn-copy,
.btn-play-audio {
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn-start {
  color: #fff;
  background: #2d6a2d;
}

.btn-start:hover:not(:disabled) {
  background: #3a853a;
}

.btn-stop {
  color: #fff;
  background: #8b3a3a;
}

.btn-stop:hover:not(:disabled) {
  background: #a04545;
}

.btn-start:disabled,
.btn-stop:disabled,
.audio-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-copy,
.btn-play-audio {
  color: #ccc;
  background: #1a1a1a;
  border: 1px solid #333;
}

.btn-copy:hover,
.btn-play-audio:hover {
  color: #fff;
  border-color: #555;
}

.audio-info-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.info-item-wide {
  flex: 1;
  flex-wrap: wrap;
}

.info-item .label {
  font-size: 0.75rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.info-item .value {
  font-size: 0.9rem;
  font-weight: 500;
}

.audio-status-idle {
  color: #888;
}

.audio-status-connecting {
  color: #f0ad4e;
}

.audio-status-live {
  color: #5cb85c;
}

.audio-status-error {
  color: #d9534f;
}

.rtsp-url {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  font-size: 0.82rem;
  color: #9fd49f;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  word-break: break-all;
}

.audio-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #777;
  line-height: 1.4;
  min-height: 1.2em;
}

.add-stream-bar {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 1280px;
  margin-bottom: 20px;
}

.whep-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #e0e0e0;
  background: #141414;
  border: 1px solid #333;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.whep-input:focus {
  border-color: #5cb85c;
}

.whep-input::placeholder {
  color: #555;
}

.btn-add {
  flex-shrink: 0;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  background: #2d6a2d;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-add:hover {
  background: #3a853a;
}

.btn-add:active {
  background: #245824;
}

.stream-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1280px;
  align-content: start;
}

.stream-grid:empty::after {
  content: "输入 WHEP 地址后点击「添加视频」";
  display: block;
  padding: 48px 24px;
  text-align: center;
  color: #555;
  font-size: 0.95rem;
  background: #111;
  border: 1px dashed #333;
  border-radius: 8px;
}

.stream-card {
  display: flex;
  flex-direction: column;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  border: 1px solid #222;
}

.stream-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #141414;
  border-bottom: 1px solid #222;
}

.stream-label {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  color: #888;
  background: transparent;
  border: 1px solid #333;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-close:hover {
  color: #fff;
  border-color: #d9534f;
  background: rgba(217, 83, 79, 0.15);
}

.video-container {
  position: relative;
  width: 100%;
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-container.audio-only {
  aspect-ratio: auto;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #141414;
}

.video-container.audio-only::before {
  content: "♪ 音频流";
  position: absolute;
  font-size: 0.9rem;
  color: #555;
  pointer-events: none;
}

.video-container.audio-only video {
  height: 0;
  overflow: hidden;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  transition: opacity 0.3s;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-text {
  font-size: 0.95rem;
  color: #aaa;
  letter-spacing: 0.05em;
}

.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  opacity: 0;
  transition: opacity 0.2s;
}

.video-container:hover .player-controls,
.video-container:focus-within .player-controls,
.video-container.is-fullscreen .player-controls {
  opacity: 1;
}

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

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
}

.ctrl-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.ctrl-volume {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ctrl-volume-slider {
  flex: 1;
  min-width: 60px;
  max-width: 120px;
  height: 4px;
  accent-color: #5cb85c;
  cursor: pointer;
}

.video-container.is-fullscreen {
  aspect-ratio: auto;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
}

.video-container.is-fullscreen video {
  width: 100%;
  height: 100%;
}

.video-container.audio-only .player-controls {
  position: relative;
  opacity: 1;
  background: #141414;
  border-top: 1px solid #222;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 10px 12px;
  background: #141414;
  border-top: 1px solid #222;
}

.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  padding: 2px 8px;
}

.status-item .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-bottom: 2px;
}

.status-item .value {
  font-size: 0.85rem;
  font-weight: 500;
  color: #ccc;
  font-variant-numeric: tabular-nums;
}

.status-connecting {
  color: #f0ad4e !important;
}

.status-connected {
  color: #5cb85c !important;
}

.status-disconnected {
  color: #d9534f !important;
}

.footer {
  margin-top: 20px;
  font-size: 0.75rem;
  color: #444;
}

@media (max-width: 600px) {
  .header h1 {
    font-size: 1.2rem;
  }

  .audio-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .audio-select,
  .btn-start,
  .btn-stop {
    width: 100%;
  }

  .info-item-wide {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-copy,
  .btn-play-audio {
    width: 100%;
  }

  .add-stream-bar {
    flex-direction: column;
  }

  .btn-add {
    width: 100%;
  }

  .status-item {
    min-width: 60px;
    padding: 2px 6px;
  }
}
