/* Токены — derived from nort.design / chertkoff.com (тёмная монохромная система,
   узкий гротеск, прямоугольные кнопки с 1px рамкой). */
:root {
  --bg: #161616;
  --white: #fff;
  --muted-35: rgba(255, 255, 255, .35);
  --muted-45: rgba(255, 255, 255, .45);
  --muted-65: rgba(255, 255, 255, .65);
  --muted-80: rgba(255, 255, 255, .8);
  --line: rgba(255, 255, 255, .12);
  --hover-fill: rgba(255, 255, 255, .2);
  --overlay: rgba(0, 0, 0, .65); /* скрим под текстом поверх видео: AA и на светлом кадре */
  /* Единственный цветовой акцент вне монохромного канона: трубка «положить».
     Осознанное исключение — для пожилой родни кнопка завершения должна быть безошибочной. */
  --danger: #d64545;
  --danger-hover: #b93a3a;
  --font: "PF Din Text Comp Pro", "Oswald", -apple-system, system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font);
  font-size: 18px;
  line-height: 26px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

:focus-visible { outline: 1px solid var(--white); outline-offset: 3px; }

/* ---------- Кнопки (фирменные: 1px рамка, прямые углы, капс) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--white);
  border-radius: 0;
  padding: 15px 30px 13px;
  font-size: 18px;
  line-height: 18px;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--white);
  background: transparent;
}
/* Filled primary — расширение канона сайта (там только контурная кнопка):
   продуктовой утилите нужна иерархия действий. */
.btn-primary { background: var(--white); color: var(--bg); }

.btn-wide { width: 100%; }

.btn:disabled { opacity: .45; cursor: default; }

/* Ховеры только для устройств с курсором — на тачах :hover «залипает»
   и спорит с инверсией aria-pressed. */
@media (hover: hover) {
  .btn:hover { background: var(--hover-fill); }
  .btn-primary:hover { background: #d9d9d9; }
  .btn:disabled:hover { background: transparent; }
  .btn-primary:disabled:hover { background: var(--white); }
}

/* ---------- Поля ввода ---------- */

.room-input,
.key-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--muted-35);
  border-radius: 0;
  padding: 15px 16px 13px;
  background: transparent;
  color: var(--white);
  font-family: var(--font);
  font-size: 18px;
  line-height: 18px;
  letter-spacing: .5px;
}
.room-input::placeholder,
.key-input::placeholder { color: var(--muted-45); text-transform: uppercase; font-size: 15px; letter-spacing: 1px; }
.room-input:focus,
.key-input:focus { outline: none; border-color: var(--white); }
.room-input:focus-visible,
.key-input:focus-visible { outline: 1px solid var(--white); outline-offset: 3px; }

/* ---------- Главная ---------- */

/* Центрирование, переживающее низкие вьюпорты (ландшафт на телефоне):
   margin:auto вместо place-items — контент не обрезается, страница скроллится. */
.page-index { display: grid; min-height: 100%; padding: 24px; }

.index-wrap { width: 100%; max-width: 420px; margin: auto; }

.brand { margin-bottom: 48px; }

.brand-kicker {
  display: block;
  font-size: 12px;
  line-height: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted-35);
  margin-bottom: 18px;
}

.brand h1 {
  font-size: clamp(40px, 11vw, 56px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.brand h1 span { font-weight: 200; }

.brand-sub { margin-top: 14px; color: var(--muted-65); font-size: 16px; line-height: 24px; }

.panel { display: grid; gap: 22px; }

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted-45);
  font-size: 12px;
  line-height: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.join-row { display: flex; gap: 10px; }
.join-row .room-input { flex: 1; }

.hint { color: var(--muted-45); font-size: 14px; line-height: 22px; }

/* ---------- Комната: экран входа ---------- */

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  padding: 24px;
  overflow-y: auto;
}

.gate-card { width: 100%; max-width: 420px; display: grid; gap: 16px; margin: auto; }

