:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a26;
  --surface3: #22222f;
  --border: #2a2a3a;
  --border-glow: #3a3a5a;
  --text: #e0e0ec;
  --text-dim: #8888a0;
  --text-muted: #555568;
  --accent: #00e5a0;
  --accent-dim: #00e5a033;
  --accent2: #00b8ff;
  --accent2-dim: #00b8ff22;
  --danger: #ff4466;
  --warning: #ffaa22;
  --radius: 10px;
  --radius-lg: 16px;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Outfit', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

/* Re-enable text selection for content users would want to copy */
input, textarea,
.chat-msg,
.word-code,
.time-display,
.loaded-name,
.error-msg,
.transfer-name,
.transfer-size,
.shortcut-row kbd,
.confirm-card p,
.format-compat,
.connect-panel p,
.nickname-row label {
  user-select: text;
}

/* Background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}


.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg {
  width: 100%;
  height: 100%;
}

.logo h1 {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo h1 span {
  color: var(--accent);
}

.status-pill {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-pill.connected .dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-dot 2s infinite;
}

.status-pill.connected {
  color: var(--accent);
  border-color: var(--accent-dim);
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* Connect panel */
.connect-panel {
  background: rgba(18, 18, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(42, 42, 58, 0.6);
  border-radius: var(--radius-lg);
  padding: 36px;
  margin-bottom: 24px;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.connect-panel h2 {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.connect-panel p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.connect-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 700px) {
  .connect-grid {
    grid-template-columns: 1fr;
  }
}

.connect-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.connect-card h3 {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 16px;
}

.word-code {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
  margin: 16px 0;
  user-select: all;
  word-spacing: 6px;
}

.word-code.waiting {
  color: var(--text-muted);
  animation: blink 1.5s infinite;
  background: var(--surface3);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  border: 1px dashed var(--border);
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

.btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #00c88e 100%);
  color: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-dim);
  font-weight: 700;
}

.btn.primary:hover {
  background: linear-gradient(135deg, #00ffa8 0%, var(--accent) 100%);
  box-shadow: 0 4px 20px rgba(0, 229, 160, 0.25);
  transform: translateY(-1px);
}

.btn.primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 8px var(--accent-dim);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.join-inputs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.join-inputs input {
  flex: 1;
  font-family: var(--mono);
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.join-inputs input:focus {
  border-color: var(--accent2);
}

.join-inputs input::placeholder {
  color: var(--text-muted);
}

.error-msg {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--danger);
  margin-top: 10px;
  min-height: 18px;
}

/* Main area tabs */
.main-area {
  display: none;
}

.main-area.visible {
  display: block;
  animation: slideIn 0.5s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--surface3);
  color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: tabFadeIn 0.25s ease forwards;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* File transfer */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: var(--surface);
  margin-bottom: 20px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.drop-zone .icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.drop-zone .label {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-dim);
}

.drop-zone .label span {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.transfer-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transfer-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s, background 0.2s;
}

.transfer-item:hover {
  border-color: var(--border-glow);
  background: var(--surface2);
}

.transfer-item .file-icon {
  width: 40px;
  height: 40px;
  background: var(--surface3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.transfer-item .file-info {
  flex: 1;
  min-width: 0;
}

.transfer-item .file-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transfer-item .file-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-bar .fill.active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease infinite;
}

.transfer-item .status-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 100px;
  flex-shrink: 0;
}

.status-badge.sending {
  color: var(--accent2);
  background: var(--accent2-dim);
}

.status-badge.sending::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent2);
  margin-right: 4px;
  animation: pulse-dot 1.5s infinite;
}

.status-badge.receiving {
  color: var(--warning);
  background: #ffaa2222;
}

.status-badge.receiving::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  margin-right: 4px;
  animation: pulse-dot 1.5s infinite;
}

.status-badge.complete {
  color: var(--accent);
  background: var(--accent-dim);
}

.status-badge.error {
  color: var(--danger);
  background: #ff446622;
}

