/* «Звонки» — тёмная тема без лишнего: только голос, статус и три кнопки. */

:root {
  --bg: #0b0f14;
  --surface: #141b24;
  --line: #222c38;
  --text: #e9eef5;
  --muted: #8d9bad;
  --accent: #5eead4;
  --accent-deep: #14b8a6;
  --danger: #f4655f;
  --warn: #f0b429;
  --ok: #4ade80;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button, input { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.icon { width: 24px; height: 24px; flex: none; }

/* ───────────────────────────── Экраны ───────────────────────────── */

.screen { position: fixed; inset: 0; display: flex; }

.screen--sheet {
  overflow-y: auto;
  padding: calc(var(--safe-top) + 24px) calc(var(--safe-right) + 20px)
           calc(var(--safe-bottom) + 24px) calc(var(--safe-left) + 20px);
  justify-content: center;
  align-items: flex-start;
}

.sheet {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: auto 0;
}

.sheet--center { text-align: center; align-items: stretch; }

/* ───────────────────────────── Заголовки ────────────────────────── */

.brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.brand__mark { width: 60px; height: 60px; border-radius: 17px; margin-bottom: 10px; }
.brand__name { margin: 0; font-size: 26px; font-weight: 620; letter-spacing: -0.02em; }
.brand__tag { margin: 0; color: var(--muted); font-size: 14.5px; }

.title { margin: 0; font-size: 22px; font-weight: 620; letter-spacing: -0.01em; text-align: center; }

.hint { margin: 0; color: var(--muted); font-size: 13px; }

/* ───────────────────────────── Карточки ─────────────────────────── */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.assurance {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* ───────────────────────── Поля и кнопки ────────────────────────── */

.input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus { border-color: var(--accent-deep); }
.input.is-error { border-color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 13px 18px;
  font-weight: 570;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn--primary { background: var(--accent); color: #05221c; }
.btn--primary:hover:not(:disabled) { background: #7bf0dc; }

.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.btn--lg { padding: 16px 20px; font-size: 17px; }
.btn--sm { padding: 8px 14px; font-size: 13.5px; }

.row { display: flex; gap: 10px; }
.row > .btn { flex: 1 1 auto; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  cursor: pointer;
  flex: none;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.iconbtn:hover { background: rgba(255, 255, 255, 0.13); }
.iconbtn.is-on { color: var(--accent); }
.iconbtn--accent { background: var(--accent); color: #05221c; }
.iconbtn--accent:hover { background: #7bf0dc; }

/* ───────────────────────── Ссылка-приглашение ───────────────────── */

.link-box {
  display: block;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-height: 120px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.6;
}

/* ───────────────────────────── Комната ──────────────────────────── */

.screen--room { flex-direction: column; }

.stage { position: relative; flex: 1; display: flex; overflow: hidden; }

/* Экран собеседника занимает всю сцену; звук идёт отдельной дорожкой. */
.screen-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #05080c;
  z-index: 1;
}

/* Верхняя строка: предупреждение слева, замок справа */

.topbar {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 14px);
  right: calc(var(--safe-right) + 14px);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 4;
}

/* Замок держится правого края, даже когда слева ничего нет. */
.topbar .iconbtn { margin-left: auto; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 540;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  white-space: nowrap;
}

.chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.chip--ok { color: var(--ok); }
.chip--accent { color: var(--accent); }
.chip--warn { color: var(--warn); }
.chip--danger { color: var(--danger); }

/* Собеседник: шар, статус, время */

.callee {
  margin: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.orb {
  position: relative;
  width: 156px;
  height: 156px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}

/* Ореол дышит, пока ждём, и вторит голосу, когда линия открыта. */
.orb::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.26), transparent 70%);
  transform: scale(calc(0.88 + var(--level, 0) * 0.42));
  transition: transform 0.12s ease-out;
}

.orb.is-waiting::before { animation: halo 2.6s ease-in-out infinite; }

.orb__core {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, var(--accent), var(--accent-deep));
}

@keyframes halo {
  0%, 100% { transform: scale(0.78); opacity: 0.6; }
  50% { transform: scale(1.05); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .orb.is-waiting::before { animation: none; }
}

.callee__status { margin: 0; font-size: 17px; font-weight: 550; }
.callee__timer { margin: 0; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.callee__hint { margin: 0; font-size: 13px; color: var(--muted); max-width: 300px; }

/* Нижняя панель управления */

.controls {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  padding: 16px calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 22px) calc(var(--safe-left) + 16px);
  z-index: 5;
}

.ctl {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.ctl:hover { background: rgba(255, 255, 255, 0.14); }
.ctl:active { transform: scale(0.94); }

/* Выключенный микрофон — залитая кнопка с перечёркнутой иконкой. */
.ctl--mic[aria-pressed='false'] { background: var(--text); color: var(--bg); }
.ctl--mic[aria-pressed='true'] .slash { display: none; }

/* Идущий показ экрана — залитая акцентом кнопка. */
.ctl--share[aria-pressed='true'] { background: var(--accent); color: #05221c; }
.ctl--share[aria-pressed='true']:hover { background: #7bf0dc; }

.ctl--hangup { width: 64px; height: 64px; background: var(--danger); color: #fff; }
.ctl--hangup:hover { background: #f7827d; }

.ctl__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ───────────────────────────── Панели ──────────────────────────── */

.panel {
  position: absolute;
  z-index: 20;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(360px, 100%);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  animation: slide-in 0.18s ease-out;
}

@keyframes slide-in {
  from { transform: translateX(14px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 640px) {
  .panel { width: 100%; }
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
}

.panel__head h3 { margin: 0; font-size: 16px; font-weight: 600; }

.panel__close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.panel__close:hover { color: var(--text); }

.panel__body {
  padding: 0 18px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Проверочная фраза */

.sas {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
}

.sas__label { margin: 0 0 6px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.sas__words {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.4;
  word-spacing: 0.3em;
}

.facts { margin: 0; display: flex; flex-direction: column; }

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 540; }
.facts dd.is-ok { color: var(--ok); }
.facts dd.is-warn { color: var(--warn); }

.switch {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  font-size: 14px;
}

.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.18s;
  flex: none;
  margin: 0;
}

.switch input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s;
}

.switch input:checked { background: var(--accent-deep); }
.switch input:checked::after { transform: translateX(18px); }

/* ───────────────────────────── Чат ─────────────────────────────── */

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-empty { color: var(--muted); font-size: 12.5px; margin: auto 0; text-align: center; }

.bubble {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 15px;
  font-size: 14.5px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.bubble--me { align-self: flex-end; background: var(--accent-deep); color: #04211c; border-bottom-right-radius: 5px; }
.bubble--peer { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 5px; }

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 14px calc(var(--safe-bottom) + 12px);
}

.chat-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  outline: none;
}

.chat-input:focus { border-color: var(--accent-deep); }

/* ───────────────────────── Уведомления ─────────────────────────── */

.toast {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--surface);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13.5px;
  z-index: 30;
  max-width: calc(100% - 36px);
  text-align: center;
  animation: rise 0.2s ease-out;
}

@keyframes rise {
  from { transform: translate(-50%, 8px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ───────────────────────── Загрузка ────────────────────────────── */

.boot {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.boot__spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
