@font-face {
  font-family: 'Geist';
  src: url('fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0e0f11;
  --surface: #17191c;
  --raised: #23262a;
  --line: #23262a;
  --line-strong: #2a2d31;
  --text: #ecedee;
  --muted: #9ba1a6;
  --live: #3dd68c;
  --wait: #f5b547;
  --danger: #d93036;
  --off: #ff8a8f;
  --radius: 14px;
  --font: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 32px; border-bottom: 1px solid var(--line); }
.topbar.plain { border-bottom: 0; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--text); display: grid; place-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--line-strong); display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; border: 2px solid var(--surface); }
.avatars { display: flex; }
.avatars > * + * { margin-left: -8px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: transparent; font-weight: 500; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.btn.primary:hover { background: #fff; }
.btn.soft { background: var(--raised); border-color: var(--raised); font-weight: 600; }
.btn.soft:hover { background: #2e3237; }
.btn.lg { height: 52px; font-size: 16px; border-radius: 12px; }
.btn.icon { width: 40px; padding: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .round:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- Layout: salas ---------- */
.page { width: 100%; max-width: 1080px; margin: 0 auto; padding: 40px 32px 64px; display: flex; flex-direction: column; gap: 48px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.section-head h1, .section-head h2 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-title { font-weight: 600; font-size: 17px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: none; }
.status.live { color: var(--live); }
.status.wait { color: var(--wait); }
.status.live::before, .status.wait::before { display: block; }
.who { display: flex; align-items: center; gap: 8px; min-height: 28px; font-size: 13px; color: var(--muted); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 16px 24px; padding: 20px 24px; }
.row + .row { border-top: 1px solid var(--line); }
.row-main { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.row-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.row-title strong { font-weight: 600; font-size: 16px; }
.row-link { font-family: var(--mono); font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-state { flex: 0 1 220px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.empty { padding: 32px 24px; color: var(--muted); text-align: center; }

/* ---------- Dialogs ---------- */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 16px; padding: 24px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .6); }
dialog h3 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 500; }
.field small { color: var(--muted); font-size: 12px; }
.input { height: 44px; background: var(--bg); border: 1px solid #3a3f45; border-radius: 10px; padding: 0 12px; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.error { color: var(--off); font-size: 13px; min-height: 1em; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 14px; z-index: 50; }

/* ---------- Entrada / espera ---------- */
.center { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 48px; }
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.preview-col { flex: 1 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.preview { aspect-ratio: 16 / 10; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; position: relative; display: grid; place-items: center; overflow: hidden; }
.preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview .placeholder { width: 96px; height: 96px; border-radius: 50%; background: var(--line-strong); display: grid; place-items: center; font-size: 36px; font-weight: 600; color: var(--muted); }
.preview .note { position: absolute; top: 16px; left: 0; right: 0; text-align: center; font-size: 13px; color: var(--muted); }
.preview .controls { position: absolute; left: 0; right: 0; bottom: 20px; display: flex; justify-content: center; gap: 12px; }
.devices { display: flex; flex-wrap: wrap; gap: 8px; }
.device { flex: 1 1 200px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; height: 40px; color: var(--muted); }
.device select { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font-size: 13px; }
.device select option { background: var(--surface); }
.join-form { flex: 0 1 360px; display: flex; flex-direction: column; gap: 24px; }
.join-form h1 { margin: 0; font-size: 32px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.check input { width: 16px; height: 16px; accent-color: var(--text); }
.fine { margin: 0; font-size: 12px; color: var(--muted); }

.waiting { max-width: 560px; flex-direction: column; text-align: center; gap: 32px; }
.waiting .preview { width: 100%; max-width: 360px; }
.dots { display: flex; gap: 6px; justify-content: center; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--text); animation: pulse 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; opacity: .7; } }
.pill { display: inline-flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; font-size: 14px; }

/* ---------- Chamada ---------- */
.call { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.call-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; }
.call-top .title { display: flex; align-items: center; gap: 12px; font-weight: 600; min-width: 0; }
.call-body { flex: 1; min-height: 0; display: flex; gap: 16px; padding: 0 20px; }
.stage { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; position: relative; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.side { width: 320px; flex: none; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.side h2 { margin: 0; font-size: 16px; font-weight: 600; }
.copyline { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; }
.copyline span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12px var(--mono); color: var(--muted); }
.copyline .btn { height: 32px; padding: 0 10px; font-size: 13px; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.people .who-name { flex: 1; display: flex; flex-direction: column; font-size: 14px; }
.people .who-name small { color: var(--muted); font-size: 12px; }
.bar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 16px 20px; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--line-strong); display: grid; place-items: center; cursor: pointer; }
.round:hover { background: #33373c; }
.round.off { background: #3a1d20; color: var(--off); }
.round.on { background: var(--text); color: var(--bg); }
.leave { height: 52px; border-radius: 26px; border: 0; background: var(--danger); color: #fff; padding: 0 22px; margin-left: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.leave:hover { background: #c4282e; }

.ended { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px; text-align: center; }
.ended h1 { margin: 0; font-size: 28px; font-weight: 600; }

@media (max-width: 820px) {
  .topbar { padding: 14px 16px; }
  .page { padding: 24px 16px 48px; }
  .center { padding: 16px; gap: 24px; }
  .side { display: none; }
  .side.open { display: flex; position: fixed; inset: 64px 12px 96px; width: auto; z-index: 10; }
  .call-body { padding: 0 8px; }
  .round { width: 46px; height: 46px; }
  .leave { margin-left: 0; }
}

/* Definições de áudio/vídeo */
.dialog { width: min(420px, calc(100vw - 24px)); background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 16px; padding: 20px; }
.dialog[open] { display: flex; flex-direction: column; gap: 16px; }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h2 { margin: 0; font-size: 17px; font-weight: 600; }
.dialog select { min-height: 44px; }
.meter { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--live); transition: width .08s linear; }
.cam-preview { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 12px; background: #000; transform: scaleX(-1); }

/* Tablet/telemóvel em landscape: o vídeo ocupa o máximo */
@media (orientation: landscape) and (max-height: 520px) {
  .call-top { display: none; }
  .bar { padding: 8px 12px; }
  .call-body { padding: 8px; }
  .side.open { inset: 8px 8px 72px; }
}