.download-btn {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.download-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Watch party */
.video-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.video-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.video-header h3 {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.sync-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-badge.synced {
  color: var(--accent);
  background: var(--accent-dim);
}

.sync-badge.syncing {
  color: var(--warning);
  background: #ffaa2222;
}

.sync-badge.no-video {
  color: var(--text-muted);
  background: var(--surface3);
}

.control-perms {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.control-perms label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: color 0.15s;
}

.control-perms label:hover {
  color: var(--text);
}

.control-perms input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  background: var(--surface3);
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  flex-shrink: 0;
}

.control-perms input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.control-perms input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.control-perms-label {
  color: var(--text-muted);
  margin-right: 2px;
}

.video-container {
  position: relative;
  background: #000;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-container video {
  width: 100%;
  height: 100%;
  display: block;
}

/* Native cue styling (for browsers where ::cue renders) */
video::cue {
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 1.15em;
  font-family: var(--sans), sans-serif;
  line-height: 1.4;
}

/* Custom subtitle overlay (JS-driven, fixes Chrome fullscreen) */
.custom-sub-overlay {
  position: absolute;
  bottom: var(--caption-bottom, 12%);
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  text-align: center;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.15s;
}

.custom-sub-overlay:empty {
  display: none;
}

.custom-sub-overlay span {
  display: inline;
  background: var(--caption-bg, rgba(0, 0, 0, 0.78));
  color: var(--caption-color, #fff);
  font-family: var(--sans), sans-serif;
  font-size: var(--caption-size, clamp(14px, 2.2vw, 22px));
  line-height: 1.6;
  padding: 3px 10px;
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.video-section.is-fullscreen {
  border: none;
  border-radius: 0;
  background: #000;
}

.video-section.is-fullscreen .video-header {
  display: none;
}

.video-section.is-fullscreen .video-container {
  height: 100%;
  aspect-ratio: auto;
}

.video-section.is-fullscreen .video-load-area {
  display: none;
}

.video-section.is-fullscreen .custom-sub-overlay {
  bottom: var(--caption-bottom-fs, 8%);
}

.video-section.is-fullscreen .custom-sub-overlay span {
  font-size: var(--caption-size, clamp(18px, 2.5vw, 32px));
}

.video-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.video-placeholder::before {
  content: '';
  position: absolute;
  inset: 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  opacity: 0.3;
  pointer-events: none;
}

.video-placeholder .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.video-placeholder p {
  font-family: var(--mono);
  font-size: 13px;
  margin-bottom: 16px;
}

.video-controls {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.video-controls .play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.video-controls .play-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.video-controls .timeline {
  width: 100%;
  height: 6px;
  background: var(--surface3);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  vertical-align: middle;
}

.video-controls .timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px var(--accent-dim);
}

.video-controls .timeline::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg,
      var(--accent) 0%,
      var(--accent) var(--progress, 0%),
      var(--surface3) var(--progress, 0%),
      var(--surface3) 100%);
}

/* Firefox timeline slider */
.video-controls .timeline::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px var(--accent-dim);
}

.video-controls .timeline::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface3);
}

.video-controls .timeline::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}

/* Volume slider */
.video-controls .volume-slider {
  width: 80px;
  height: 6px;
  background: var(--surface3);
  border-radius: 3px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  vertical-align: middle;
  flex-shrink: 0;
  background: linear-gradient(90deg,
      var(--accent2) 0%,
      var(--accent2) var(--vol-progress, 100%),
      var(--surface3) var(--vol-progress, 100%),
      var(--surface3) 100%);
}

.video-controls .volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent2);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.video-controls .volume-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
}

.video-controls .volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent2);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.video-controls .volume-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface3);
}

.video-controls .volume-slider::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent2);
}

.video-controls .time-display {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 110px;
  text-align: right;
}

.video-load-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.video-load-area .loaded-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface3);
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
}

.source-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.source-btn:hover {
  color: var(--text);
}

.source-btn.active {
  background: var(--surface);
  color: var(--accent);
}

.source-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.yt-url-input {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.yt-url-input:focus {
  border-color: var(--accent2);
}

.yt-url-input::placeholder {
  color: var(--text-muted);
}

#youtubeContainer {
  width: 100%;
  height: 100%;
  position: relative;
}

