:root {
  --bg: #f4f6f8; --panel: #fff; --fg: #111827; --muted: #6b7280; --line: #e5e7eb; --accent: #0f766e; --accent-fg: #fff;
  --green: #16a34a; --red: #dc2626; --call-bg: #0b3b37;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0f17; --panel: #121826; --fg: #e5e7eb; --muted: #9ca3af; --line: #263041; --call-bg: #062825; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 "Noto Sans Bengali", "Hind Siliguri", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .grow { flex: 1; }
.err { color: var(--red); min-height: 1.2em; }
button, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.icon { border: none; background: none; font-size: 18px; padding: 6px 10px; }
input { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 12px; width: 100%; }

.screen { min-height: 100%; max-width: 560px; margin: 0 auto; }
#reg { display: grid; place-items: center; padding: 16px; min-height: 100vh; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; width: min(380px, 100%); display: grid; gap: 12px; text-align: center; }
.card h1 { margin: 0; color: var(--accent); }
.logo { font-size: 44px; }

.top { display: flex; align-items: center; gap: 8px; padding: 14px 16px; background: var(--accent); color: var(--accent-fg); }
.top .muted { color: #ccfbf1; }
.conn { font-size: 14px; } .conn.on { color: #86efac; } .conn.off { color: #fca5a5; }
.tabs { display: flex; background: var(--accent); }
.tabs button { flex: 1; border: none; border-radius: 0; background: none; color: #ccfbf1; padding: 10px 4px; border-bottom: 3px solid transparent; }
.tabs button.active { color: #fff; border-bottom-color: #fff; font-weight: 600; }
.badge { background: #fff; color: var(--accent); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.tab { padding: 10px 12px 24px; }
.search { margin-bottom: 8px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item .who { flex: 1; min-width: 0; }
.item .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .call-mini { border: none; background: var(--green); color: #fff; border-radius: 50%; width: 42px; height: 42px; font-size: 18px; padding: 0; }
.item .call-mini:disabled { background: var(--line); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: #99f6e4; color: #134e4a; display: grid; place-items: center; font-weight: 700; flex: none; position: relative; }
.avatar.on::after { content: ''; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 2px solid var(--panel); }
.avatar.big { width: 110px; height: 110px; font-size: 42px; margin: 0 auto; }
.st-in { color: var(--green); } .st-out { color: var(--accent); } .st-miss { color: var(--red); }

.dial-num { font-size: 26px; text-align: center; letter-spacing: 1px; margin: 8px 0 12px; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad button { font-size: 24px; padding: 14px 0; border-radius: 14px; }
.dial-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.call-btn { background: var(--green); color: #fff; border: none; padding: 14px; border-radius: 14px; font-weight: 600; }
.call-btn.alt { background: var(--accent); }

.call { position: fixed; inset: 0; max-width: none; background: var(--call-bg); color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 64px 16px 56px; text-align: center; z-index: 10; }
.call h2 { margin: 16px 0 2px; font-size: 26px; }
.call .muted { color: #a7f3d0; }
.call-state { margin-top: 14px; font-size: 18px; color: #d1fae5; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; justify-content: center; gap: 56px; }
.round { width: 70px; height: 70px; border-radius: 50%; border: none; font-size: 26px; background: rgba(255,255,255,.15); color: #fff; }
.round.red { background: var(--red); } .round.green { background: var(--green); animation: pulse 1.2s infinite; }
.round.on { background: #fff; color: var(--call-bg); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.6); } 100% { box-shadow: 0 0 0 22px rgba(22,163,74,0); } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; }

/* ---------- video + conference ---------- */
.row-search { display: flex; gap: 8px; margin-bottom: 8px; } .row-search .search { margin: 0; }
.conf-btn { white-space: nowrap; }
.item .call-mini.vid { background: var(--accent); }
.item input.pick { width: 24px; height: 24px; flex: none; }
.pick-bar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.pick-bar .call-btn { padding: 10px 14px; }
.dial-actions { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.call .call-actions { gap: clamp(14px, 6vw, 40px); flex-wrap: wrap; }
.call .round { width: 64px; height: 64px; }
.remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; }
.call.has-video .remote-video { display: block; }
.call.has-video .call-top .avatar, .call.conf .call-top .avatar.big { display: none; }
.call.has-video .call-top, .call.conf .call-top { position: relative; z-index: 2; text-shadow: 0 1px 3px #000; }
.call .call-actions { position: relative; z-index: 2; }
.local-video { position: absolute; right: 12px; top: 12px; width: 28vw; max-width: 160px; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.6); z-index: 3; background: #000; }
.call.conf { padding-top: 16px; }
.call:not(.conf) .conf-grid { display: none; }
.conf-grid { flex: 1; display: grid; gap: 6px; margin: 10px 0; grid-template-columns: 1fr; grid-auto-rows: 1fr; min-height: 0; }
.conf-grid[data-n="2"] { grid-template-rows: 1fr 1fr; }
.conf-grid[data-n="3"], .conf-grid[data-n="4"] { grid-template-columns: 1fr 1fr; }
.conf-grid[data-n="5"] { grid-template-columns: 1fr 1fr; }
.tile { position: relative; background: rgba(0,0,0,.35); border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 0; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile-av { width: 64px; height: 64px; border-radius: 50%; background: #99f6e4; color: #134e4a; display: grid; place-items: center; font-weight: 700; font-size: 26px; }
.tile-name { position: absolute; left: 8px; bottom: 6px; font-size: 13px; background: rgba(0,0,0,.45); padding: 1px 8px; border-radius: 8px; }
.add-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 60%; overflow: auto; background: var(--panel); color: var(--fg); border-radius: 18px 18px 0 0; padding: 12px; z-index: 5; text-align: left; }
.add-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#addList { display: grid; gap: 6px; } #addList button { text-align: left; }
