:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1d2330;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #6c8cff;
  --accent-2: #8f7bff;
  --danger: #ff5c6c;
  --warn: #ffb84d;
  --ok: #4ade80;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid #232838;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.logo { font-size: 20px; }
.brand-sub {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

.online {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  background: var(--panel);
  border: 1px solid #232838;
  padding: 6px 12px;
  border-radius: 999px;
}
.online .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  animation: pulse 2s ease infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }

/* ---------- layout ---------- */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 12px;
  gap: 12px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
  position: relative;
}

.videos {
  flex: 1;
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 14px;
  min-height: 0;
}

.video-box {
  position: relative;
  background: var(--panel);
  border: 1px solid #232838;
  border-radius: 14px;
  overflow: hidden;
  min-height: 0;
}

.video-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0c10;
  display: block;
}

.video-box .label {
  position: absolute;
  bottom: 10px;
  left: 12px;
  background: rgba(10, 12, 16, 0.65);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  backdrop-filter: blur(6px);
}

.local video { transform: scaleX(-1); }

/* ---------- remote overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 40%, #1a2030 0%, #0d0f14 80%);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid #2a3247;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  display: none;
}
.spinner.active { display: block; }

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

.status { color: var(--muted); font-size: 15px; max-width: 340px; line-height: 1.5; }
.status b { color: var(--text); }

.partner-name {
  font-size: 22px;
  font-weight: 700;
}

.topic-badge {
  font-size: 12px;
  color: var(--accent-2);
  background: rgba(143, 123, 255, 0.12);
  border: 1px solid rgba(143, 123, 255, 0.35);
  padding: 4px 12px;
  border-radius: 999px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- interests row ---------- */
.interests-row {
  display: flex;
  justify-content: center;
}

.interests-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid #2a3247;
  color: var(--text);
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s;
  max-width: 90%;
}
.interests-edit:hover { border-color: var(--accent); }
.interests-edit .pencil { color: var(--muted); font-size: 13px; }
#interestsSummary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- controls ---------- */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid #2a3247;
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 12px 26px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover:not(:disabled) { background: #26304a; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #5678f0; }

.btn.danger { border-color: #472a2f; color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: #2c1d21; }

.btn.subtle {
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  padding: 12px 18px;
}
.btn.subtle:hover:not(:disabled) { color: var(--danger); background: #2c1d21; }

.btn.muted { border-color: #472a2f; color: var(--warn); }
.mute-indicator { color: var(--warn); margin-left: 4px; }

/* ---------- banner & toast ---------- */
.error-banner {
  background: #2c1d21;
  border: 1px solid #472a2f;
  color: var(--danger);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  text-align: center;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #26304a;
  border: 1px solid #33406b;
  color: var(--text);
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 60;
  white-space: nowrap;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
}

/* ---------- interests modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-card {
  background: var(--panel);
  border: 1px solid #2a3247;
  border-radius: 16px;
  padding: 26px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h2 { font-size: 20px; margin-bottom: 6px; }
.modal-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; line-height: 1.5; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  border: 1px solid #2a3247;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { border-color: var(--accent); }
.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.custom-row { margin-bottom: 18px; }

.custom-row input {
  width: 100%;
  background: var(--bg);
  border: 1px solid #2a3247;
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  outline: none;
}
.custom-row input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.hidden { display: none !important; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 10px;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }

@media (max-width: 720px) {
  .videos { grid-template-columns: 1fr; }
  .local { order: -1; max-height: 160px; }
  .brand-sub { display: none; }
  .btn { padding: 10px 16px; font-size: 14px; }
}