#youtubeContainer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#youtubeContainer iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.video-section:fullscreen #youtubeContainer,
.video-section:-webkit-full-screen #youtubeContainer {
  width: 100%;
  height: 100%;
}

.video-section:fullscreen #youtubeContainer iframe,
.video-section:-webkit-full-screen #youtubeContainer iframe {
  width: 100%;
  height: 100%;
}

/* Chat */
.chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 20px;
}

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-messages {
  height: 140px;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.4;
}

.chat-msg .author {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 11px;
  margin-right: 6px;
}

.chat-msg .author.you {
  color: var(--accent);
}

.chat-msg .author.peer {
  color: var(--accent2);
}

.chat-msg .author.system {
  color: var(--text-muted);
}

.chat-msg.system-msg {
  background: var(--surface2);
  border-radius: 6px;
  padding: 4px 8px;
  margin: 2px -4px;
  font-size: 12px;
  color: var(--text-dim);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.chat-input-row input {
  flex: 1;
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.chat-input-row input:focus {
  border-color: var(--accent2);
}

.chat-input-row button {
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent2);
  background: transparent;
  color: var(--accent2);
  cursor: pointer;
  transition: all 0.15s;
}

.chat-input-row button:hover {
  background: var(--accent2);
  color: var(--bg);
}

/* Disconnect bar */
.disconnect-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.disconnect-btn {
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.disconnect-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

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

@media (max-width: 600px) {
  .connect-panel {
    padding: 24px 18px;
  }

  .word-code {
    font-size: 20px;
  }

  .video-controls {
    flex-wrap: wrap;
  }
}

/* SVG icon styles */
.icon-svg {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
}


.drop-zone .icon .icon-svg {
  width: 36px;
  height: 36px;
}

.video-placeholder .icon .icon-svg {
  width: 48px;
  height: 48px;
}

.play-btn .icon-svg {
  width: 14px;
  height: 14px;
}

.file-icon .icon-svg {
  width: 20px;
  height: 20px;
}

.status-badge .icon-svg {
  width: 11px;
  height: 11px;
  vertical-align: -1px;
}

.download-btn .icon-svg {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
}

/* ===== Volume controls ===== */
.volume-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.volume-group .volume-slider {
  width: 70px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-group .volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: 1.5px solid var(--bg);
}

.volume-group .volume-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--text-dim) 0%, var(--text-dim) var(--vol-progress, 100%), var(--surface3) var(--vol-progress, 100%), var(--surface3) 100%);
}

/* Firefox volume slider */
.volume-group .volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: 1.5px solid var(--bg);
}

.volume-group .volume-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface3);
}

.volume-group .volume-slider::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--text-dim);
}

/* ===== Timeline tooltip ===== */
.timeline-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.timeline-tooltip {
  position: absolute;
  top: -30px;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  white-space: nowrap;
  z-index: 10;
}

.timeline-wrapper:hover .timeline-tooltip {
  opacity: 1;
}

/* ===== Subtitle button ===== */
.cc-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.cc-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.cc-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* ===== Audio track picker ===== */
.audio-track-picker {
  position: relative;
  flex-shrink: 0;
}

.audio-track-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 140px;
  z-index: 100;
  display: none;
}

.audio-track-menu.open {
  display: block;
}

.audio-track-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.audio-track-item:hover {
  background: var(--surface3);
  color: var(--text);
}

.audio-track-item.active {
  color: var(--accent);
}

.audio-track-item .track-check {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0;
}

.audio-track-item.active .track-check {
  opacity: 1;
}

/* ===== Format compatibility hints ===== */
.format-compat {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  font-size: 10px;
}

.fmt-tag {
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
}

.fmt-ok {
  background: rgba(0, 229, 160, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 229, 160, 0.3);
}

.fmt-partial {
  background: rgba(255, 170, 34, 0.12);
  color: var(--warning);
  border: 1px solid rgba(255, 170, 34, 0.3);
}

.fmt-sep {
  color: var(--text-dim);
}

.fmt-unsup {
  color: var(--text-dim);
  font-size: 10px;
}

