:root {
  --bg0: #12071f;
  --bg1: #1d0f33;
  --ink: #f2eaff;
  --ink-soft: #bea8df;
  --accent: #8f4cf0;
  --accent-strong: #7437cb;
  --card: rgba(35, 20, 60, 0.82);
  --line: rgba(196, 165, 242, 0.24);
  --ok: #79d6b0;
  --warn: #ffb87a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 12% 10%, #41226b, transparent 28%),
    radial-gradient(circle at 88% 25%, #2a1552, transparent 30%),
    radial-gradient(circle at 70% 84%, #6f2bc0, transparent 24%),
    linear-gradient(140deg, var(--bg0), var(--bg1));
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.4;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(29, 15, 51, 0.72);
}

.top-bar h1 {
  margin: 0;
  font-family: 'Archivo Black', sans-serif;
  letter-spacing: 0.08em;
  font-size: clamp(1.4rem, 3vw, 2.1rem);
}

.session-area {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.7rem;
  font-size: 0.95rem;
}

.room-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.83rem;
  color: var(--ink-soft);
}

.layout {
  width: min(1400px, 99vw);
  margin: 0.7rem auto 2rem;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0.65rem;
  align-items: start;
  transition: grid-template-columns 0.22s ease;
}

.layout.sidebar-collapsed {
  grid-template-columns: 40px 1fr;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(6, 2, 14, 0.45);
  animation: rise-in 0.48s ease both;
}

.panel {
  padding: 1rem;
}

.panel h2,
.viewer h2 {
  margin-top: 0.1rem;
  margin-bottom: 0.7rem;
  font-family: 'Archivo Black', sans-serif;
  letter-spacing: 0.04em;
  font-size: 1.15rem;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.drop-zone {
  margin-bottom: 0.8rem;
  border: 2px dashed rgba(31, 42, 46, 0.28);
  border-radius: 14px;
  padding: 0.95rem 0.8rem;
  text-align: center;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.drop-zone p {
  margin: 0;
}

.drop-zone.active {
  border-color: var(--accent);
  background: rgba(143, 76, 240, 0.2);
  transform: translateY(-1px);
}

button,
input[type='file'] {
  width: 100%;
}

button {
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0.72rem 0.9rem;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

button.ghost {
  width: auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  padding: 0.4rem 0.8rem;
}

input[type='file'],
input[type='text'],
input[type='password'] {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.video-list-wrap {
  margin-top: 0.4rem;
}

.session-tools-wrap {
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.session-tools-wrap h3 {
  margin: 0 0 0.5rem;
}

.session-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

.sessions-list {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 220px;
  overflow: auto;
}

.session-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
}

.session-item .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.session-item .meta {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 0.25rem;
}

.session-item .actions {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.video-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 380px;
  overflow: auto;
}

.video-list button {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hint {
  margin-top: 0.9rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.public-link-wrap {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.public-link-wrap label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.public-link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.public-link-row input {
  min-width: 0;
}

.public-link-row button {
  width: auto;
  min-width: 88px;
}

.upload-status {
  margin-top: 0;
  margin-bottom: 0.7rem;
  min-height: 1.15rem;
  color: var(--warn);
  font-size: 0.88rem;
}

.viewer {
  padding: 1rem;
}

/* ── Camera Panel (inside Live float) ───────────────────────────────────────── */
.camera-float-mid {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}

.cam-panel {
  width: 155px;
  flex-shrink: 0;
  border-left: 1px solid rgba(143, 76, 240, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.22s ease;
  background: rgba(0, 0, 0, 0.35);
}

.cam-panel.cam-panel-collapsed {
  width: 28px;
}

.cam-panel-hdr {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.45rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  overflow: hidden;
}

.cam-panel-toggle-btn {
  width: 20px;
  min-width: 20px;
  height: 20px;
  padding: 0;
  font-size: 0.65rem;
  line-height: 1;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: unset !important;
}

.cam-panel-toggle-btn:hover { background: rgba(255, 255, 255, 0.15); transform: none; }

.cam-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
}

.cam-panel.cam-panel-collapsed .cam-panel-title { display: none; }
.cam-panel.cam-panel-collapsed .cam-panel-body  { display: none; }

.cam-panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.4rem;
}

/* ── Camera section in main layout (cam-main-wrap) ───────────────────────────── */
.cam-main-wrap {
  overflow: auto;
  min-height: 120px;
}

.cam-main-wrap > .cam-panel {
  width: auto;
  border-left: none;
  background: transparent;
  max-height: none;
}

.cam-main-wrap .cam-panel.cam-panel-collapsed {
  width: auto;
}

.cam-main-wrap .cam-panel-body {
  overflow: visible;
  flex: unset;
}

.cam-main-wrap #camSidebarList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.actor-status-text {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-soft);
  padding: 0.25rem 0.4rem;
  min-height: 1em;
}


.viewer-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
}

#activeVideoName {
  font-size: 0.9rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-wrap {
  position: relative;
  margin-top: 0.8rem;
}

video {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #111;
  aspect-ratio: 16 / 9;
  display: block;
}

.unmute-btn {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  min-width: 160px;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: rgba(14, 8, 24, 0.82);
  border: 1px solid var(--accent);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
  z-index: 2;
}

.status-row {
  margin-top: 0.7rem;
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

#syncStatus,
#actorStatus,
#sessionStatus,
#activeVideoName {
  word-break: break-word;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  background: rgba(14, 8, 24, 0.55);
  padding: 1rem;
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

.login-card {
  width: min(430px, 100%);
  border-radius: 16px;
  border: 1px solid rgba(196, 165, 242, 0.35);
  background: rgba(27, 14, 46, 0.95);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.login-card h2 {
  margin: 0;
  font-family: 'Archivo Black', sans-serif;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.95rem;
}

.remember-me-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  font-size: 0.9rem;
  opacity: 0.85;
  cursor: pointer;
}

.remember-me-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.error {
  margin: 0;
  color: #ff8fb1;
  min-height: 1.2rem;
}

.modal-card {
  width: min(500px, 95vw);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0;
}

.modal-header h2 {
  margin: 0;
  font-family: 'Archivo Black', sans-serif;
}

.video-list-wrap.hidden {
  display: none;
}

body.public-view-only .bg-grid,
body.public-view-only .top-bar,
body.public-view-only .panel,
body.public-view-only .viewer-title-row,
body.public-view-only .status-row,
body.public-view-only #linksModal {
  display: none !important;
}

body.public-view-only .layout {
  width: 100vw;
  margin: 0;
  display: block;
}

body.public-view-only .viewer {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  background: #000;
  animation: none;
}

body.public-view-only .player-wrap {
  margin-top: 0;
}

body.public-view-only video {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  object-fit: contain;
  background: #000;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .top-bar {
    position: static;
    padding: 0.85rem 0.95rem;
  }

  .layout {
    width: min(100%, 98vw);
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-top: 0.8rem;
  }

  .panel,
  .viewer,
  .login-card {
    padding: 0.85rem;
  }

  .video-list {
    max-height: 260px;
  }

  .status-row,
  .viewer-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  button:not(.cam-sl-star):not(.cam-sl-mute-btn):not(.cam-float-btn):not(.cam-btn):not(.cam-exit-fs-btn):not(.cam-footer-btn):not(.sidebar-toggle-btn):not(.sidebar-collapse-btn),
  input[type='file'],
  input[type='text'],
  input[type='password'] {
    min-height: 44px;
  }

  .drop-zone {
    padding: 1rem 0.8rem;
  }

  .hint {
    font-size: 0.85rem;
  }
}

/* ── Lobby ── */
.lobby-card {
  width: min(600px, 95vw);
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(22, 11, 40, 0.97);
  padding: 2rem 1.8rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  max-height: 90vh;
  overflow-y: auto;
  animation: rise-in 0.4s ease both;
}

.lobby-title {
  margin: 0;
  font-family: 'Archivo Black', sans-serif;
  letter-spacing: 0.1em;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  text-align: center;
}

.lobby-sub {
  margin: 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 1rem;
}

.lobby-rooms {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lobby-room-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  animation: rise-in 0.35s ease both;
}

.lobby-room-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.lobby-room-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-room-meta {
  font-size: 0.83rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 1.5rem 0;
  font-size: 0.95rem;
}

.lobby-footer {
  display: flex;
  justify-content: center;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}

.lobby-footer button {
  width: auto;
  min-width: 120px;
}

/* ── Session Picker ── */
.sessions-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
  max-height: 55vh;
  overflow-y: auto;
}

.sessions-empty {
  margin: 1rem 0;
}

.session-picker-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

.session-picker-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.spc-info {
  flex: 1;
  min-width: 0;
}

.spc-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spc-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spc-join-btn {
  flex-shrink: 0;
  width: auto;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.spc-join-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.live-badge {
  font-size: 0.72rem;
  color: #ff8fb1;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.session-create-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.session-create-row input {
  flex: 1;
}

/* ── In-Session Header ── */
.in-session-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.session-chip {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

/* ── Video List Redesign ── */
.video-list-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.1rem 0;
}

.watched-check {
  flex-shrink: 0;
  color: #7af0b4;
  font-weight: 700;
  font-size: 0.9rem;
  width: 1.2rem;
  text-align: center;
}

.video-pick-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0.45rem 0.7rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s;
}

.video-pick-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.video-pick-btn.video-watched {
  color: #7af0b4;
}

/* ── Countdown Timer ── */
.countdown-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1.2rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  margin-bottom: 1rem;
}

.countdown-label {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  letter-spacing: 0.03em;
}

.countdown-blocks {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

.countdown-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 3.5rem;
}

.countdown-block span {
  font-family: 'Archivo Black', sans-serif;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.countdown-block label {
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.countdown-totals {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
  margin-top: 0.2rem;
}

.countdown-total-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.countdown-total-row span {
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.01em;
  min-width: 4ch;
  text-align: right;
}

.countdown-total-row label {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Settings Modal ── */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.settings-section h3 {
  margin: 0 0 0.2rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--ink);
}

.settings-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

.settings-actions button {
  width: auto;
}

/* ── User Management (settings modal) ── */
.user-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.user-row:last-child { border-bottom: none; }
.user-row-name {
  flex: 1;
  font-size: 0.88rem;
}
.user-role-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255,255,255,0.1);
  color: var(--ink-soft);
}
.user-role-badge.admin {
  background: rgba(66,133,244,0.22);
  color: #93c5fd;
}
.user-row-acts { display: flex; gap: 0.2rem; }

/* ── Media Manager Modal ── */
.media-manager-card {
  width: min(1600px, 98vw);
  max-height: 90vh;
  overflow-y: auto;
}

.mm-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.mm-left {
  flex: 1;
  min-width: 0;
}

.mm-right {
  flex: 1;
  min-width: 0;
  position: sticky;
  top: 0;
}

.mm-preview-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  margin: 0 0 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mm-preview-player {
  width: 100%;
  border-radius: 10px;
  background: #000;
  display: block;
}

.mm-section {
  margin-bottom: 1.6rem;
}

.mm-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mm-jobs-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mm-job-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.mm-job-name {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.mm-job-status {
  font-size: 0.8rem;
  color: var(--ink-soft);
  flex-shrink: 0;
  margin-left: 0.8rem;
}

.mm-library-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mm-library-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.mm-lib-name {
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  font-size: 0.9rem;
}

.mm-lib-size {
  font-size: 0.8rem;
  color: var(--ink-soft);
  flex-shrink: 0;
}

.mm-del-btn {
  flex-shrink: 0;
  padding: 0.25rem 0.6rem !important;
  font-size: 0.8rem !important;
  color: #ff8fb1 !important;
  border-color: #ff8fb1 !important;
}

.mm-preview-btn {
  flex-shrink: 0;
  padding: 0.25rem 0.6rem !important;
  font-size: 0.8rem !important;
}

.mm-start-session-btn {
  flex-shrink: 0;
  padding: 0.25rem 0.6rem !important;
  font-size: 0.8rem !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.spc-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.spc-delete-btn {
  padding: 0.25rem 0.5rem !important;
  font-size: 0.8rem !important;
  color: #ff8fb1 !important;
  border-color: #ff8fb1 !important;
  opacity: 0.7;
}

.spc-delete-btn:hover {
  opacity: 1;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.cam-header-btn {
  border-color: rgba(143, 76, 240, 0.5);
  color: #c4a3f5;
}

.sidebar {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-toggle-btn {
  width: 100%;
  padding: 0.52rem;
  background: rgba(255, 255, 255, 0.04);
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover { background: rgba(255, 255, 255, 0.1); transform: none; }

.sidebar-inner {
  flex: 1;
  padding: 0.6rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.layout.sidebar-collapsed .sidebar-inner { display: none; }

.sidebar-sect {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.sidebar-sect-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.42rem 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--line);
  gap: 0.4rem;
}

.sidebar-sect-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  flex: 1;
}

.sidebar-sect-acts { display: flex; gap: 0.22rem; flex-shrink: 0; }

.sidebar-sm-btn {
  padding: 0.12rem 0.38rem !important;
  font-size: 0.76rem !important;
  min-height: unset !important;
  line-height: 1.3;
  width: auto;
}

.sidebar-sect-body { padding: 0.5rem; }
.sidebar-sect-body.sect-collapsed { display: none; }

/* ── Camera Right Panel Tiles ────────────────────────────────────────────── */
#camSidebarList { display: flex; flex-direction: column; gap: 0.4rem; }

.cam-sl-tile {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.35rem;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.07);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.cam-sl-tile:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(143, 76, 240, 0.35); }

.cam-sl-tile video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 5px;
  background: #111;
  display: block;
  pointer-events: none;
}

.cam-sl-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  min-width: 0;
}

.cam-sl-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.cam-sl-btns { display: flex; gap: 0.2rem; flex-shrink: 0; }

.cam-sl-star {
  width: auto;
  min-height: unset;
  padding: 0.1rem 0.28rem;
  font-size: 0.82rem;
  line-height: 1;
  border-radius: 5px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.cam-sl-star:hover { color: #ffd700; border-color: rgba(255, 215, 0, 0.45); }
.cam-sl-star.cam-sl-star-active {
  color: #ffd700;
  border-color: rgba(255, 215, 0, 0.55);
  background: rgba(255, 215, 0, 0.1);
}

/* Mute button in tile */
.cam-sl-mute-btn { font-size: 0.68rem; padding: 0.08rem 0.22rem; }
.cam-sl-mute-active {
  color: #ff8fb1 !important;
  border-color: rgba(255, 143, 177, 0.55) !important;
  background: rgba(255, 143, 177, 0.1) !important;
}

/* Volume meter canvas — horizontal bar below video + info row */
.cam-sl-meter {
  width: 100%;
  height: 5px;
  border-radius: 2px;
  background: rgba(255,255,255,0.06);
  display: block;
  flex-shrink: 0;
}

/* Per-cam volume slider */
.cam-sl-vol-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0;
}

.cam-sl-vol-icon {
  font-size: 0.7rem;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
}

.cam-sl-vol {
  flex: 1;
  min-width: 0;
  height: 3px;
  cursor: pointer;
  accent-color: rgba(143, 76, 240, 0.9);
  opacity: 0.75;
  transition: opacity 0.15s;
}

.cam-sl-vol:hover { opacity: 1; }

/* Popped-out: dim the tile and show a small badge */
.cam-sl-tile.cam-sl-popped { opacity: 0.6; }
.cam-sl-tile.cam-sl-popped::after {
  content: '↗ live';
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.58rem;
  font-weight: 700;
  color: #fff;
  background: rgba(143, 76, 240, 0.8);
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: none;
}

/* ── Timer Items ──────────────────────────────────────────────────────────── */

.timer-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.4rem;
  background: rgba(255, 255, 255, 0.02);
}

.timer-item-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--line);
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.03);
}

