:root {
  --bg: #0b0b0f;
  --surface: #15151a;     /* cards, panel */
  --surface-2: #1e1e25;   /* inputs, secondary buttons, chips */
  --line: #2a2a32;
  --fg: #ececf1;
  --muted: #8b8b96;
  --accent: #14b8c6;      /* one brand accent, used sparingly */
  --accent-hover: #2dd4bf;
  --ok: #34d399;
  --danger: #f0566b;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--fg);
  padding: 16px;
  line-height: 1.5;
}

/* ---- Header ---- */
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { background: none; border: 0; padding: 4px; margin: -4px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.brand:hover { opacity: .8; }
.wordmark { font-size: 19px; font-weight: 700; letter-spacing: -.02em; color: var(--fg); }
.tag { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.header-right { display: flex; align-items: center; gap: 16px; }
.online { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.15); }
.online b { color: var(--fg); font-weight: 600; }
.status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot-idle, .dot-live { width: 7px; height: 7px; border-radius: 50%; }
.dot-idle { background: var(--muted); }
.dot-live { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.15); }

/* ---- Gate card ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; max-width: 460px; margin: 56px auto; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.card h2 { margin: 0 0 10px; font-size: 21px; letter-spacing: -.01em; }
.card p { color: var(--muted); font-size: 14px; margin: 0; }
.check { display: flex; gap: 10px; align-items: center; margin: 20px 0; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.mode-choice { display: flex; gap: 10px; }
.enter-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; font-size: 15px; font-weight: 600; }
.enter-btn svg { width: 18px; height: 18px; }

/* ---- Layout: video column + chat panel, bound to the viewport ---- */
#app { display: flex; gap: 16px; align-items: stretch; height: calc(100vh - 100px); }
.stage { width: 440px; max-width: 100%; flex: 0 0 auto; display: flex; flex-direction: column; }

.videos { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.video-wrap { flex: 1 1 0; min-height: 0; position: relative; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.video-wrap video { width: 100%; height: 100%; object-fit: cover; background: #000; }
#localVideo { transform: scaleX(-1); }  /* mirror your own view; stranger is normal */
.vlabel { position: absolute; bottom: 8px; left: 8px; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg); background: rgba(0,0,0,.5); padding: 3px 8px; border-radius: 6px; backdrop-filter: blur(6px); }

/* searching / connecting overlay on the stranger box */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; gap: 16px; text-align: center; background: rgba(11,11,15,.82); }
.overlay .pulse { position: relative; width: 48px; height: 48px; }
.overlay .pulse::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--accent); opacity: .6; animation: ping 1.8s cubic-bezier(0,0,.2,1) infinite; }
.overlay .dot { position: absolute; inset: 18px; border-radius: 50%; background: var(--accent); }
@keyframes ping { 0% { transform: scale(.6); opacity: .6; } 80%,100% { transform: scale(2.1); opacity: 0; } }
.overlay-text { font-size: 14px; font-weight: 600; }
.overlay-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Right panel: interests + chat ---- */
.panel { flex: 1; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.interests-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.ib-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ib-input { background: #0e0e12; border: 1px solid var(--line); color: var(--fg); border-radius: 8px; padding: 6px 10px; font-size: 13px; width: 120px; }
.ib-input:focus { outline: none; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--fg); font-size: 13px; padding: 4px 9px; border-radius: 14px; }
.chip button { all: unset; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--fg); }
.chip.shared { background: rgba(20,184,198,.14); border-color: rgba(20,184,198,.5); }

.chat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-sys { align-self: center; font-size: 12px; color: var(--muted); text-align: center; max-width: 85%; margin: 4px 0; }
.msg { max-width: 76%; padding: 8px 12px; border-radius: 14px; font-size: 14px; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }

.chat-footer { display: flex; align-items: center; gap: 8px; padding: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.chat-input { flex: 1 1 140px; min-width: 90px; background: #0e0e12; border: 1px solid var(--line); color: var(--fg); border-radius: 9px; padding: 10px 12px; font-size: 14px; }
.chat-input:focus { outline: none; border-color: var(--accent); }

.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; min-height: 16px; }

/* ---- Buttons (restrained: one accent, no glows) ---- */
button {
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background .12s, border-color .12s, opacity .12s, transform .06s;
}
button:hover:not(:disabled) { background: #26262e; border-color: #34343d; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* primary actions: solid accent, no gradient, no glow */
#startBtn, #nextBtn, .send, .enter-btn:not(.ghost) {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
#startBtn:hover:not(:disabled), #nextBtn:hover:not(:disabled),
.send:hover:not(:disabled), .enter-btn:not(.ghost):hover:not(:disabled) {
  background: var(--accent-hover); border-color: var(--accent-hover);
}
button.danger { background: transparent; border-color: var(--line); color: var(--muted); }
button.danger:hover:not(:disabled) { background: rgba(240,86,107,.1); border-color: rgba(240,86,107,.5); color: var(--danger); }

.act { padding: 10px 14px; }
.big-start { flex: 1 1 auto; padding: 14px 24px; font-size: 15px; }
#stopBtn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
kbd { font-family: ui-monospace, Menlo, monospace; font-size: 10px; font-weight: 600; background: rgba(255,255,255,.15); border-radius: 4px; padding: 1px 5px; margin-left: 5px; }

/* text mode: no video column, centered chat */
#app.mode-text .stage { display: none; }
#app.mode-text .panel { max-width: 720px; margin: 0 auto; }

@media (max-width: 760px) {
  /* Page scrolls; the action bar (Start/Stop + chat input) is pinned to the
     bottom so the primary action is ALWAYS reachable without scrolling. */
  #app { flex-direction: column; height: auto; padding-bottom: 78px; }
  .stage { width: 100%; }
  .videos { display: block; }
  .video-wrap { aspect-ratio: 4/3; max-height: 42vh; margin-bottom: 10px; }
  .panel { overflow: visible; border: 0; background: transparent; }
  .panel .interests-bar { border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
  .panel .chat-log { background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); min-height: 160px; }
  .chat-footer {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
}