.convert-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.convert-link:hover {
  opacity: 0.8;
}

.subtitle-load-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  margin-top: 8px;
  min-width: 0;
  width: 100%;
}

.subtitle-load-row .btn {
  flex-shrink: 0;
}

.subtitle-load-row .loaded-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sourceSubtitle {
  flex-direction: column;
  align-items: stretch;
}

.caption-settings-toggle {
  flex-shrink: 0;
  margin-left: auto;
}

.caption-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 10px 0 2px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}

.caption-setting-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.caption-setting-label {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  min-width: 32px;
}

.caption-seg-btns {
  display: flex;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.caption-seg-btn {
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 3px 8px;
  font-size: 11px;
  font-family: var(--mono);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-right: 1px solid var(--border);
}

.caption-seg-btn:last-child {
  border-right: none;
}

.caption-seg-btn:hover {
  background: var(--bg-alt);
}

.caption-seg-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ===== Nickname input ===== */
.nickname-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.nickname-row label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.nickname-row input {
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  max-width: 200px;
  transition: border-color 0.2s;
}

.nickname-row input:focus {
  border-color: var(--accent);
}

.nickname-row input::placeholder {
  color: var(--text-muted);
}

/* ===== Header controls ===== */
.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.header-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header-btn .icon-svg {
  width: 16px;
  height: 16px;
}

/* ===== Encryption badge ===== */
.encryption-badge {
  display: none;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.encryption-badge.visible {
  display: flex;
}

.encryption-badge .icon-svg {
  width: 11px;
  height: 11px;
}

/* ===== Connection quality ===== */
.conn-quality {
  display: none;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.conn-quality.visible {
  display: flex;
}

.conn-quality .bar {
  width: 3px;
  border-radius: 1px;
  background: var(--text-muted);
  transition: background 0.3s;
}

.conn-quality .bar:nth-child(1) {
  height: 6px;
}

.conn-quality .bar:nth-child(2) {
  height: 9px;
}

.conn-quality .bar:nth-child(3) {
  height: 12px;
}

.conn-quality.good .bar {
  background: var(--accent);
}

.conn-quality.ok .bar:nth-child(1),
.conn-quality.ok .bar:nth-child(2) {
  background: var(--warning);
}

.conn-quality.ok .bar:nth-child(3) {
  background: var(--text-muted);
}

.conn-quality.poor .bar:nth-child(1) {
  background: var(--danger);
}

.conn-quality.poor .bar:nth-child(2),
.conn-quality.poor .bar:nth-child(3) {
  background: var(--text-muted);
}

/* ===== Chat resize handle ===== */
.chat-resize-handle {
  height: 8px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
  transition: opacity 0.15s;
}

.chat-resize-handle:hover {
  opacity: 0.7;
}

.chat-resize-handle .icon-svg {
  width: 16px;
  height: 8px;
}

/* ===== Keyboard shortcut overlay ===== */
.shortcut-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.shortcut-overlay.visible {
  display: flex;
}

.shortcut-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  max-width: 380px;
  width: 90%;
}

.shortcut-card h3 {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 18px;
}

.shortcut-card .shortcut-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.shortcut-card .shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-card kbd {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--text);
  min-width: 28px;
  text-align: center;
}

/* ===== Shimmer skeleton ===== */
.shimmer {
  background: linear-gradient(90deg, var(--surface3) 25%, var(--border) 50%, var(--surface3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease infinite;
  border-radius: 6px;
  color: transparent !important;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ===== Light theme ===== */
html.light {
  --bg: #f5f5f8;
  --surface: #ffffff;
  --surface2: #f0f0f5;
  --surface3: #e5e5ee;
  --border: #d0d0dd;
  --border-glow: #b0b0cc;
  --text: #1a1a2e;
  --text-dim: #555568;
  --text-muted: #8888a0;
  --accent: #00b880;
  --accent-dim: #00b88033;
  --accent2: #0090cc;
  --accent2-dim: #0090cc22;
  --danger: #dd3355;
  --warning: #cc8800;
}

html.light .connect-panel {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(208, 208, 221, 0.6);
}

html.light body::before {
  opacity: 0.06;
}

html.light body::after {
  opacity: 0.12;
}

/* ===== Inline spinner ===== */
.spinner-inline {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Mobile gesture overlay ===== */
.seek-overlay {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 16px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}

.seek-overlay.left {
  left: 20%;
}

.seek-overlay.right {
  right: 20%;
}

.seek-overlay.show {
  opacity: 1;
}

/* ===== Tablet layout (900-1199px) ===== */
@media (min-width: 900px) and (max-width: 1199px) {
  .app {
    max-width: 960px;
  }

  .main-area.watch-active {
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-rows: auto auto 1fr;
    gap: 0 12px;
  }

  .main-area.watch-active .disconnect-bar {
    grid-column: 1 / -1;
  }

  .main-area.watch-active .tabs {
    grid-column: 1 / -1;
  }

  .main-area.watch-active #tab-watch {
    grid-column: 1;
  }

  .main-area.watch-active .chat-panel {
    grid-column: 2;
    grid-row: 3;
    margin-top: 0;
  }

  .main-area.watch-active .chat-messages {
    height: 240px;
  }
}

/* ===== Side-by-side layout ===== */
@media (min-width: 1200px) {
  .app {
    max-width: 1400px;
  }

  .main-area.watch-active {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: auto auto 1fr;
    gap: 0 16px;
  }

  .main-area.watch-active .disconnect-bar {
    grid-column: 1 / -1;
  }

  .main-area.watch-active .tabs {
    grid-column: 1 / -1;
  }

  .main-area.watch-active #tab-watch {
    grid-column: 1;
  }

  .main-area.watch-active .chat-panel {
    grid-column: 2;
    grid-row: 3;
    margin-top: 0;
  }

  .main-area.watch-active .chat-messages {
    height: 300px;
  }
}

@media (max-width: 600px) {
  .header-controls {
    gap: 6px;
  }

  .header-btn {
    width: 28px;
    height: 28px;
  }

  .volume-group .volume-slider {
    width: 50px;
  }

  .nickname-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .nickname-row input {
    max-width: 100%;
    width: 100%;
  }

  .join-inputs input {
    font-size: 16px;
    padding: 12px 8px;
    min-height: 44px;
  }

  .connect-card .btn.primary {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    min-height: 44px;
  }

  .video-controls {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
  }

  .video-controls .play-btn {
    width: 36px;
    height: 36px;
    min-width: 44px;
    min-height: 44px;
  }

  .timeline-wrapper {
    order: 4;
    width: 100%;
    flex-basis: 100%;
  }

  .video-controls .time-display {
    font-size: 11px;
    min-width: auto;
    order: 5;
    width: 100%;
    text-align: center;
  }

  [data-tooltip]::after {
    display: none;
  }
}

/* ===== Plyr theme overrides ===== */
.plyr {
  --plyr-color-main: var(--accent);
  --plyr-audio-control-color: var(--text);
  --plyr-video-control-color: #fff;
  --plyr-video-control-color-hover: #fff;
  --plyr-video-control-background-hover: var(--accent);
  --plyr-range-fill-background: var(--accent);
  --plyr-range-thumb-background: var(--accent);
  --plyr-range-thumb-shadow: 0 0 6px var(--accent-dim);
  --plyr-tooltip-background: var(--surface2);
  --plyr-tooltip-color: var(--text);
  --plyr-font-family: var(--mono);
  --plyr-font-size-base: 13px;
  --plyr-font-size-small: 11px;
  --plyr-font-size-time: 12px;
  --plyr-control-spacing: 10px;
  border-radius: 0;
}

/* Plyr container inside video-container */
.video-container .plyr {
  width: 100%;
  height: 100%;
}

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

/* Plyr YouTube embed fills container */
.video-container .plyr__video-embed,
.video-container .plyr__video-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Subtitle overlay inside Plyr container for native fullscreen */
.plyr .custom-sub-overlay {
  position: absolute;
  bottom: var(--caption-bottom, 12%);
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  text-align: center;
  pointer-events: none;
  z-index: 10;
}

.plyr:fullscreen .custom-sub-overlay {
  bottom: var(--caption-bottom-fs, 8%);
}

.plyr:fullscreen .custom-sub-overlay span {
  font-size: var(--caption-size, clamp(18px, 2.5vw, 32px));
}

/* CC and audio track buttons inside Plyr controls */
.plyr__controls .cc-btn {
  margin-left: 2px;
}

.plyr__controls .audio-track-picker {
  margin-left: 2px;
}

/* Audio track menu above Plyr controls */
.plyr__controls .audio-track-menu {
  bottom: calc(100% + 6px);
}

/* Ensure overlays render above Plyr wrapper */
.video-container .seek-overlay {
  z-index: 10;
}

.video-container .video-placeholder {
  z-index: 10;
}

/* ===== Confirmation dialog ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

.confirm-overlay.visible {
  display: flex;
}

.confirm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

.confirm-card p {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
  color: var(--text);
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-actions .btn {
  min-width: 90px;
  justify-content: center;
}

/* ===== Tooltip system ===== */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 11px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  max-width: 240px;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

[data-tooltip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 8px);
}

/* ===== Tab badge ===== */
.tab {
  position: relative;
}

.tab-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  animation: fadeIn 0.2s ease;
}

/* ===== Drop zone enhancements ===== */
.drop-zone-active {
  display: none;
}

.drop-zone.drag-over .drop-zone-default {
  display: none;
}

.drop-zone.drag-over .drop-zone-active {
  display: block;
}

.drop-zone .drop-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.drop-zone-active .icon .icon-svg {
  animation: bounce 0.6s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.drop-zone.drag-over {
  transform: scale(1.01);
  box-shadow: 0 0 24px var(--accent-dim);
}

/* ===== Chat character counter ===== */
.chat-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.chat-input-wrapper input {
  width: 100%;
  padding-right: 52px;
}

.char-count {
  position: absolute;
  right: 10px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.char-count.visible {
  opacity: 1;
}

.char-count.warning {
  color: var(--warning);
}

.char-count.danger {
  color: var(--danger);
}

/* ===== Onboarding hint ===== */
.onboarding-hint {
  background: var(--accent-dim);
  border: 1px solid rgba(0, 229, 160, 0.25);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text);
  animation: fadeIn 0.4s ease;
}

.onboarding-hint kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}

.onboarding-hint.hidden {
  display: none;
}

.hint-dismiss {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.hint-dismiss:hover {
  color: var(--text);
}

/* ===== Connection quality label ===== */
.conn-label {
  font-family: var(--mono);
  font-size: 10px;
  margin-left: 4px;
  color: inherit;
}

.conn-quality.good .conn-label { color: var(--accent); }
.conn-quality.ok .conn-label { color: var(--warning); }
.conn-quality.poor .conn-label { color: var(--danger); }

/* ===== Debug Panel ===== */
#debugPanel {
  position: fixed;
  top: 8px;
  right: 8px;
  width: 420px;
  max-height: 80vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 9999;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
#debugPanel.visible { display: block; }

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  position: sticky;
  top: 0;
  background: var(--surface);
}
.debug-header button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.debug-header button:hover { color: var(--text); }

.debug-section {
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
}
.debug-section:last-child { border-bottom: none; }

.debug-section-title {
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 0;
  line-height: 1.5;
}
.debug-label {
  color: var(--muted);
  white-space: nowrap;
}
.debug-value {
  text-align: right;
  word-break: break-all;
}

.debug-ok { color: #4ade80; }
.debug-err { color: #f87171; }

.debug-track {
  padding: 2px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.debug-track-type {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--border);
}
.debug-track-codec { color: var(--accent); }
.debug-track-extra { color: var(--muted); }
.debug-track-lang { color: var(--muted); font-style: italic; }

.debug-event-list {
  max-height: 200px;
  overflow-y: auto;
}
.debug-event {
  padding: 1px 0;
  line-height: 1.4;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.debug-event-ts { color: var(--muted); }
.debug-event-cat { color: var(--accent); }

@media (max-width: 500px) {
  #debugPanel {
    width: calc(100vw - 16px);
    font-size: 10px;
  }
}