/* Интерфейс в фирменном стиле Алиби: глубокий тёмно-синий фон,
   золотой акцент действий, зелёный — «живое» (речь, успех), красный — опасное. */

:root {
  --bg: #0a0d22;
  --bg-raised: linear-gradient(160deg, #171d40, #0c1026);
  --bg-flat: #12173a;
  --bg-input: #0c1026;
  --line: rgba(255, 255, 255, .12);
  --text: #f3f1e9;
  --text-dim: #7d83a6;
  --accent: #f4b24c;
  --accent-grad: linear-gradient(90deg, #ffd98a, #f4b24c);
  --on-accent: #0a0d22;
  --ok: #5fd08a;
  --danger: #e5484d;
  --radius: 12px;
}

* { box-sizing: border-box; }
/* Управление видимостью идёт атрибутом hidden — он должен побеждать
   любые авторские display:flex/grid ниже */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(120% 60% at 50% 0%, #101635 0%, #0a0d22 45%, #06080f 100%) fixed, #0a0d22;
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; cursor: pointer; }
h1 { margin: 0; font-size: 22px; line-height: 1.3; text-wrap: balance; }

/* ── Экран входа ─────────────────────────────────────────────── */
#join {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
#join-fields { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.card label { font-size: 13px; color: var(--text-dim); margin-top: 8px; }
.card input {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* меньше 16px — iOS Safari сам зумит страницу при фокусе */
}
.card input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
#join-btn {
  margin-top: 18px;
  background: var(--accent-grad);
  color: var(--on-accent);
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  padding: 12px;
}
#join-btn:disabled { opacity: .55; cursor: default; }
.error {
  margin-top: 12px;
  background: rgba(229, 72, 77, .12);
  border: 1px solid rgba(229, 72, 77, .45);
  color: #e79a9a;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
}
.note { color: var(--text-dim); font-size: 12.5px; margin: 14px 0 0; }

/* ── Каркас встречи ──────────────────────────────────────────── */
#meet {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
}
#meet-room { font-weight: 600; }
#meet-count { color: var(--text-dim); font-size: 13px; margin-left: 10px; }
#top-right { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--text-dim); }
#conn-badge {
  background: rgba(229, 72, 77, .15);
  border: 1px solid rgba(229, 72, 77, .5);
  color: #e79a9a;
  padding: 3px 10px;
  border-radius: 999px;
}

#stage { flex: 1; overflow-y: auto; padding: 16px; }

/* Демонстрации экрана */
#screens { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.screen-tile {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.screen-tile video { display: block; width: 100%; max-height: 62vh; object-fit: contain; }
.screen-tile .who {
  position: absolute;
  left: 10px; bottom: 8px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 999px;
}
.screen-tile .fs-btn {
  position: absolute;
  right: 10px; bottom: 8px;
  background: rgba(0, 0, 0, .65);
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  font-size: 12.5px;
  padding: 3px 12px;
  border-radius: 999px;
  cursor: pointer;
  /* на ПК появляется при наведении на демонстрацию */
  opacity: 0;
  transition: opacity .15s;
}
.screen-tile:hover .fs-btn,
.screen-tile .fs-btn:focus-visible { opacity: 1; }
.screen-tile .fs-btn:hover { border-color: var(--accent); }
/* на сенсорных экранах наведения нет — кнопка видна всегда */
@media (hover: none) {
  .screen-tile .fs-btn { opacity: 1; }
}
/* в полном экране видео занимает всё, плашки остаются доступными */
.screen-tile:fullscreen { border: 0; border-radius: 0; }
.screen-tile:fullscreen video { max-height: 100vh; height: 100%; }

