:root {
  --bg: #111318;
  --bg2: #1b1e26;
  --fg: #f2f3f7;
  --muted: #9aa0ad;
  --ok: #2ecc71;
  --danger: #e74c3c;
  --accent: #3b7ddd;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 20px;
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: flex; }

h1 { font-size: 34px; margin: 12px 0 4px; font-weight: 700; }
h2 { font-size: 24px; margin: 0; }
p { margin: 6px 0; color: var(--muted); }
.sub { font-size: 22px; }

.center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.big-icon { font-size: 72px; }

/* ----- шапка ----- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg2);
}
.me { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--danger);
}
.dot.on { background: var(--ok); }
.icon-btn {
  background: transparent; border: 0; color: var(--fg);
  font-size: 28px; width: 48px; height: 48px; border-radius: 50%;
}
.icon-btn:active { background: rgba(255,255,255,.1); }

.banner {
  background: #5a3a10; color: #ffe1b3; padding: 10px 18px; font-size: 17px; text-align: center;
}

/* ----- список контактов ----- */
.contacts {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.contact {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.contact .avatar { width: 64px; height: 64px; font-size: 28px; margin: 0; }
.contact .info { flex: 1; min-width: 0; }
.contact .name { font-size: 24px; font-weight: 600; }
.contact .status { font-size: 16px; color: var(--muted); }
.contact.online .status { color: var(--ok); }
.contact .call-btn {
  width: 88px; height: 88px; border-radius: 50%;
  border: 0; background: var(--ok); color: #fff; font-size: 40px;
  box-shadow: 0 6px 18px rgba(46,204,113,.35);
}
.contact .call-btn:active { transform: scale(.94); }
.contact .call-btn:disabled { background: #3a3f4b; box-shadow: none; color: #777; }

.hint { padding: 12px 18px; color: var(--muted); font-size: 15px; text-align: center; }

/* ----- аватар ----- */
.avatar {
  width: 140px; height: 140px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 60px; font-weight: 700; margin: 0 auto;
}
.avatar.ringing { animation: ring 1.2s ease-in-out infinite; }
@keyframes ring {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(59,125,221,.6); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 24px rgba(59,125,221,0); }
}

/* ----- кнопки действий ----- */
.actions {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
}
.actions.two { gap: 64px; }
.round {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: transparent; border: 0; color: var(--fg);
}
.round .glyph {
  width: 96px; height: 96px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; background: #2a2f3b; transition: transform .1s;
}
.round:active .glyph { transform: scale(.92); }
.round .label { font-size: 17px; }
.round.ok .glyph { background: var(--ok); }
.round.danger .glyph { background: var(--danger); }
.round.ctrl.off .glyph { background: #e74c3c55; text-decoration: line-through; }
.round.pulse .glyph { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46,204,113,.7); }
  50% { box-shadow: 0 0 0 20px rgba(46,204,113,0); }
}

/* ----- разговор ----- */
.screen.call { background: #000; }
#remote-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000;
}
.remote-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg);
}
#local-video {
  position: absolute; right: 14px; top: 70px;
  width: 30vw; max-width: 160px; aspect-ratio: 3/4;
  object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.4);
  background: #222;
}
.call-top {
  position: absolute; top: env(safe-area-inset-top); left: 0; right: 0;
  display: flex; justify-content: center; align-items: center; gap: 12px;
  padding: 14px; font-size: 20px; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px #000;
}
.quality { width: 12px; height: 12px; border-radius: 50%; background: #555; }
.quality.good { background: var(--ok); }
.quality.meh { background: #f1c40f; }
.quality.bad { background: var(--danger); }
.call-actions {
  position: absolute; left: 0; right: 0; bottom: 0;
  gap: 18px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
}
.call-actions .round .glyph { width: 72px; height: 72px; font-size: 30px; }
.call-actions .round .label { font-size: 14px; }

/* ----- настройки ----- */
.settings { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.settings .row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--bg2); border-radius: var(--radius); padding: 16px; font-size: 18px;
}
.settings .row.small { font-size: 13px; color: var(--muted); white-space: pre-wrap; word-break: break-all; }
.settings input[type=checkbox] { width: 28px; height: 28px; flex: none; }

/* ----- тост ----- */
.toast {
  position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%);
  background: #2a2f3b; color: var(--fg); padding: 12px 20px; border-radius: 12px;
  font-size: 17px; max-width: 90vw; text-align: center; z-index: 10;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}

.primary {
  margin-top: 20px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-size: 20px; padding: 16px 28px;
}
