:root {
  --bg: #0f172a; --panel: #1e293b; --line: #334155; --text: #e2e8f0; --muted: #94a3b8; --accent: #3b82f6;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, "Segoe UI", Tahoma, sans-serif; direction: ltr; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(420px, 100%); direction: rtl; display: grid; gap: 14px; }
.card h1 { margin: 0; font-size: 28px; }
label { display: grid; gap: 6px; }
input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
#swatches { display: inline-flex; gap: 6px; vertical-align: middle; margin-inline: 8px; }
#swatches button { width: 24px; height: 24px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
#swatches button[aria-pressed="true"] { border-color: #fff; }

#app { display: flex; height: 100%; }
#stage { position: relative; flex: 1; min-width: 0; }
#canvas { display: block; width: 100%; height: 100%; }
#toolbar { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; align-items: center; background: #0f172acc; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--line); }
#toolbar button { background: var(--panel); border: 1px solid var(--line); width: 40px; height: 40px; padding: 0; font-size: 18px; }
#toolbar button.off { background: #7f1d1d; }
#hint { position: absolute; bottom: 12px; left: 12px; font-size: 13px; }
#chat { position: absolute; bottom: 40px; left: 12px; width: min(320px, calc(100% - 24px)); background: #0f172af0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; direction: rtl; }
#messages { max-height: 220px; overflow-y: auto; padding: 10px; display: grid; gap: 6px; font-size: 14px; }
#messages b { margin-inline-end: 6px; }
#chatForm input { width: 100%; border-radius: 0; border: 0; border-top: 1px solid var(--line); }

#tiles { width: 240px; background: var(--panel); border-inline-start: 1px solid var(--line); overflow-y: auto; padding: 8px; display: grid; gap: 8px; align-content: start; }
.tile { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.self video { transform: scaleX(-1); }
.tile .label { position: absolute; bottom: 4px; left: 6px; right: 6px; font-size: 12px; text-shadow: 0 1px 3px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; font-size: 42px; font-weight: 700; color: #fff; }
.tile.has-video .avatar { display: none; }

@media (max-width: 720px) {
  #app { flex-direction: column; }
  #tiles { width: 100%; height: 150px; flex-direction: row; display: flex; border-inline-start: 0; border-top: 1px solid var(--line); }
  .tile { flex: 0 0 160px; }
}

/* accounts */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tabs button { background: transparent; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.error { color: #fca5a5; min-height: 1.5em; margin: 0; }
.link { background: transparent; color: var(--muted); text-decoration: underline; padding: 4px; }
.secondary { background: var(--bg); border: 1px solid var(--line); }
.grid { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; }
