/* Coforte meeting page. Dark by design (video reads best on dark). */
:root {
  --bg: #0b1120; --panel: #111a2e; --tile: #1c2740; --line: #2a3756;
  --text: #e8edf7; --muted: #9aa8c4; --accent: #2563eb; --accent-2: #3b82f6;
  --danger: #dc2626; --ok: #16a34a; --warn: #f59e0b; --radius: 12px;
  --bar: 52px; --controls: 76px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; min-height: 100dvh; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

.bar { height: var(--bar); flex: 0 0 var(--bar); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 700; letter-spacing: .2px; }
.room-name { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { margin-left: auto; font-size: 13px; color: var(--warn); }

.panel { flex: 1; overflow-y: auto; padding: 24px 16px 40px; max-width: 560px; width: 100%; margin: 0 auto; }
.panel h1 { font-size: 22px; margin: 4px 0 6px; }
.muted { color: var(--muted); margin: 0 0 14px; }
.warn { color: var(--warn); }
.error { color: #fca5a5; margin-top: 12px; }

.preview { position: relative; aspect-ratio: 16 / 10; background: #000; border-radius: var(--radius); overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--tile); }
.preview-controls { position: absolute; left: 0; right: 0; bottom: 12px; display: flex; justify-content: center; gap: 12px; }
.level { position: absolute; left: 12px; top: 12px; width: 80px; height: 6px; background: rgba(255,255,255,.15); border-radius: 3px; overflow: hidden; }
.level span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(15,23,42,.8); display: grid; place-items: center; }
.round.off, .ctl.off { background: var(--danger); }
.devices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.devices label, .name { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
select, input { font: inherit; color: var(--text); background: var(--tile); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.name { margin-bottom: 14px; }
.primary { background: var(--accent); border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 600; }
.primary:hover { background: var(--accent-2); }
.primary:disabled { opacity: .6; cursor: wait; }
.big { width: 100%; padding: 14px; font-size: 17px; }
@media (max-width: 480px) { .devices { grid-template-columns: 1fr; } }

/* ---- in the meeting ---- */
.meeting { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.stage { flex: 1; min-height: 0; display: flex; gap: 8px; padding: 8px; }
.main-area, .people { min-width: 0; min-height: 0; display: flex; gap: 8px; }
.main-area > .tile { flex: 1; }

.tile { position: relative; background: var(--tile); border-radius: var(--radius); overflow: hidden; min-width: 0; min-height: 0; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.screen video { object-fit: contain; }
.tile.self video { transform: scaleX(-1); }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; }
.tile .avatar span { width: 34%; max-width: 96px; aspect-ratio: 1; border-radius: 50%; background: #334155; display: grid; place-items: center;
  font-size: clamp(14px, 3vw, 32px); font-weight: 600; }
.tile .label { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 3px 8px; border-radius: 6px;
  background: rgba(2,6,23,.7); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .label .mute { color: #fca5a5; margin-left: 4px; }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--ok); }
.tile .presenting { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; padding: 16px; }

/* Grid: everyone the same size. */
.layout-grid .main-area { display: none; }
.layout-grid .people { flex: 1; display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }

/* Speaker and Focus: big area + a strip. Landscape: strip on the right. Portrait: strip below. */
.layout-speaker .main-area { flex: 1 1 78%; }
.layout-focus .main-area { flex: 1 1 75%; }
.layout-speaker .people, .layout-focus .people { flex: 0 0 22%; flex-direction: column; overflow-y: auto; }
.layout-speaker .people .tile, .layout-focus .people .tile { flex: 0 0 auto; aspect-ratio: 16 / 10; }
.layout-focus .people { flex-basis: 25%; }

/* Side by side: screen 50%, people 50%. */
.layout-side .main-area { flex: 1 1 50%; }
.layout-side .people { flex: 1 1 50%; display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }

/* Screen only. */
.layout-screen .people { display: none; }
.layout-screen .main-area { flex: 1; }

@media (orientation: portrait) {
  .stage { flex-direction: column; }
  .layout-speaker .people, .layout-focus .people { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .layout-speaker .people .tile, .layout-focus .people .tile { height: 100%; width: auto; }
}

.controls { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; padding: 8px 10px; border: 0;
  border-radius: 12px; background: var(--tile); }
.ctl small { font-size: 11px; color: var(--muted); }
.ctl.off small, .ctl.leave small { color: #fee2e2; }
.ctl.active { background: var(--accent); }
.ctl.active small { color: #dbeafe; }
.ctl.leave { background: var(--danger); }
.ctl svg, .round svg { width: 22px; height: 22px; display: block; }
@media (max-width: 480px) { .ctl { min-width: 0; flex: 1; padding: 8px 4px; } .ctl small { font-size: 10px; } }

.layout-wrap { position: relative; }
.menu { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); width: min(320px, 92vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; z-index: 20;
  box-shadow: 0 12px 32px rgba(0,0,0,.45); }
.menu-head { margin: 8px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.menu label { display: flex; align-items: baseline; gap: 8px; padding: 6px 2px; cursor: pointer; flex-wrap: wrap; }
.menu em { font-style: normal; color: var(--muted); font-size: 12px; }
.menu-note { font-size: 12px; color: var(--warn); margin: 8px 0 2px; }
@media (max-width: 480px) { .menu { position: fixed; left: 8px; right: 8px; bottom: calc(var(--controls) + env(safe-area-inset-bottom)); transform: none; width: auto; } }

.floating { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 15; }
.toast { position: absolute; left: 50%; bottom: calc(var(--controls) + 16px); transform: translateX(-50%); background: rgba(2,6,23,.88);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; z-index: 30; max-width: 90vw; }