.timer-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer-item-acts { display: flex; gap: 0.18rem; flex-shrink: 0; }
.timer-item-body { padding: 0.4rem 0.5rem; }

.tc-blocks {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  padding: 0.15rem 0;
}

.tc-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.08rem;
  min-width: 2.5rem;
}

.tc-block span {
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.45rem;
  line-height: 1;
  color: var(--ink);
}

.tc-block label {
  font-size: 0.6rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.timer-item-edit {
  padding: 0.45rem 0.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.timer-edit-label {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  font-size: 0.8rem;
}

.timer-edit-label input {
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
  border-radius: 6px;
  min-height: unset;
}

.timer-edit-actions { display: flex; gap: 0.35rem; }
.timer-edit-actions button { width: auto; padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.timer-repeat-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
  cursor: pointer;
}
.timer-repeat-label input[type="checkbox"] { width: 13px; height: 13px; cursor: pointer; }

/* ── Calendar-sourced timer tiles ─────────────────────────────────────────── */

.timer-item.cal-event {
  border-color: rgba(66, 133, 244, 0.35);
  background: rgba(66, 133, 244, 0.06);
}

.timer-item.cal-event .timer-item-hdr {
  background: rgba(66, 133, 244, 0.08);
}

.cal-link {
  color: rgba(66, 133, 244, 0.7);
  font-size: 0.8rem;
  text-decoration: none;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.cal-link:hover { color: rgb(66, 133, 244); background: rgba(66, 133, 244, 0.12); }

/* ── Floating Camera Panel ───────────────────────────────────────────────── */

.camera-float {
  position: fixed;
  z-index: 300;
  top: 74px;
  right: 1.5rem;
  width: 490px;
  background: rgba(8, 3, 16, 0.93);
  border: 1px solid rgba(143, 76, 240, 0.35);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 180px;
  min-height: 160px;
  resize: both;
  user-select: none;
}

.camera-float-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.36rem 0.6rem;
  background: rgba(143, 76, 240, 0.13);
  border-bottom: 1px solid rgba(143, 76, 240, 0.22);
  cursor: grab;
  flex-shrink: 0;
  gap: 0.5rem;
}

.camera-float-hdr:active { cursor: grabbing; }

.cam-float-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--ink);
  pointer-events: none;
}

