/* Bora Studios look: black canvas, white type, the brand gradient as faint light. */
:root {
  color-scheme: dark;
  --bg: #000; --fg: #fff; --muted: rgb(255 255 255 / .5); --line: rgb(255 255 255 / .14);
  --card: rgb(255 255 255 / .06); --me: rgb(92 78 229 / .28); --warn: #ff6b81;
  --red: #d90133; --blue: #0014e3; --magenta: #e20eee; --cyan: #0ec6ee; --violet: #5c4ee5;
  font: 13px/1.45 "Helvetica Neue", Helvetica, "Segoe UI", system-ui, Arial, sans-serif;
  font-synthesis: none; /* no faked bold: it smears on Windows */
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); min-height: 100dvh; }
.glow {
  position: fixed; inset: -20vmax; z-index: -1; pointer-events: none; filter: blur(90px); opacity: .3;
  background:
    radial-gradient(30vmax 40vmax at 10% 0%, var(--red), transparent 70%),
    radial-gradient(30vmax 35vmax at 95% 10%, var(--blue), transparent 70%),
    radial-gradient(30vmax 35vmax at 85% 95%, var(--magenta), transparent 70%);
}
main { max-width: 720px; margin: 0 auto; padding: 16px; }
a { color: inherit; }
.row { display: flex; gap: 8px; align-items: center; }
.hint { color: var(--muted); margin: 0; }
.notice { color: var(--warn); margin: 0; }

input, textarea, button, .button { font: inherit; color: inherit; }
input:not([type=checkbox]), textarea { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .button:focus-within, a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
button, .button { background: var(--fg); color: var(--bg); border: 0; border-radius: 6px; padding: 7px 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
button.secondary, .button.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); }
button:disabled { opacity: .4; cursor: default; }

.logo { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-weight: 700; font-size: 15px; }
.logo svg { width: 15px; height: 17px; }

/* ---------- home: you in the middle, peers drifting around ---------- */
#home { display: flex; flex-direction: column; min-height: 100dvh; }
#home[hidden] { display: none; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bar input { width: 140px; text-align: right; background: none; border-color: transparent; color: var(--muted); }
.bar input:hover, .bar input:focus { border-color: var(--line); color: var(--fg); }

#space { position: relative; width: min(100%, 440px); aspect-ratio: 1; margin: auto; }
/* Orbit rings at 30% and 46% of the width from the center (see renderPeers). */
#space::before, #space::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid var(--line); pointer-events: none; }
#space::before { inset: 20%; }
#space::after { inset: 4%; border-color: rgb(255 255 255 / .07); }
#peers { list-style: none; margin: 0; padding: 0; }
/* Anchor on the bubble's center (half its height), not the bubble+label box. */
.self, #peers li { position: absolute; transform: translate(-50%, -22px); }
.self { transform: translate(-50%, -26px); }
.self { left: 50%; top: 50%; }
#no-peers { position: absolute; left: 0; right: 0; bottom: 4%; text-align: center; }

