:root {
  --bg: #080a0f;
  --surface: #111520;
  --surface-2: #192030;
  --border: rgba(255, 255, 255, 0.085);
  --text: #f1f4fa;
  --muted: #94a3b8;
  --accent: #6c63ff;
  --accent-hover: #7f77ff;
  --tv: #0ea5e9;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(ellipse 75% 45% at 85% -5%, rgba(108, 99, 255, 0.16), transparent 65%),
    radial-gradient(ellipse 55% 40% at 10% 0%, rgba(14, 165, 233, 0.10), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }

code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.88em;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.88rem; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  background: rgba(8, 10, 15, 0.84);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.18rem;
  cursor: pointer;
  letter-spacing: -0.025em;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--tv));
  box-shadow: 0 0 14px var(--accent);
}

.brand-tag {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(108, 99, 255, 0.22);
  color: #c4c0ff;
  border: 1px solid rgba(108, 99, 255, 0.42);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.pill:hover { border-color: rgba(255, 255, 255, 0.22); background: var(--surface-2); }

.tv-selector-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.tv-select {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  max-width: 220px;
}
.tv-select option {
  background: #131722;
  color: #f1f4fa;
}
.tv-refresh-btn {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tv-refresh-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}
.status-dot.online { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-dot.offline { background: var(--danger); }

.badge-count {
  background: rgba(108, 99, 255, 0.32);
  color: #dbd8ff;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.76rem;
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  transition: transform 0.1s, background 0.18s, border-color 0.18s, filter 0.18s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 0.81rem; border-radius: 8px; }
.btn-lg { padding: 11px 22px; font-size: 0.96rem; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5b52f0); box-shadow: 0 4px 14px rgba(108, 99, 255, 0.28); }
.btn-primary:hover { filter: brightness(1.09); }
.btn-tv { background: linear-gradient(135deg, #0284c7, #0ea5e9); box-shadow: 0 4px 14px rgba(14, 165, 233, 0.25); }
.btn-tv:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); }
.btn-secondary:hover { border-color: rgba(255, 255, 255, 0.22); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn-danger { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.45); color: #fca5a5; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.32); }

.input, .select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.18s;
}
.input:focus, .select:focus { border-color: var(--accent); }
.input-sm, .select-sm { padding: 6px 9px; font-size: 0.81rem; border-radius: 8px; }
.textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }

/* Container & Views */
.container {
  max-width: 1540px;
  margin: 0 auto;
  padding: 20px 22px 48px;
}

.view { display: none; }
.view.active { display: block; }

/* Library */
.library-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.library-header h1 { font-size: 1.7rem; letter-spacing: -0.025em; }
.subtitle { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }

.library-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
.crumb-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 7px;
}
.crumb-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.crumb-btn.current { color: #fff; background: rgba(108, 99, 255, 0.22); }
.crumb-sep { color: var(--muted); font-size: 0.8rem; }

.folder-card {
  background: linear-gradient(155deg, rgba(25, 32, 48, 0.95), rgba(15, 19, 30, 0.96));
  border: 1px solid rgba(108, 99, 255, 0.28);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.folder-card:hover {
  transform: translateY(-4px);
  border-color: rgba(108, 99, 255, 0.72);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}
.folder-card-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #1b2238, #0f1422);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.folder-card-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.38;
  filter: blur(1px);
  transition: opacity 0.2s, transform 0.3s;
}
.folder-card:hover .folder-card-preview img { opacity: 0.55; transform: scale(1.04); }
.folder-card-icon {
  position: relative;
  z-index: 2;
  font-size: 2.7rem;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.6));
}
.folder-card-body {
  padding: 13px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.folder-card-title {
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.3;
  word-break: break-word;
}
.folder-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.79rem;
  color: var(--muted);
}

.filter-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.2); }
.chip.active { background: rgba(108, 99, 255, 0.26); color: #fff; border-color: var(--accent); }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(292px, 1fr));
  gap: 18px;
}

.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.media-card:hover {
  transform: translateY(-4px);
  border-color: rgba(108, 99, 255, 0.5);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
}

.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #161c2d, #0d111b);
  overflow: hidden;
  cursor: pointer;
}
.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.media-card:hover .thumb-wrap img { transform: scale(1.03); }