.cam-float-btns { display: flex; gap: 0.22rem; flex-shrink: 0; }

.cam-float-btn {
  width: auto !important;
  padding: 0.15rem 0.38rem !important;
  font-size: 0.86rem !important;
  min-height: unset !important;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  color: var(--ink);
  line-height: 1.2;
}

.cam-float-btn:hover { background: rgba(255, 255, 255, 0.18); transform: none; }

.camera-float-body {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
  min-height: 140px;
  display: flex;
  flex-direction: row;
}

/* ── Featured (selected) remote camera ── */
.featured-cam-video {
  flex: 1;
  height: 100%;
  object-fit: contain;
  display: block;
  border: none;
  background: #000;
  min-width: 0;
}

/* ── Right thumbnail column ── */
.cam-thumb-col {
  width: 88px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: #080808;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px;
  border-left: 1px solid rgba(143, 76, 240, 0.2);
}

.cam-thumb-col::-webkit-scrollbar { width: 3px; }
.cam-thumb-col::-webkit-scrollbar-thumb { background: rgba(143, 76, 240, 0.4); border-radius: 2px; }

.cam-thumb-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.cam-thumb-tile:hover { border-color: rgba(143, 76, 240, 0.5); }
.cam-thumb-tile.active { border-color: rgb(143, 76, 240); }