.gate-label {
  color: var(--muted-35);
  font-size: 12px;
  line-height: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.room-code {
  font-size: clamp(44px, 13vw, 72px);
  line-height: 1;
  font-weight: 200;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

.key-row { display: grid; gap: 12px; }

/* ---------- Комната: звонок ---------- */

.call { position: fixed; inset: 0; background: #000; }

.remote-video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: var(--bg);
}

.local-video {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  right: 16px;
  width: 28vw;
  max-width: 160px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 0;
  border: 1px solid var(--muted-35);
  background: var(--bg);
}

.status {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 7px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  font-size: 12px;
  line-height: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-dot {
  width: 7px; height: 7px;
  background: var(--muted-45);
}
.status[data-mode="wait"] .status-dot { background: var(--white); animation: breathe 1.6s ease-in-out infinite; }
.status[data-mode="ok"] .status-dot { background: var(--white); }
.status[data-mode="err"] .status-dot { background: var(--danger); }

@keyframes breathe { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .status[data-mode="wait"] .status-dot { animation: none; }
}

/* На узких экранах статус уходит влево, чтобы не залезать под своё видео справа */
@media (max-width: 600px) {
  .status {
    left: 16px;
    transform: none;
    max-width: calc(100vw - 28vw - 64px);
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.controls {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
}

/* Контролы звонка: те же фирменные кнопки, только квадратные под иконку */
.ctl {
  width: 56px; height: 56px;
  border: 1px solid var(--muted-65);
  border-radius: 0;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
}
@media (hover: hover) {
  .ctl:hover { background: var(--hover-fill); border-color: var(--white); }
  .ctl-hang:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
}

.ic { width: 24px; height: 24px; fill: var(--white); }

/* Состояния вкл/выкл: «выключено» — инверсия, как hover-заливка nort */
.ctl .ic-off { display: none; }
.ctl[aria-pressed="true"] { background: var(--white); border-color: var(--white); }
.ctl[aria-pressed="true"] .ic { fill: var(--bg); }
.ctl[aria-pressed="true"] .ic-on { display: none; }
.ctl[aria-pressed="true"] .ic-off { display: block; }

.ctl-hang { width: 72px; border-color: var(--danger); background: var(--danger); }
.ctl-hang .ic { fill: var(--white); }

/* ---------- Переключатель языка (как на сайте: [ EN ]) ---------- */

.lang-btn {
  font-size: 12px;
  line-height: 26px;
  color: var(--white);
  background: none;
  border: none;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 0;
  font-family: var(--font);
}
.lang-btn i { font-style: normal; color: var(--muted-35); }
.lang-corner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 16px;
  z-index: 20;
}

/* ---------- Кнопка качества и бейдж чата ---------- */

.ctl-hd {
  font-size: 15px;
  letter-spacing: 1px;
  font-weight: 400;
  color: var(--white);
  text-transform: uppercase;
}
.ctl-chat { position: relative; }
.ctl-dot {
  position: absolute;
  top: -4px; right: -4px;
  width: 10px; height: 10px;
  background: var(--danger);
}

/* ---------- Чат ---------- */

.chat {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
  width: min(420px, calc(100vw - 32px));
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--muted-35);
  z-index: 5;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.chat-x {
  background: none;
  border: none;
  color: var(--muted-65);
  font-size: 16px;
  line-height: 1;
  padding: 4px;
}
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  min-height: 80px;
}
.msg {
  justify-self: start;
  max-width: 85%;
  padding: 8px 12px 6px;
  border: 1px solid var(--line);
  font-size: 15px;
  line-height: 22px;
  overflow-wrap: anywhere;
}
.msg--own {
  justify-self: end;
  background: var(--white);
  color: var(--bg);
  border-color: var(--white);
}
.chat-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
}
.chat-row .key-input { flex: 1; padding: 10px 12px 8px; font-size: 15px; }
.chat-row .btn { padding: 10px 16px 8px; font-size: 15px; }

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 104px);
  left: 50%;
  transform: translateX(-50%);
  padding: 11px 18px 9px;
  border-radius: 0;
  background: var(--bg);
  border: 1px solid var(--muted-35);
  font-size: 14px;
  line-height: 20px;
  max-width: 90vw;
  overflow-wrap: anywhere;
  z-index: 10;
}
