/* Звонилка — веб-телефон сотрудника (phone.olesyaloo.ru).
   Палитра побережья: галька, море, буй. Жёлтый — только у живого звонка. */

@font-face {
  font-family: "Golos Text";
  src: url("/fonts/golos-cyr.woff2") format("woff2");
  font-weight: 400 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  src: url("/fonts/golos-lat.woff2") format("woff2");
  font-weight: 400 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Unbounded";
  src: url("/fonts/unbounded-cyr.woff2") format("woff2");
  font-weight: 200 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  src: url("/fonts/unbounded-lat.woff2") format("woff2");
  font-weight: 200 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --pebble: #E6E3DE;
  --pebble-2: #D9D5CE;
  --sand: #F3F1ED;
  --sea: #0D4757;
  --sea-2: #145C70;
  --deep: #072630;
  --buoy: #F0B323;
  --decline: #C4313B;
  --ink: #17262C;
  --ink-2: #4E5E64;
  --line: rgba(23, 38, 44, .14);

  --bg: var(--pebble);
  --surface: var(--sand);
  --text: var(--ink);
  --muted: var(--ink-2);
  --rule: var(--line);
  --accent: var(--sea);
  --on-accent: #fff;
  --key: var(--sand);
  --key-press: var(--pebble-2);

  --ui: "Golos Text", system-ui, -apple-system, sans-serif;
  --display: "Unbounded", "Golos Text", system-ui, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--deep);
    --surface: #0B323E;
    --text: #E9EEEF;
    --muted: #93A7AD;
    --rule: rgba(233, 238, 239, .12);
    --accent: #5FB4C9;
    --on-accent: var(--deep);
    --key: #0B323E;
    --key-press: #124453;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--deep);
  --surface: #0B323E;
  --text: #E9EEEF;
  --muted: #93A7AD;
  --rule: rgba(233, 238, 239, .12);
  --accent: #5FB4C9;
  --on-accent: var(--deep);
  --key: #0B323E;
  --key-press: #124453;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--buoy); outline-offset: 2px; border-radius: 6px; }
svg { display: block; }
.sprite { position: absolute; }

/* ── Кнопки ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 28px; border-radius: 26px;
  font-weight: 600; font-size: 17px;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-ghost { border: 1.5px solid currentColor; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 22px; color: var(--muted); }
.icon-btn svg { width: 24px; height: 24px; }

/* ── Вход ───────────────────────────────────────────────── */
.gate {
  min-height: 100%; display: grid; place-items: center;
  padding: calc(32px + var(--safe-t)) 24px calc(32px + var(--safe-b));
}
.gate-inner { max-width: 22rem; }
.gate-mark { width: 64px; height: 64px; margin-bottom: 28px; }
.gate-title { font: 700 34px/1.1 var(--display); letter-spacing: -.01em; margin: 0 0 12px; }
.gate-text { color: var(--muted); margin: 0 0 32px; }

/* ── Каркас ─────────────────────────────────────────────── */
.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 480px; margin: 0 auto;
}
.topbar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + var(--safe-t)) 12px 8px 20px;
}
.me { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.me-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; align-self: center;
  background: var(--muted); opacity: .5;
}
.me-dot.is-ready { background: #2FA36B; opacity: 1; }
.me-dot.is-error { background: var(--decline); opacity: 1; }
.me-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-ext { color: var(--muted); font-variant-numeric: tabular-nums; }

.menu {
  position: absolute; right: 12px; top: calc(52px + var(--safe-t)); z-index: 5;
  min-width: 15rem; padding: 8px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(7, 38, 48, .18);
}
.menu-who { margin: 8px 12px 10px; color: var(--muted); font-size: 15px; }
.menu-item { width: 100%; text-align: left; padding: 12px; border-radius: 10px; color: var(--decline); font-weight: 500; }
.menu-item:active { background: var(--key-press); }

.views { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── Набор: панель-коммутатор ───────────────────────────── */
.readout {
  flex: 1; min-height: 120px;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 0 20px 20px;
}
.readout-number {
  font: 500 clamp(30px, 10vw, 44px)/1.1 var(--display);
  letter-spacing: .02em; font-variant-numeric: tabular-nums;
  min-height: 1.1em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.readout-hint { margin: 6px 0 0; color: var(--muted); font-size: 15px; min-height: 1.45em; }

.pad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 0 20px;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}
.pad button {
  position: relative;
  height: clamp(58px, 9.5vh, 76px);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font: 400 30px/1 var(--display);
  font-variant-numeric: tabular-nums;
  transition: background-color .08s;
}
.pad button small { position: absolute; margin-left: 4px; margin-top: 2px; font: 400 14px/1 var(--ui); color: var(--muted); }
.pad button:active, .pad button.is-down { background: var(--key-press); }
/* Углы панели — у самого блока, не у кнопок: это одна плата, а не плитки */
.pad { border-radius: 2px; }

.pad-actions {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 20px 20px calc(16px + 0px);
}
.pad-actions .erase { justify-self: center; }
.call-disc {
  width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sea); color: #fff;
  transition: transform .12s, opacity .12s;
}
.call-disc svg { width: 30px; height: 30px; }
.call-disc:disabled { opacity: .35; }
.call-disc:not(:disabled):active { transform: scale(.94); }

/* ── Списки ─────────────────────────────────────────────── */
.search {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 20px 8px; padding: 0 14px; height: 44px;
  background: var(--surface); border-radius: 12px; color: var(--muted);
}
.search svg { width: 20px; height: 20px; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font: inherit; color: var(--text);
}
.search input::placeholder { color: var(--muted); }

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 12px; }
.list-head {
  position: sticky; top: 0; z-index: 1;
  margin: 0; padding: 14px 20px 6px;
  background: var(--bg); color: var(--muted);
  font-size: 14px; font-weight: 600;
}
.row {
  width: 100%;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  padding: 12px 20px; text-align: left;
  border-bottom: 1px solid var(--rule);
}
.row:active { background: var(--key-press); }
.row-main { min-width: 0; }
.row-title { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 15px; }
.row-sub svg { width: 14px; height: 14px; }
.row-num { font: 500 15px/1 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; }
.row.is-missed .row-title { color: var(--decline); }
.row-time { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }

.empty { padding: 48px 28px; color: var(--muted); text-align: center; }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 6px; }

/* ── Вкладки ────────────────────────────────────────────── */
.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b));
  border-top: 1px solid var(--rule);
  background: var(--bg);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; color: var(--muted); text-decoration: none;
  font-size: 12px; font-weight: 500;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }

/* ── Экран звонка — море во всю ширину ──────────────────── */
.stage {
  position: fixed; inset: 0; z-index: 10;
  display: grid; grid-template-rows: auto 1fr auto auto;
  padding: calc(56px + var(--safe-t)) 28px calc(36px + var(--safe-b));
  background: var(--sea); color: #fff;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .stage { background: #0A3A47; }
}
.stage-top { max-width: 30rem; }
.stage-state {
  margin: 0 0 14px; font-size: 16px; color: rgba(255, 255, 255, .72);
  font-variant-numeric: tabular-nums;
}
.stage-name {
  margin: 0;
  font: 600 clamp(34px, 11vw, 56px)/1.04 var(--display);
  letter-spacing: -.015em;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.stage-sub { margin: 14px 0 0; font-size: 17px; color: rgba(255, 255, 255, .72); font-variant-numeric: tabular-nums; }

.stage-mid { display: flex; align-items: center; justify-content: center; min-height: 0; }
.stage-note { max-width: 22rem; text-align: center; color: rgba(255, 255, 255, .85); margin: 0; }
.stage-keys { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px 22px; }
.stage-keys button {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  font: 400 28px/1 var(--display);
}
.stage-keys button:active { background: rgba(255, 255, 255, .26); }

.stage-tools { display: flex; justify-content: center; gap: 36px; margin-bottom: 36px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: rgba(255, 255, 255, .85); }
.tool svg {
  width: 64px; height: 64px; padding: 19px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.tool[aria-pressed="true"] svg { background: #fff; color: var(--sea); }

.stage-actions { display: flex; justify-content: space-around; align-items: center; min-height: 80px; }
.disc { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.disc svg { width: 32px; height: 32px; }
.disc:active { transform: scale(.94); }
.disc-decline { background: var(--decline); }
.disc-answer { position: relative; background: var(--buoy); color: var(--deep); }
.stage-actions .btn-ghost { color: #fff; }

/* Единственная непрошеная анимация: буй «качается», пока звонок ждёт ответа */
.stage.is-ringing .disc-answer::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 2px solid var(--buoy);
  animation: swell 1.6s ease-out infinite;
}
@keyframes swell {
  from { transform: scale(.88); opacity: .9; }
  to   { transform: scale(1.35); opacity: 0; }
}

/* Появление экрана звонка — ответ на действие, снизу вверх */
.stage.is-entering { animation: rise .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Тост ───────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 15px;
  box-shadow: 0 10px 28px rgba(7, 38, 48, .25);
}

/* ── Комнаты (список) ───────────────────────────────────── */
.room-new { display: flex; gap: 10px; margin: 4px 20px 8px; }
.room-new input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px;
  border: 0; border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit;
}
.room-new input::placeholder { color: var(--muted); }
.room-new .btn { min-height: 48px; padding: 0 20px; border-radius: 24px; }
.row-live { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 15px; }
.row-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--buoy); }

.btn-buoy { background: var(--buoy); color: var(--deep); }
.btn-danger { color: #FF8A8F; }

/* ── Комната: лобби и разговор ─────────────────────────── */
.room {
  position: fixed; inset: 0; z-index: 9;
  background: var(--deep); color: #E9EEEF;
  color-scheme: dark;
}
.room .icon-btn { color: #E9EEEF; }

.lobby {
  height: 100%; overflow-y: auto;
  padding: calc(8px + var(--safe-t)) 20px calc(24px + var(--safe-b));
}
.lobby-back { margin-left: -10px; }
.lobby-body { max-width: 26rem; margin: 8px auto 0; }
.lobby-title { margin: 0; font: 600 clamp(28px, 8vw, 40px)/1.08 var(--display); letter-spacing: -.01em; overflow-wrap: anywhere; }
.lobby-meta { margin: 10px 0 20px; color: #93A7AD; }
.lobby-preview {
  position: relative; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden;
  background: #0B323E; display: grid; place-items: center;
}
.lobby-preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.lobby-nocam { margin: 0; color: #93A7AD; }
.lobby-toggles { display: flex; justify-content: center; gap: 36px; margin: 22px 0; }
.lobby .btn-buoy { width: 100%; }
.lobby-share { margin-top: 12px; }
.lobby-share .btn { width: 100%; color: #E9EEEF; }
.lobby-hint { margin: 16px 0 0; color: #93A7AD; font-size: 15px; text-align: center; }

/* В комнате кнопка «нажата» = устройство включено; выключенное — красным. */
.room .tool svg { background: rgba(255, 255, 255, .14); color: #fff; }
.room .tool[aria-pressed="false"] svg { background: rgba(196, 49, 59, .9); }
.room .tool#c-screen[aria-pressed="false"] svg { background: rgba(255, 255, 255, .14); }
.room .tool#c-screen[aria-pressed="true"] svg { background: var(--buoy); color: var(--deep); }

.live { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
.live-top {
  display: flex; align-items: center; gap: 4px;
  padding: calc(8px + var(--safe-t)) 12px 8px 20px;
}
.live-head { flex: 1; min-width: 0; }
.live-title { margin: 0; font: 600 18px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-sub { margin: 2px 0 0; font-size: 14px; color: #93A7AD; font-variant-numeric: tabular-nums; }
.live-btn { position: relative; }
.live-btn[aria-pressed="true"] { background: rgba(255, 255, 255, .14); }
.badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #0B323E; color: #E9EEEF;
  font-size: 12px; font-weight: 600; line-height: 18px; text-align: center;
}
.badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 8px; right: 8px; background: var(--buoy); }

.live-main { position: relative; min-height: 0; display: flex; }
.grid {
  flex: 1; min-width: 0; min-height: 0;
  display: grid; gap: 8px; padding: 0 8px;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}
.tile {
  position: relative; min-height: 0; border-radius: 14px; overflow: hidden;
  background: #0B323E; display: grid; place-items: center;
}
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.is-screen video { object-fit: contain; background: #000; }
.tile.is-self video { transform: scaleX(-1); }
.tile.is-self.is-screen video { transform: none; }
.tile.is-featured { grid-column: 1 / -1; grid-row: span 2; }
.tile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sea-2); color: #fff;
  font: 600 26px/1 var(--display);
}
.tile.has-video .tile-avatar { display: none; }
.tile-name {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 10px;
  background: rgba(7, 38, 48, .72); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-name svg { width: 14px; height: 14px; flex: none; color: #FF8A8F; }

.panel {
  width: 340px; flex: none; display: flex; flex-direction: column; min-height: 0;
  margin-right: 8px; border-radius: 14px; background: #0B323E;
}
.panel > div { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.panel-title { margin: 0; padding: 14px 16px 8px; font-size: 15px; font-weight: 600; color: #93A7AD; }
.people { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.person-main { flex: 1; min-width: 0; }
.person-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 13px; color: #93A7AD; }
.person-act { padding: 6px 10px; border-radius: 8px; font-size: 13px; background: rgba(255, 255, 255, .1); }
.person-act:active { background: rgba(255, 255, 255, .2); }
.person-act.is-danger { color: #FF8A8F; }
#end-all { margin: 8px 12px 12px; }

.chat { list-style: none; margin: 0; padding: 0 16px; overflow-y: auto; flex: 1; }
.chat li { margin: 0 0 12px; }
.chat-who { font-size: 13px; color: #93A7AD; }
.chat-text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-empty { color: #93A7AD; padding: 8px 0; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgba(233, 238, 239, .12); }
.chat-form input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 0; border-radius: 22px;
  background: rgba(255, 255, 255, .1); color: #E9EEEF; font: inherit;
}

.live-bar {
  display: flex; justify-content: center; align-items: center; gap: 22px;
  padding: 14px 16px calc(14px + var(--safe-b));
}
.live-bar .tool span { font-size: 12px; }
.live-bar .tool svg { width: 56px; height: 56px; padding: 16px; }
.live-bar .disc { width: 64px; height: 64px; }

@media (max-width: 719px) {
  .panel {
    position: absolute; inset: 0; z-index: 2; width: auto; margin: 0 8px; 
  }
  .live-bar { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Широкий экран (ноутбук): та же колонка, просто по центру */
@media (min-width: 720px) {
  .app { border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }
  .stage { place-content: center; grid-template-columns: minmax(0, 30rem); }
}