.cam-thumb-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Per-peer mute button — bottom-left of thumb */
.cam-thumb-mute {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: auto;
  min-height: unset;
  padding: 1px 5px;
  font-size: 0.7rem;
  line-height: 1.4;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 12;
}
.cam-thumb-tile:hover .cam-thumb-mute { opacity: 1; }
.cam-thumb-mute-active { opacity: 1 !important; background: rgba(210, 50, 50, 0.75) !important; border-color: rgba(255, 90, 90, 0.5) !important; }

.cam-thumb-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.1rem 0.2rem;
  font-size: 0.58rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-thumb-popout {
  position: absolute;
  top: 2px;
  right: 2px;
  padding: 0.05rem 0.15rem;
  font-size: 0.62rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.cam-thumb-tile:hover .cam-thumb-popout { opacity: 1; }

/* cam-overlay, cam-name, cam-controls, cam-btn, cam-vol-wrap, cam-vol kept below */
.cam-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  padding: 1.2rem 0.7rem 0.42rem;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 0.5rem;
}

.cam-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  flex-shrink: 0;
}

.cam-controls { display: flex; align-items: center; gap: 0.3rem; }

.cam-btn {
  width: auto;
  padding: 0.26rem 0.48rem;
  font-size: 0.95rem;
  line-height: 1.1;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
  min-height: unset;
}