.self, .peer { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.peer { background: none; color: var(--fg); padding: 0; width: 72px; font-weight: 400; }
.dot {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: radial-gradient(circle at 32% 28%, rgb(255 255 255 / .45), transparent 50%), var(--hue, var(--violet));
  box-shadow: 0 0 24px -4px var(--hue, var(--violet));
}
.self .dot { width: 52px; height: 52px; background: radial-gradient(circle at 32% 28%, rgb(255 255 255 / .5), transparent 50%), linear-gradient(135deg, var(--red), var(--magenta) 50%, var(--blue)); }
.self .dot { position: relative; }
.self .dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--line); animation: ripple 3s ease-out infinite; }
.name { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer .name { color: var(--fg); }
.peer .dot { animation: drift 6s ease-in-out infinite alternate; animation-delay: var(--delay, 0s); transition: transform .15s; }
.peer:hover .dot { scale: 1.12; }
#peers li { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) both; }
#peers li.gone { animation: unpop .3s ease-in both; }

@keyframes drift { 0% { translate: 0 0; } 33% { translate: 3px -5px; } 66% { translate: -4px 2px; } 100% { translate: 2px 4px; } }
@keyframes pop { from { scale: 0; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes unpop { to { scale: 0; opacity: 0; } }
@keyframes ripple { from { transform: scale(1); opacity: .8; } to { transform: scale(3.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .peer .dot, #peers li, #peers li.gone, .self .dot::after { animation: none; } }

.actions { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding-bottom: 8px; }
#link-box { width: min(100%, 440px); display: flex; flex-direction: column; gap: 6px; }

/* ---------- bubble states ---------- */
.peer { position: relative; }
.peer.on .dot { outline: 2px solid var(--fg); outline-offset: 3px; }
.peer.pending .dot { outline: 2px dashed var(--muted); outline-offset: 3px; }
.peer.open .name { font-weight: 700; }
.peer.drop .dot { scale: 1.25; }
.peer .dot { position: relative; }
.peer.link .dot::after { content: "🌐"; position: absolute; right: -6px; bottom: -4px; font-size: 13px; }
.badge {
  position: absolute; top: -4px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg); animation: pop .4s cubic-bezier(.3, 1.6, .5, 1) both;
}

/* ---------- conversation panel ---------- */
#panel {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(400px, calc(100vw - 24px));
  display: flex; flex-direction: column; background: rgb(14 14 16 / .92); backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: 0 20px 60px #000c;
  animation: slide .25s ease-out both;
}
#panel header { gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
#panel .dot { width: 32px; height: 32px; font-size: 11px; flex: none; }
.who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#close { padding: 4px 9px; }
#share { padding: 4px 9px; font-size: 12px; }
#share.live { background: var(--red); border-color: var(--red); color: #fff; }
#panel.watching { width: min(960px, calc(100vw - 24px)); }
#call, #share { padding: 4px 9px; font-size: 12px; }
#call.live { background: var(--red); border-color: var(--red); color: #fff; }

/* Screen + call area at the top of the panel. */
#stage { flex: none; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 62%; }
#screen-wrap { position: relative; min-height: 0; flex: 1; border-radius: 8px; overflow: hidden; background: #000; }
#screen-wrap.pointing { cursor: crosshair; }
#screen { display: block; width: 100%; height: 100%; max-height: 50vh; object-fit: contain; }
#screen-wrap:fullscreen #screen { max-height: none; }
#laser {
  position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #fff 0 18%, #ff2448 30%, rgb(255 36 72 / .35) 60%, transparent 70%);
  box-shadow: 0 0 18px 6px rgb(255 36 72 / .55); transition: left .03s linear, top .03s linear;
}
#fullscreen { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; background: rgb(0 0 0 / .5); opacity: .7; }
#fullscreen:hover { opacity: 1; }
#tiles { display: flex; gap: 8px; justify-content: flex-end; }
#tiles:not(:has(.tile:not([hidden]))) { display: none; }
.tile { position: relative; flex: 0 0 160px; min-width: 0; width: 160px; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #111; border: 1px solid var(--line); }
#panel:not(.watching) .tile { flex-basis: 50%; width: auto; max-width: 220px; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.mine video { transform: scaleX(-1); }
.tile.voice video { visibility: hidden; }
.tile.voice::before { content: "🎙"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; }
.tile .label { position: absolute; left: 6px; bottom: 4px; font-size: 11px; text-shadow: 0 1px 3px #000; }
#unmute { align-self: center; }
.log .stat { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
#logs { flex: 1; min-height: 0; display: flex; }
.log { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.log li { max-width: 85%; align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.log li.me { align-self: flex-end; background: var(--me); }
.log li.sys { align-self: center; background: none; border: 0; color: var(--muted); font-size: 11px; }
.log li.code { max-width: 100%; width: 100%; }
.log pre { margin: 0; overflow-x: auto; white-space: pre; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Cascadia Mono", monospace; }
.log progress { width: 100%; accent-color: var(--cyan); }
.log li button { margin-top: 6px; padding: 2px 8px; font-size: 11px; }
.log li a[download] { font-size: 11px; color: var(--muted); }
#composer { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
#composer .row { justify-content: flex-end; }
#composer label:first-child { margin-right: auto; color: var(--muted); }
body.drag #panel { outline: 2px dashed var(--cyan); outline-offset: -2px; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #panel, .badge { animation: none; } }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(calc(100vw - 32px), 420px); background: #111; border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; gap: 8px; align-items: center; box-shadow: 0 10px 40px #000a; }
.toast[hidden] { display: none; }
.toast span { flex: 1; }
