:root {
  --bg: #0d0d12;
  --panel: #17171f;
  --panel2: #1f1f2a;
  --text: #f2f2f5;
  --muted: #9a9aad;
  --accent: #e5484d;
  --accent2: #7c5cff;
  --border: #2a2a38;
  --green: #2fbf71;
  --warn: #f5a524;
  --danger: #e5484d;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
.error { color: var(--danger); font-size: 14px; margin-top: 8px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* top bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.logo { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.logo span { color: var(--accent); }
.online { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.online .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); display: inline-block; }

/* landing */
.landing { max-width: 860px; margin: 0 auto; padding: 36px 20px 20px; width: 100%; }
.hero h1 { font-size: clamp(30px, 6vw, 52px); line-height: 1.08; font-weight: 800; }
.hero h1 .accent { color: var(--accent); }
.hero .sub { color: var(--muted); font-size: 17px; margin: 14px 0 26px; max-width: 560px; line-height: 1.5; }
.start-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px; display: flex; flex-direction: column; gap: 12px;
}
.interest-label { font-size: 14px; font-weight: 600; }
#interests, #chatInput {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; width: 100%; outline: none;
}
#interests:focus, #chatInput:focus { border-color: var(--accent2); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 13px 18px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--muted); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }
.steps { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.step {
  flex: 1; min-width: 150px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; display: flex; gap: 10px; align-items: center;
  font-size: 14px; color: var(--muted);
}
.step b {
  background: var(--accent2); color: #fff; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.safety { margin-top: 34px; }
.safety h2 { font-size: 20px; margin-bottom: 12px; }
.safety ul { list-style: none; display: flex; flex-direction: column; gap: 9px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.safety li b { color: var(--text); }

/* chat layout */
.chat {
  flex: 1; display: grid; grid-template-columns: 1fr 340px; gap: 14px;
  padding: 14px 20px; width: 100%; max-width: 1280px; margin: 0 auto;
}
.video-area { position: relative; min-height: 0; }
.remote-wrap {
  position: relative; background: #000; border-radius: 16px; overflow: hidden;
  aspect-ratio: 16 / 10; border: 1px solid var(--border);
}
.remote-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; background: #101016; color: var(--muted);
}
.video-placeholder.hidden { display: none; }
.spinner {
  width: 42px; height: 42px; border: 4px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.remote-tag, .local-tag {
  position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.55);
  padding: 4px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
}
.video-controls { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.video-controls button {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border);
  background: rgba(20,20,28,.85); font-size: 20px; cursor: pointer; color: var(--text);
}
.video-controls button.off { background: var(--danger); }
.local-wrap {
  position: absolute; right: 14px; bottom: 14px; width: 168px; aspect-ratio: 4 / 3;
  border-radius: 12px; overflow: hidden; border: 2px solid rgba(255,255,255,.25);
  background: #000; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.local-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.local-wrap .local-tag { top: 6px; left: 6px; font-size: 11px; padding: 2px 8px; }

/* side panel */
.side {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden; min-height: 420px;
}
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-log .sys { color: var(--muted); font-size: 13px; text-align: center; background: var(--panel2); padding: 8px 10px; border-radius: 8px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 14.5px; line-height: 1.45; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--accent2); color: #fff; border-bottom-right-radius: 4px; }
.msg.stranger { align-self: flex-start; background: var(--panel2); border-bottom-left-radius: 4px; }
.msg .who { display: block; font-size: 11px; opacity: .7; margin-bottom: 2px; }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.action-row { display: flex; gap: 8px; padding: 0 10px 10px; }
.action-row button { flex: 1; padding: 11px 6px; font-size: 14px; }
.btn-danger { background: var(--danger); color: #fff; border: none; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn-warn { background: var(--warn); color: #222; border: none; border-radius: 10px; font-weight: 700; cursor: pointer; }
.side .small { padding: 0 12px 12px; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 16px; border-top: 1px solid var(--border); }

@media (max-width: 860px) {
  .chat { grid-template-columns: 1fr; }
  .remote-wrap { aspect-ratio: 4 / 3; }
  .local-wrap { width: 120px; }
  .side { min-height: 340px; }
}