.cam-btn:hover { background: rgba(255, 255, 255, 0.18); transform: none; }
.cam-btn-active { background: rgba(210, 50, 50, 0.7) !important; border-color: rgba(255, 90, 90, 0.55) !important; }

.cam-vol-wrap {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(0, 0, 0, 0.45);
  padding: 0.26rem 0.48rem;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.cam-vol-icon { font-size: 0.72rem; line-height: 1; color: rgba(255, 255, 255, 0.7); }

.cam-vol {
  width: 64px;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  cursor: pointer;
  border: none;
  padding: 0;
  min-height: unset;
}

.cam-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.cam-vol::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
}

.cam-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  padding: 0 1rem;
  width: 100%;
}

/* PiP: your camera within partner's */
.cam-pip {
  position: absolute;
  bottom: 44px;
  right: 96px;
  width: 96px;
  aspect-ratio: 4 / 3;
  border-radius: 7px;
  overflow: hidden;
  border: 2px solid rgba(143, 76, 240, 0.75);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.75);
  cursor: grab;
  z-index: 10;
  background: #0a0410;
  touch-action: none;
}

.cam-pip:active { cursor: grabbing; }

.cam-pip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  border: none;
  aspect-ratio: unset;
}

.cam-pip-label {
  position: absolute;
  bottom: 2px;
  left: 4px;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95);
  pointer-events: none;
}

.cam-pip-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  pointer-events: none;
  padding: 0.2rem;
}

/* Resize handle — bottom-right triangle */
.cam-pip-resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 12;
  background: linear-gradient(135deg, transparent 52%, rgba(143, 76, 240, 0.9) 52%);
  border-bottom-right-radius: 5px;
  touch-action: none;
}

/* Pop-out button — appears on hover */
.cam-pip-popout {
  position: absolute;
  top: 2px;
  right: 2px;
  width: auto;
  min-height: unset;
  padding: 1px 5px;
  font-size: 0.68rem;
  line-height: 1.4;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 12;
}

.cam-pip:hover .cam-pip-popout { opacity: 1; }


  flex-shrink: 0;
  padding: 0.26rem 0.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cam-rtc-status {
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Camera/audio settings panel inside float */
.cam-settings-panel {
  position: absolute;
  bottom: 2.2rem;
  right: 0.5rem;
  background: rgba(20,20,28,0.97);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 0.75rem 0.85rem 0.6rem;
  z-index: 10;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.cam-settings-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.cam-settings-row select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  color: var(--ink);
  padding: 0.28rem 0.45rem;
  font-size: 0.82rem;
}

@media (max-width: 700px) {
  .camera-float {
    width: min(90vw, 320px);
    /* Reset any saved pixel position so it stays on-screen */
    top: auto !important;
    bottom: 1rem !important;
    right: 0.5rem !important;
    left: auto !important;
  }

  /* Cam tile buttons: ensure comfortable tap targets without breaking layout */
  .cam-sl-btns { gap: 0.35rem; }
  .cam-sl-star { padding: 0.2rem 0.45rem; font-size: 0.82rem; }

  /* Top-bar: stack on very small screens */
  .top-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .session-area {
    font-size: 0.85rem;
    gap: 0.4rem;
  }
  .session-area #sessionStatus { display: none; }

  /* ── Fake fullscreen for mobile / iOS ── */
  .camera-float.cam-fs {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    right: 0 !important;
    bottom: 0 !important;
    top: 0 !important;
    left: 0 !important;
    border-radius: 0 !important;
    resize: none !important;
    z-index: 9999 !important;
  }

  .camera-float.cam-fs .camera-float-body {
    min-height: 0;
  }

  /* In landscape fake-fullscreen: thumb col becomes a top strip */
  @media (orientation: landscape) {
    .camera-float.cam-fs .camera-float-body {
      flex-direction: column;
    }
    .camera-float.cam-fs .cam-thumb-col {
      width: 100%;
      height: 64px;
      flex-direction: row;
      overflow-x: auto;
      overflow-y: hidden;
      border-left: none;
      border-bottom: 1px solid rgba(143, 76, 240, 0.2);
      flex-shrink: 0;
    }
    .camera-float.cam-fs .cam-thumb-tile {
      width: auto;
      height: 100%;
      aspect-ratio: 16 / 9;
      flex-shrink: 0;
    }
  }

  /* Exit fullscreen button — shown only in cam-fs */
  .cam-exit-fs-btn {
    display: block;
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 10000;
    width: auto;
    min-height: unset;
    padding: 0.3rem 0.6rem;
    font-size: 1rem;
    line-height: 1;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    cursor: pointer;
  }
}

/* Hide exit btn on non-mobile — fullscreen handled by browser */
@media (min-width: 701px) {
  .cam-exit-fs-btn { display: none !important; }
}

/* Player pip inside cam fullscreen */
.player-fs-pip video {
  aspect-ratio: 16 / 9;
  background: #000;
  object-fit: contain;
}

/* cameraFloat as a pip when video player is fullscreened */
.player-wrap:fullscreen .camera-float,
.player-wrap:-webkit-full-screen .camera-float {
  position: absolute !important;
  width: 28% !important;
  min-width: 180px !important;
  max-width: 340px !important;
  height: auto !important;
  right: 12px !important;
  bottom: 60px !important;
  top: auto !important;
  left: auto !important;
  border-radius: 10px !important;
  resize: none !important;
  z-index: 9999 !important;
}

.player-wrap:fullscreen,
.player-wrap:-webkit-full-screen {
  position: relative;
  background: #000;
}

.player-wrap:fullscreen video#player,
.player-wrap:-webkit-full-screen video#player {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
  border: none !important;
  aspect-ratio: unset !important;
  object-fit: contain !important;
}