.thumb-play-veil {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 15, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.thumb-wrap:hover .thumb-play-veil { opacity: 1; }
.thumb-play-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(108, 99, 255, 0.92);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.thumb-duration {
  position: absolute;
  bottom: 9px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
}
.thumb-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.thumb-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
}
.thumb-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--tv));
}

.badge {
  font-size: 0.69rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}
.badge-4k { background: rgba(14, 165, 233, 0.9); color: #fff; }
.badge-hdr { background: rgba(245, 158, 11, 0.92); color: #111; }
.badge-hd { background: rgba(15, 23, 42, 0.85); color: #e2e8f0; border: 1px solid rgba(255, 255, 255, 0.16); }
.badge-ok { background: rgba(34, 197, 94, 0.16); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.35); }
.badge-remux { background: rgba(245, 158, 11, 0.15); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-resume { background: rgba(108, 99, 255, 0.25); color: #d8d4ff; border: 1px solid rgba(108, 99, 255, 0.5); }

.card-body {
  padding: 13px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card-title {
  font-weight: 700;
  font-size: 0.96rem;
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.77rem;
  color: var(--muted);
}
.card-actions {
  margin-top: auto;
  padding-top: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.empty-state {
  text-align: center;
  padding: 56px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-icon { font-size: 2.6rem; margin-bottom: 10px; }
.empty-state p { color: var(--muted); margin: 10px auto 18px; max-width: 520px; line-height: 1.5; }

/* Watch Room */
.room-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.room-title-wrap { flex: 1; min-width: 220px; }
.room-title-wrap h2 { font-size: 1.2rem; }
.movie-meta-badges { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }

.room-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.incoming-call-pill {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(17, 21, 32, 0.92);
  border: 1px solid rgba(108, 99, 255, 0.6);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  font-size: 0.83rem;
}

/* Frameless Draggable & Resizable Floating Video Call Bubbles */
.call-bubbles-dock {
  --cam-size: 82px;
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 16px;
  background: transparent;
  user-select: none;
  touch-action: none;
  transition: opacity 0.22s ease;
}
.call-bubbles-dock.ghost-mode { opacity: 0.72; }
.call-bubbles-dock.ghost-mode:hover,
.call-bubbles-dock.controls-open { opacity: 1; }

.call-hover-toolbar,
.call-hover-sliders {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(11, 14, 22, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.call-hover-sliders {
  border-radius: 12px;
  padding: 5px 9px;
  gap: 10px;
}
.call-bubbles-dock:hover .call-hover-toolbar,
.call-bubbles-dock:hover .call-hover-sliders,
.call-bubbles-dock.controls-open .call-hover-toolbar,
.call-bubbles-dock.controls-open .call-hover-sliders {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.call-icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(25, 32, 48, 0.92);
  color: #fff;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.15s;
}
.call-icon-btn:hover { background: rgba(108, 99, 255, 0.7); transform: scale(1.08); }
.call-icon-btn.off { background: rgba(239, 68, 68, 0.45); border-color: rgba(239, 68, 68, 0.75); }
.call-icon-btn.active { background: rgba(14, 165, 233, 0.5); border-color: rgba(14, 165, 233, 0.8); }
.call-icon-btn.danger { background: rgba(239, 68, 68, 0.82); border-color: rgba(239, 68, 68, 0.95); }

.call-bubbles-stage {
  position: relative;
  cursor: grab;
  padding: 2px;
}
.call-bubbles-stage:active { cursor: grabbing; }

.call-bubbles-list {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.call-bubbles-dock.layout-col .call-bubbles-list {
  flex-direction: column;
}

.cam-bubble {
  position: relative;
  overflow: hidden;
  background: #0c1018;
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.65);
  flex-shrink: 0;
  transition: border-color 0.2s, border-radius 0.2s;
}
.cam-bubble.remote { border-color: rgba(108, 99, 255, 0.85); }
.cam-bubble.local { border-color: rgba(14, 165, 233, 0.75); }
.cam-bubble.speaking {
  border-color: #22c55e !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35), 0 8px 26px rgba(0, 0, 0, 0.65);
}

.call-bubbles-dock.shape-circle .cam-bubble {
  width: var(--cam-size);
  height: var(--cam-size);
  border-radius: 50%;
}
.call-bubbles-dock.shape-cinema .cam-bubble {
  width: calc(var(--cam-size) * 1.48);
  height: calc(var(--cam-size) * 0.84);
  border-radius: 12px;
}
.call-bubbles-dock.shape-rounded .cam-bubble {
  width: var(--cam-size);
  height: var(--cam-size);
  border-radius: 18px;
}

/* When partner is connected, keep self-preview subtly smaller (80%) so partner stands out */
.call-bubbles-dock.has-remote .cam-bubble.local {
  transform: scale(0.84);
  opacity: 0.92;
}
.call-bubbles-dock.has-remote .cam-bubble.local:hover {
  transform: scale(0.95);
  opacity: 1;
}

.cam-bubble video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.cam-bubble video.audio-only-video {
  opacity: 0.01;
}
.cam-bubble.local video { transform: scaleX(-1); }

.cam-mic-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 4;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 1px 5px;
  font-size: 0.66rem;
  line-height: 1.25;
  pointer-events: none;
}
.cam-unmute-btn {
  position: absolute;
  inset: 0;
  z-index: 6;
  margin: auto;
  width: fit-content;
  height: fit-content;
  max-width: 92%;
  background: rgba(239, 68, 68, 0.94);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}
.cam-unmute-btn:hover { background: #dc2626; transform: scale(1.04); }

.cam-bubble-name {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 88%;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.call-bubbles-dock:hover .cam-bubble-name,
.call-bubbles-dock.controls-open .cam-bubble-name {
  opacity: 1;
}

.cam-bubble-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--muted);
  background: radial-gradient(circle, #1c2438, #0e131e);
}

.call-resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(17, 21, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #e2e8f0;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.12s;
  z-index: 4;
}
.call-bubbles-dock:hover .call-resize-handle,
.call-bubbles-dock.controls-open .call-resize-handle {
  opacity: 1;
}
.call-resize-handle:hover { background: var(--accent); transform: scale(1.12); }

.call-slider-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: #cbd5e1;
}
.call-slider-row input {
  width: 66px;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}
.call-mic-select {
  max-width: 150px;
  background: rgba(25, 32, 48, 0.95);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  padding: 2px 6px;
  font-size: 0.72rem;
  outline: none;
  cursor: pointer;
}

.theater-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 335px;
  gap: 18px;
  align-items: start;
}

.player-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.player-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.subtitle-overlay {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 7%;
  text-align: center;
  pointer-events: none;
  z-index: 8;
}
.subtitle-overlay span {
  display: inline-block;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  line-height: 1.35;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
  white-space: pre-line;
}
.subtitle-overlay.size-sm span { font-size: clamp(0.86rem, 1.7vw, 1.18rem); }
.subtitle-overlay.size-md span { font-size: clamp(1rem, 2.2vw, 1.55rem); }
.subtitle-overlay.size-lg span { font-size: clamp(1.22rem, 2.8vw, 2rem); }

.reactions-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9;
}
.floating-emoji {
  position: absolute;
  bottom: 14%;
  font-size: 2rem;
  animation: floatUp 2.2s ease-out forwards;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(15px) scale(0.7); }
  15% { opacity: 1; transform: translateY(-10px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-210px) scale(1); }
}

.player-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 14, 0.84);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 12;
}
.autoplay-overlay {
  background: rgba(7, 9, 14, 0.72);
  backdrop-filter: blur(4px);
  z-index: 11;
}

.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* TV Mode Deck Overlay */
.tv-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #12233a 0%, #080c15 78%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 10;
}
.tv-overlay-card {
  width: 100%;
  max-width: 520px;
  background: rgba(17, 21, 32, 0.9);
  border: 1px solid rgba(14, 165, 233, 0.45);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.tv-badge-live {
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.06em;
}
.tv-big-time {
  font-size: 2.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.tv-remote-buttons {
  display: flex;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
}
.tv-volume-row, .tv-sub-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.84rem;
  flex-wrap: wrap;
}
.tv-volume-row input { flex: 1; max-width: 220px; accent-color: var(--tv); }
.vol-num { min-width: 28px; font-variant-numeric: tabular-nums; color: #cbd5e1; }
.tv-overlay-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
}
.toggle-inline input { accent-color: var(--tv); cursor: pointer; }
.tv-mirror-pref { justify-content: center; margin-top: 2px; }

.tv-mini-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 13px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.4);
}
.tv-mini-left, .tv-mini-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Controls bar */
.controls-bar {
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.scrub-row { display: flex; align-items: center; gap: 10px; }
.seek-bar { flex: 1; accent-color: var(--accent); cursor: pointer; }
.time-label {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 56px;
  text-align: center;
}
.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sync-status { font-size: 0.78rem; color: #86efac; padding-left: 4px; }

.sub-tuning-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tuning-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.82rem; }
.shortcuts-hint { font-size: 0.74rem; color: var(--muted); opacity: 0.8; }

/* Party Sidebar */
.party-sidebar { display: flex; flex-direction: column; gap: 14px; }
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head h3 { font-size: 0.94rem; }
.ping-badge {
  font-size: 0.74rem;
  color: #cbd5e1;
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.ping-badge.connected { color: #86efac; border-color: rgba(34, 197, 94, 0.35); }
.ping-badge.reconnecting { color: #fcd34d; border-color: rgba(245, 158, 11, 0.4); }

.profile-row { display: grid; grid-template-columns: 1fr 0.8fr auto; gap: 6px; }
.members-list { display: flex; flex-direction: column; gap: 6px; }
.member-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 0.82rem;
}
.member-top, .member-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.member-meta { font-size: 0.73rem; color: var(--muted); }
.sync-pill {
  font-size: 0.71rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.sync-pill.ok { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.sync-pill.warn { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.sync-pill.bad { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.sync-pill.idle { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }
.sync-summary-banner {
  font-size: 0.79rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 9px;
  text-align: center;
}
.sync-summary-banner.ok { background: rgba(34, 197, 94, 0.16); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.32); }
.sync-summary-banner.warn { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.32); }

.chat-card { height: 400px; }
.reactions-bar { display: flex; gap: 4px; }
.react-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.12s;
}
.react-btn:hover { transform: scale(1.15); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 4px;
}
.chat-msg {
  background: var(--surface-2);
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.83rem;
  line-height: 1.36;
  word-break: break-word;
}
.chat-msg.system {
  background: transparent;
  color: var(--muted);
  font-size: 0.77rem;
  text-align: center;
  padding: 2px 6px;
}
.chat-sender { font-weight: 700; color: #b7b3ff; margin-right: 6px; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}
.modal-sm { max-width: 360px; }
.modal-lg { max-width: 680px; }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.link-box, .form-group { display: flex; flex-direction: column; gap: 6px; }
.public-link-card {
  background: rgba(108, 99, 255, 0.08);
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: 12px;
  padding: 12px;
}
.tailscale-link-card {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px;
  padding: 12px;
}
.tailscale-link-card a {
  color: #6ee7b7;
  text-decoration: underline;
}
.public-link-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.link-box label, .form-group label { font-size: 0.84rem; font-weight: 600; color: #cbd5e1; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }
.hint { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.tv-info-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.error-text { color: #fca5a5; font-size: 0.82rem; }

/* Folder Browser */
.folder-shortcuts-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.folder-shortcuts { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.folder-path-bar { display: flex; gap: 8px; align-items: center; }
.folder-path-bar input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.folder-video-summary {
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.32);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.83rem;
  line-height: 1.4;
}
.folder-list {
  max-height: 270px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0c0f17;
  display: flex;
  flex-direction: column;
}
.folder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 0.87rem;
}
.folder-row:last-child { border-bottom: none; }
.folder-row:hover { background: rgba(108, 99, 255, 0.16); }
.folder-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 0.84rem; }
.folder-modal-actions { justify-content: space-between; flex-wrap: wrap; }
.folder-action-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}
.toast {
  background: rgba(25, 32, 48, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.18s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1060px) {
  .theater-layout { grid-template-columns: 1fr; }
  .chat-card { height: 290px; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .container { padding: 14px 14px 36px; }
  .media-grid { grid-template-columns: 1fr; }
  .shortcuts-hint { display: none; }
}