/* Участники */
#people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.person {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.person.speaking { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: #1c2350;
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 19px;
  letter-spacing: .02em;
}
.person.speaking .avatar { background: rgba(95, 208, 138, .16); color: var(--ok); }
.pname { font-size: 13.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbadges { display: flex; gap: 6px; align-items: center; min-height: 18px; }
.badge {
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}
.badge.muted { color: #e79a9a; border-color: rgba(229, 72, 77, .5); }
.badge.share { color: var(--accent); border-color: rgba(244, 178, 76, .5); }
.kick {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 6px;
  font-size: 11.5px;
  padding: 2px 8px;
}
.kick:hover { color: #e79a9a; border-color: var(--danger); }

/* ── Панель управления ───────────────────────────────────────── */
#controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg-raised);
  flex-wrap: wrap;
}
.ctl {
  --level: 0%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 76px;
  padding: 8px 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
}
.ctl svg {
  width: 21px; height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  position: relative;
  z-index: 1;
}
.ctl span { font-size: 11.5px; color: var(--text-dim); position: relative; z-index: 1; }
.ctl:hover { border-color: var(--accent); }
.ctl.off { color: #e79a9a; border-color: rgba(229, 72, 77, .55); }
.ctl.active { border-color: var(--accent); color: var(--accent); }
.ctl.danger { color: #e79a9a; }
/* функция есть у продукта, но недоступна на этой платформе */
.ctl.unavailable { opacity: .45; }
.ctl.unavailable:hover { border-color: var(--line); }
.ctl.danger:hover { border-color: var(--danger); }
/* счётчик непрочитанных сообщений на кнопке «Чат» */
.chat-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  z-index: 2;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  font-style: normal;
}

/* уровень голоса — зелёное заполнение кнопки микрофона снизу вверх */
#btn-mic::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--level);
  background: linear-gradient(to top, rgba(95, 208, 138, .5), rgba(95, 208, 138, .12));
  transition: height .09s linear;
  pointer-events: none;
}
#btn-mic.off::before { display: none; }

/* ── Боковая панель ──────────────────────────────────────────── */
#panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(340px, 92vw);
  background: var(--bg-raised);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
#panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
#panel-close {
  background: none; border: 0;
  color: var(--text-dim);
  font-size: 22px; line-height: 1;
  padding: 2px 8px;
}
#panel-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#chat-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { font-size: 13.5px; overflow-wrap: break-word; }
.msg .from { color: var(--accent); font-weight: 600; margin-right: 6px; }
.msg.sys { color: var(--text-dim); font-size: 12.5px; }
#chat-form { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
#chat-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 16px; /* против авто-зума iOS */
}
#chat-form button {
  background: var(--accent-grad);
  border: 0; border-radius: 8px;
  color: var(--on-accent); font-weight: 600;
  padding: 0 14px;
}
#btn-attach {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  padding: 0 10px;
  display: flex;
  align-items: center;
}
#btn-attach svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
#btn-attach:hover { color: var(--accent); border-color: var(--accent); }
.file-link {
  display: inline-block;
  margin-top: 3px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid rgba(244, 178, 76, .4);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.file-link:hover { border-color: var(--accent); }
.file-thumb {
  display: block;
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  margin: 4px 0 2px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}
.viewer-box {
  max-width: 96vw;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#viewer-img {
  max-width: 96vw;
  max-height: calc(92dvh - 60px);
  border-radius: 10px;
  border: 1px solid var(--line);
  object-fit: contain;
}
.viewer-actions { display: flex; gap: 10px; }
.viewer-actions .btn-sec { text-decoration: none; color: var(--text); }
/* ── Главная страница ────────────────────────────────────────── */
#home {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.home-wrap { width: 100%; max-width: 720px; text-align: center; }
#home-title { font-size: 26px; margin: 6px 0 4px; }
.home-sub { color: var(--text-dim); margin: 0 0 26px; }
.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  text-align: left;
}
.home-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 18px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
}
.home-card:hover { border-color: var(--accent); }
.home-card svg {
  width: 26px; height: 26px;
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.home-card b { font-size: 15.5px; }
.home-card span { color: var(--text-dim); font-size: 12.5px; line-height: 1.45; }
.home-card:disabled { opacity: .6; }
.new-result {
  margin-top: 18px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  text-align: left;
  font-size: 14px;
  line-height: 1.7;
}
.nr-title { font-weight: 700; margin-bottom: 6px; color: var(--ok); }
.nr-row code {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 13px;
  word-break: break-all;
}
.nr-note { color: var(--text-dim); font-size: 12px; }
.nr-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.btn-main {
  background: var(--accent-grad);
  color: var(--on-accent);
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
}
.btn-sec {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 16px;
}
.btn-sec:hover { border-color: var(--accent); }

/* ── Попапы ──────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 6, 18, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.modal-x {
  background: none; border: 0;
  color: var(--text-dim);
  font-size: 24px; line-height: 1;
  padding: 0 6px;
}
.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-body label { font-size: 13px; color: var(--text-dim); }
.modal-body input, .modal-body select {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  max-width: 100%;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 11px 0;
  font: inherit;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.meter {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-top: 4px;
}
#mic-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #3d9f68, var(--ok));
  transition: width .09s linear;
}
.hint-line { color: var(--text-dim); font-size: 12px; }
.test-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
#active-mic { color: var(--ok); font-size: 12px; min-height: 15px; overflow-wrap: break-word; }
#spk-row { display: flex; flex-direction: column; gap: 8px; }
.mini {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 6px 10px;
  margin-top: 6px;
}
.mini:hover { color: var(--text); border-color: var(--accent); }

/* ── Служебное ───────────────────────────────────────────────── */
#banner {
  position: fixed;
  left: 50%; bottom: 86px;
  transform: translateX(-50%);
  max-width: calc(100vw - 30px);
  background: #171d40;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  z-index: 60;
  text-align: center;
}
#banner.warn { background: #2a1226; border-color: rgba(229, 72, 77, .5); color: #e79a9a; }
#btn-unlock-audio {
  position: fixed;
  left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  background: var(--accent-grad);
  color: var(--on-accent);
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  padding: 16px 22px;
  z-index: 70;
}

@media (max-width: 560px) {
  .ctl { min-width: 62px; padding: 7px 6px; }
  .ctl span { font-size: 10.5px; }
  #people { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  #meet-site { display: none; }
}

/* Телефон: чат — лист на всю ширину; сверху остаётся место под демонстрацию,
   снизу — под панель кнопок, чтобы ничего не перекрывалось */
@media (max-width: 700px) {
  #panel {
    left: 0;
    right: 0;
    width: 100%;
    top: 36dvh;
    bottom: calc(64px + env(safe-area-inset-bottom));
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
  }
  /* демонстрация целиком помещается в верхнюю зону над чатом */
  .screen-tile video { max-height: 32dvh; }
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