/* Player pip inside cam fullscreen */
.player-fs-pip video {
  aspect-ratio: 16 / 9;
  background: #000;
  object-fit: contain;
}

/* cameraFloat as a pip when video player-wrap is fullscreened */
.player-wrap:fullscreen .camera-float,
.player-wrap:-webkit-full-screen .camera-float {
  position: absolute !important;
  width: 28% !important;
  min-width: 180px !important;
  max-width: 340px !important;
  height: auto !important;
  right: 12px !important;
  bottom: 60px !important;
  top: auto !important;
  left: auto !important;
  border-radius: 10px !important;
  resize: none !important;
  z-index: 9999 !important;
}

.player-wrap:fullscreen,
.player-wrap:-webkit-full-screen {
  position: relative;
  background: #000;
}

.player-wrap:fullscreen video#player,
.player-wrap:-webkit-full-screen video#player {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
  border: none !important;
  aspect-ratio: unset !important;
  object-fit: contain !important;
}

/* ── Desktop fullscreen: scale the whole float panel to fill the screen ── */
.camera-float:fullscreen,
.camera-float:-webkit-full-screen {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
  resize: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
}

.camera-float:fullscreen .camera-float-body,
.camera-float:-webkit-full-screen .camera-float-body {
  flex: 1;
  min-height: 0;
  height: 100%;
}

/* Thumb col: keep same proportional width as in the floating panel (~26%) */
.camera-float:fullscreen .cam-thumb-col,
.camera-float:-webkit-full-screen .cam-thumb-col {
  width: 18%;
  min-width: 120px;
  max-width: 280px;
}

/* PiP: keep proportional to screen width */
.camera-float:fullscreen .cam-pip,
.camera-float:-webkit-full-screen .cam-pip {
  width: 14vw;
  min-width: 96px;
  max-width: 220px;
  right: calc(18% + 8px);
  bottom: 52px;
}


.camera-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.camera-tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #0a0410;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
}

.camera-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  border: none;
  aspect-ratio: unset;
  background: #0a0410;
}

.cam-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  padding: 1.2rem 0.7rem 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.5rem;
}

.cam-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  flex-shrink: 0;
}

.cam-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cam-btn {
  width: auto;
  padding: 0.28rem 0.5rem;
  font-size: 1rem;
  line-height: 1.1;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
  min-height: unset;
}

.cam-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: none;
}

.cam-btn-active {
  background: rgba(210, 50, 50, 0.7) !important;
  border-color: rgba(255, 90, 90, 0.55) !important;
}

.cam-vol-wrap {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(0, 0, 0, 0.45);
  padding: 0.28rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.cam-vol-icon {
  font-size: 0.75rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.7);
}

.cam-vol {
  width: 72px;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  cursor: pointer;
  border: none;
  padding: 0;
  min-height: unset;
}

.cam-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.cam-vol::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
}

.cam-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  padding: 0 1rem;
  width: 100%;
}

.camera-section-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  gap: 1rem;
}

