/* VedPortal — tuned for the HyperPixel 4.0 (800x480) touchscreen and phones.
   Big targets, high contrast. */

:root {
  --bg: #0f1226;
  --bg-2: #171a3a;
  --bg-3: #23264f;
  --accent: #4fc3f7;
  --answer: #34c759;
  --hangup: #ff3b30;
  --text: #ffffff;
  --muted: #9aa0c0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.screen[hidden] { display: none !important; }

/* ---- Auth ---- */
.screen-auth { align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, var(--bg-2), var(--bg)); }
.auth-card { width: min(92vw, 380px); background: var(--bg-2);
  border-radius: 20px; padding: 24px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.brand { text-align: center; font-size: 28px; margin-bottom: 16px; color: var(--accent); }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 10px; border: none; border-radius: 10px;
  background: var(--bg-3); color: var(--muted); font-size: 15px; cursor: pointer; }
.auth-tab.active { background: var(--accent); color: #06263a; font-weight: 700; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input { padding: 14px; border-radius: 10px; border: 1px solid #2a2d55;
  background: #0e1030; color: #fff; font-size: 16px; }
.btn-primary { padding: 14px; border: none; border-radius: 10px; background: var(--accent);
  color: #06263a; font-size: 16px; font-weight: 700; cursor: pointer; }
.auth-error { margin-top: 12px; text-align: center; font-size: 14px; min-height: 20px; }
.auth-error[data-kind="err"] { color: var(--hangup); }
.auth-error[data-kind="ok"] { color: var(--answer); }

/* ---- Home ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.title { font-size: 22px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.chip-link { font-size: 13px; color: var(--accent); text-decoration: none;
  background: rgba(79,195,247,.12); padding: 6px 10px; border-radius: 999px; }
.self-id { font-size: 13px; color: var(--muted); background: rgba(255,255,255,.06);
  padding: 4px 10px; border-radius: 999px; }

.contact-grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px; padding: 16px; align-content: center; justify-items: center; overflow-y: auto; }
.empty-note { color: var(--muted); grid-column: 1 / -1; text-align: center; }

.contact { position: relative; background: var(--bg-2); border: none; border-radius: 24px;
  padding: 14px; width: 100%; max-width: 200px; display: flex; flex-direction: column;
  align-items: center; gap: 10px; color: var(--text); cursor: pointer;
  transition: transform .08s ease, background .2s ease; }
.contact:active { transform: scale(.95); background: var(--bg-3); }
.contact-photo { width: 110px; height: 110px; border-radius: 50%; background-size: cover;
  background-position: center; background-color: #2a2d55; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.contact-photo--initial { display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 700; color: var(--accent); }
.contact-name { font-size: 20px; font-weight: 600; }
.presence-dot { position: absolute; top: 16px; right: 16px; width: 15px; height: 15px;
  border-radius: 50%; background: #555a80; border: 2px solid var(--bg-2); }
.contact[data-online="true"] .presence-dot { background: var(--answer); }

/* distinct avatar colors */
.contact:nth-child(6n+1) .contact-photo--initial { background:#4fc3f7; color:#06263a; }
.contact:nth-child(6n+2) .contact-photo--initial { background:#ff8a65; color:#3a1200; }
.contact:nth-child(6n+3) .contact-photo--initial { background:#81c784; color:#072a10; }
.contact:nth-child(6n+4) .contact-photo--initial { background:#ba68c8; color:#2a0733; }
.contact:nth-child(6n+5) .contact-photo--initial { background:#ffd54f; color:#3a2f00; }
.contact:nth-child(6n+6) .contact-photo--initial { background:#4db6ac; color:#05302b; }

/* ---- Status (ringing) ---- */
.screen-status { align-items: center; justify-content: center; gap: 28px;
  background: radial-gradient(circle at 50% 40%, var(--bg-2), var(--bg)); }
.big-photo { width: 180px; height: 180px; border-radius: 50%; background: #2a2d55;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.status-text { font-size: 24px; font-weight: 600; }
.status-text span { color: var(--accent); }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{transform:scale(1);box-shadow:0 8px 30px rgba(79,195,247,.3);}
  50%{transform:scale(1.06);box-shadow:0 8px 44px rgba(79,195,247,.6);} }
.answer-row { display: flex; gap: 40px; }
.btn { border: none; cursor: pointer; color: #fff; }
.big-round { width: 90px; height: 90px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 42px; box-shadow: 0 6px 18px rgba(0,0,0,.4); transition: transform .08s; }
.big-round:active { transform: scale(.92); }
.btn-answer { background: var(--answer); }
.btn-hangup { background: var(--hangup); }

/* ---- In-call (group) ---- */
.screen-call { background: #000; }
.incall-top { position: absolute; top: 0; left: 0; right: 0; z-index: 4; padding: 10px 16px;
  background: linear-gradient(rgba(0,0,0,.6), transparent); }
.incall-title { font-size: 18px; font-weight: 600; text-shadow: 0 1px 4px #000; }

/* remote tiles grid: 1 fills, 2 side-by-side, 3-4 quadrants */
.remote-tiles { position: absolute; inset: 0; display: grid; gap: 2px; background: #000; }
.remote-tiles[data-count="0"], .remote-tiles[data-count="1"] { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.remote-tiles[data-count="2"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.remote-tiles[data-count="3"], .remote-tiles[data-count="4"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.remote-tile { position: relative; overflow: hidden; background: #111; }
.remote-tile video { width: 100%; height: 100%; object-fit: cover; }
.tile-label { position: absolute; left: 8px; bottom: 8px; font-size: 13px; padding: 2px 8px;
  border-radius: 8px; background: rgba(0,0,0,.5); text-shadow: 0 1px 2px #000; }

.local-video { position: absolute; right: 10px; top: 46px; width: 120px; height: 90px;
  object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.5); background: #111; z-index: 5; }

/* scrollable "add to call" strip */
.add-strip-wrap { position: absolute; left: 0; right: 0; bottom: 96px; z-index: 5; }
.add-strip { display: flex; gap: 10px; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; }
.add-strip::-webkit-scrollbar { display: none; }
.add-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(23,26,58,.8); border: none; border-radius: 14px; padding: 8px 10px; color: #fff;
  cursor: pointer; min-width: 66px; }
.add-chip-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-3);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); position: relative; }
.add-chip[data-online="true"] .add-chip-avatar::after { content: ""; position: absolute; right: 0; bottom: 0;
  width: 11px; height: 11px; border-radius: 50%; background: var(--answer); border: 2px solid var(--bg-2); }
.add-chip-name { font-size: 12px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* centered call controls at the very bottom */
.call-controls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center; gap: 28px; padding: 16px; }
.ctrl-btn { width: 64px; height: 64px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.15); color: #fff; font-size: 26px; display: flex;
  align-items: center; justify-content: center; transition: transform .08s, background .2s; }
.ctrl-btn:active { transform: scale(.92); }
.ctrl-btn[data-muted="true"] { background: var(--hangup); }
.ctrl-hangup { background: var(--hangup); }

/* ---- Edge gesture feedback overlay ---- */
#edge-feedback { position: fixed; top: 50%; transform: translateY(-50%); z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 0;
  transition: opacity .2s; pointer-events: none; }
#edge-feedback.show { opacity: 1; }
#edge-feedback[data-side="left"] { left: 16px; }
#edge-feedback[data-side="right"] { right: 16px; }
.edge-bar { width: 10px; height: 160px; background: rgba(255,255,255,.2); border-radius: 999px;
  overflow: hidden; display: flex; align-items: flex-end; }
.edge-fill { width: 100%; background: var(--accent); border-radius: 999px; }
.edge-label { font-size: 13px; background: rgba(0,0,0,.6); padding: 2px 8px; border-radius: 8px; }

.fatal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 30px; font-size: 20px; color: var(--hangup); }