.cam-rtc-status {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.cam-footer-btn {
  font-size: 0.85rem;
  flex-shrink: 0;
}

@media (max-width: 680px) {
  .camera-tiles {
    grid-template-columns: 1fr;
  }

  .camera-tile {
    aspect-ratio: 4 / 3;
  }
}

/* ── Floating Video Panel ──────────────────────────────────────────────────── */
.video-float {
  position: fixed;
  z-index: 290;
  top: 74px;
  left: 1.5rem;
  width: 360px;
  background: rgba(8, 3, 16, 0.93);
  border: 1px solid rgba(143, 76, 240, 0.35);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 240px;
  max-width: 700px;
  resize: both;
  user-select: none;
}

.vf-hdr {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.36rem 0.55rem;
  background: rgba(143, 76, 240, 0.13);
  border-bottom: 1px solid rgba(143, 76, 240, 0.22);
  cursor: grab;
  flex-shrink: 0;
}
.vf-hdr:active { cursor: grabbing; }

.vf-drag-dots {
  color: var(--ink-soft);
  font-size: 0.7rem;
  pointer-events: none;
  line-height: 1;
  letter-spacing: -1px;
}

.vf-title {
  flex: 1;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.vf-hdr-btns {
  display: flex;
  gap: 0.22rem;
  flex-shrink: 0;
}

.vf-btn {
  padding: 0.15rem 0.38rem;
  font-size: 0.84rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  color: var(--ink);
  line-height: 1.2;
  transition: background 0.15s;
}
.vf-btn:hover { background: rgba(255, 255, 255, 0.18); }

.vf-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.vf-picker-panel {
  border-bottom: 1px solid rgba(143, 76, 240, 0.2);
  max-height: 260px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.vf-search-row {
  padding: 0.4rem 0.5rem;
  flex-shrink: 0;
}

.vf-search-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  padding: 0.35rem 0.55rem;
  font-size: 0.84rem;
  outline: none;
}
.vf-search-input:focus { border-color: rgba(143, 76, 240, 0.7); }

.vf-list-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.vf-list-wrap::-webkit-scrollbar { width: 4px; }
.vf-list-wrap::-webkit-scrollbar-thumb {
  background: rgba(143, 76, 240, 0.4);
  border-radius: 2px;
}

.vf-list {
  list-style: none;
  margin: 0;
  padding: 0 0.3rem 0.3rem;
}

.vf-list .video-list-item { margin: 0; padding: 0; }

.vf-list .video-pick-btn {
  width: 100%;
  text-align: left;
  padding: 0.38rem 0.55rem;
  font-size: 0.82rem;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.vf-player-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  min-height: 160px;
}

.vf-player {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
  object-fit: contain;
  background: #000;
}

.vf-status-row {
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
  border-top: 1px solid rgba(143, 76, 240, 0.12);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* Collapsed: show only header */
.video-float.vf-collapsed .vf-body { display: none; }

/* Search filter: hide non-matching items */
.video-list-item.vf-hidden { display: none; }

@media (max-width: 600px) {
  .video-float {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    max-width: none;
    resize: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   NEW MAIN-CAM + RIGHT-PANEL LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Centre column: featured cam ─────────────────────────────────────────── */
.main-cam-area {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.main-cam-view {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
}

.main-cam-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.main-cam-footer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 14px 14px;
  flex-wrap: wrap;
}

/* pop-in slot — overlays the main cam view */
.pop-in-slot {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 36%;
  aspect-ratio: 16/9;
  background: #000;
  border: 2px solid rgba(143,76,240,0.55);
  border-radius: 8px;
  overflow: hidden;
  z-index: 12;
  resize: both;
}
.pop-in-slot video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.pop-in-name {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.12rem 0.35rem;
  pointer-events: none;
}
.pop-in-close {
  position: absolute;
  top: 3px; right: 3px;
  width: auto !important; min-height: unset !important;
  padding: 0.05rem 0.3rem !important;
  font-size: 0.72rem; line-height: 1.3;
  background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; border-radius: 4px; cursor: pointer;
  z-index: 13;
}
.pop-in-close:hover { background: rgba(200,50,50,0.7); transform: none; }

/* ── Cam thumbnail strip — inside main-cam-view ───────────────────────────── */
.cam-strip-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 15;
  background: linear-gradient(transparent, rgba(8,3,16,0.82));
  padding: 0.35rem 0.4rem 0.4rem;
}

.cam-strip {
  display: flex;
  flex-direction: row;
  gap: 0.4rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(143,76,240,0.4) transparent;
}
.cam-strip::-webkit-scrollbar { height: 4px; }
.cam-strip::-webkit-scrollbar-thumb { background: rgba(143,76,240,0.4); border-radius: 2px; }

/* Tiles in the strip are compact horizontal cards */
.cam-strip .cam-sl-tile {
  flex-shrink: 0;
  width: 140px;
  min-width: 120px;
}

/* ── Sidebar: movie list section ──────────────────────────────────────────── */
.sidebar-sect-picker {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
}
.sidebar-sect-picker .sidebar-sect-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-sect-picker .sidebar-sect-body::-webkit-scrollbar { width: 4px; }
.sidebar-sect-picker .sidebar-sect-body::-webkit-scrollbar-thumb { background: rgba(143,76,240,0.4); border-radius: 2px; }
.sidebar-sect-picker .rp-picker-panel { max-height: none; overflow: visible; }
.sidebar-sect-picker .vf-list-wrap { max-height: none; }
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 90px);
  position: sticky;
  top: 74px;
}

/* ── Section common ─────────────────────────────────────────────────────── */
.rp-sect {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.rp-sect:last-child { border-bottom: none; flex-shrink: 1; overflow: hidden; }

.rp-sect-hdr {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.55rem;
  background: rgba(143,76,240,0.1);
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
.rp-sect-hdr:hover { background: rgba(143,76,240,0.18); }

.rp-sect-title {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-collapse-btn {
  width: 18px !important; min-width: 18px; min-height: unset !important;
  height: 18px; padding: 0 !important; font-size: 0.62rem; line-height: 1;
  background: transparent; border: none; color: var(--ink-soft);
  cursor: pointer; flex-shrink: 0; border-radius: 3px; display: flex;
  align-items: center; justify-content: center;
}
.rp-collapse-btn:hover { background: rgba(255,255,255,0.12); transform: none; }
.rp-sect.rp-collapsed .rp-sect-body { display: none; }
.rp-sect.rp-collapsed .rp-collapse-btn { transform: rotate(-90deg); }

.rp-sect-body {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
.rp-sect-body::-webkit-scrollbar { width: 4px; }
.rp-sect-body::-webkit-scrollbar-thumb { background: rgba(143,76,240,0.4); border-radius: 2px; }

/* Cams section body limits */
#camsSectBody { max-height: 380px; }

/* ── Cam tiles in right panel ─────────────────────────────────────────────── */
#camSidebarList {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.35rem;
}

/* Tile tweak: fill column width */
.right-panel .cam-sl-tile {
  width: 100%;
}

/* ── Pinned indicator on tile ─────────────────────────────────────────────── */
.cam-sl-tile.cam-sl-pinned {
  border-color: rgba(250,200,50,0.65) !important;
  background: rgba(250,200,50,0.06) !important;
}
.cam-sl-tile.cam-sl-pinned .cam-sl-pin-btn {
  color: #ffd700 !important;
  border-color: rgba(255,215,0,0.6) !important;
  background: rgba(255,215,0,0.1) !important;
}

/* ── Cam tile: extra buttons we add ─────────────────────────────────────── */
.cam-sl-pin-btn { }        /* styled same as .cam-sl-star */
.cam-sl-popin-btn { }      /* styled same as .cam-sl-star */

/* ── Video section ────────────────────────────────────────────────────────── */
.rp-sect-video { flex: 1; overflow: hidden; min-height: 0; }
.rp-sect-video .rp-sect-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.rp-picker-panel {
  flex-shrink: 0;
  border-bottom: 1px solid rgba(143,76,240,0.2);
  max-height: 240px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rp-picker-panel .vf-list-wrap { max-height: 160px; }

.rp-player-wrap {
  position: relative;
  flex: 1;
  min-height: 120px;
  background: #000;
  display: flex;
  flex-direction: column;
}
.rp-player {
  flex: 1; width: 100%; min-height: 0;
  object-fit: contain; background: #000; display: block;
}
.rp-status-row {
  padding: 0.25rem 0.5rem; font-size: 0.7rem; color: var(--ink-soft);
  border-top: 1px solid rgba(143,76,240,0.12);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0;
}

/* ── Context menu ────────────────────────────────────────────────────────── */
.cam-ctx-menu {
  position: fixed;
  background: rgba(16, 6, 32, 0.96);
  border: 1px solid rgba(143,76,240,0.45);
  border-radius: 9px;
  padding: 0.3rem 0;
  z-index: 9999;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.75);
  backdrop-filter: blur(10px);
  user-select: none;
}
.cam-ctx-item {
  padding: 0.42rem 0.85rem;
  font-size: 0.84rem;
  cursor: pointer;
  white-space: nowrap;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cam-ctx-item:hover { background: rgba(143,76,240,0.22); }
.cam-ctx-item.danger { color: #ff8fb1; }
.cam-ctx-item.danger:hover { background: rgba(255,143,177,0.15); }
.cam-ctx-sep { height: 1px; background: var(--line); margin: 0.22rem 0.55rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr !important;
  }
  .main-cam-area { order: -1; }
  .right-panel { display: none !important; }
  #camsSectBody { max-height: 240px; }
  .video-panel { width: 55vw; min-width: 140px; }
}

/* ── Right panel hidden (merged into main view) ──────────────────────── */
.right-panel { display: none !important; }

/* ── Video player panel nested inside main-cam-view ───────────────────── */
.video-panel {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 300px;
  z-index: 18;
  background: rgba(8,3,16,0.88);
  border: 1px solid rgba(143,76,240,0.45);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  resize: both;
  min-width: 180px;
  display: flex;
  flex-direction: column;
}

.video-panel-hdr {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.5rem;
  background: rgba(143,76,240,0.18);
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
  border-bottom: 1px solid rgba(143,76,240,0.25);
}
.video-panel-hdr:active { cursor: grabbing; }

.video-panel-title {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-panel-btn {
  width: auto !important; min-height: unset !important;
  padding: 0.05rem 0.4rem !important;
  font-size: 0.8rem; line-height: 1.3;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18) !important;
  color: var(--ink-soft);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.video-panel-btn:hover { background: rgba(255,255,255,0.12) !important; transform: none; }

.video-panel-body {
  flex: 1;
  min-height: 0;
  background: #000;
}

.video-panel-player {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  object-fit: contain;
  background: #000;
}

.video-panel-status {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  color: var(--ink-soft);
  border-top: 1px solid rgba(143,76,240,0.15);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* Minimised: header only */
.video-panel.vp-minimised .video-panel-body,
.video-panel.vp-minimised .video-panel-status { display: none; }
.video-panel.vp-minimised { resize: none; width: auto !important; min-width: unset; }

