:root {
  --bg: #0f1115;
  --surface: #16191f;
  --surface-2: #1d2129;
  --line: #2a2f39;
  --text: #ecebe6;
  --muted: #9b9a93;
  --accent: #e8a33d;
  --ok: #2fb36b;
  --ok-press: #26965a;
  --danger: #e5484d;
  --danger-press: #c93a3f;
  --r-field: 14px;
  --r-self: 16px;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.muted { color: var(--muted); }

.screen {
  min-height: 100dvh;
  padding: calc(16px + var(--safe-t)) 24px calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
}

/* ---------- Вход ---------- */
.login {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand { font-weight: 700; font-size: 40px; letter-spacing: -0.02em; }
.brand::after { content: ''; display: inline-block; width: 10px; height: 10px; margin-left: 6px; border-radius: 50%; background: var(--accent); }
.login p { margin: -8px 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field input {
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  color: var(--text);
  font-size: 17px;
}
.field input:focus { border-color: var(--accent); outline: none; }
.error { color: #ff8a8d; margin: 0; font-size: 15px; }

.btn {
  height: 56px;
  border-radius: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 500;
  font-size: 17px;
  padding: 0 24px;
}
.btn-primary { background: var(--text); color: var(--bg); margin-top: 8px; }
.btn-primary:disabled { opacity: .5; }
.btn-call { background: var(--ok); color: #fff; }
.btn-call:active { background: var(--ok-press); }
.btn-ghost { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- Главный ---------- */
.bar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.brand-sm { font-weight: 700; font-size: 18px; }
.me { margin-left: auto; font-size: 14px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.icon-btn:hover { color: var(--text); background: var(--surface); }

.who {
  margin: auto 0;
  padding: 32px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.who h1 { margin: 16px 0 0; font-size: clamp(36px, 11vw, 56px); line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.avatar {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 36px; font-weight: 500;
  position: relative;
}
.presence { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); }
.presence .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.presence.on { color: var(--text); }
.presence.on .dot { background: var(--accent); border-color: var(--accent); }

.actions { display: grid; gap: 12px; }
.tips { display: grid; gap: 8px; margin-top: 24px; }
.tip {
  min-height: 48px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-field);
  background: var(--surface);
  text-align: left;
  font-size: 15px;
}
.tip svg { width: 20px; height: 20px; color: var(--accent); }
.tip-text { font-size: 14px; margin: 0; }
.foot { font-size: 12px; margin: 16px 0 0; }

/* ---------- Встречи, списки ---------- */
.sec { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.small { font-size: 14px; }
.meetings { margin-top: 24px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 10px 12px 10px 16px;
  border-radius: var(--r-field);
  background: var(--surface);
}
.row-click { cursor: pointer; }
.row-click:hover { background: var(--surface-2); }
.row-text { flex: 1; min-width: 0; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-btns { display: flex; align-items: center; gap: 6px; flex: none; }
.empty { padding: 12px 0; font-size: 15px; }
.chip {
  height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 18px;
  background: var(--surface-2);
  font-size: 14px; font-weight: 500;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; }
.chip:hover { background: var(--line); }
.chip:disabled { opacity: .45; cursor: default; }
.chip-ok { background: var(--ok); color: #fff; }
.chip-ok:hover { background: var(--ok-press); }
.chip-danger { color: #ff8a8d; }
.badge { flex: none; font-size: 12px; padding: 4px 10px; border-radius: 12px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-done { color: var(--ok); }
.badge-error { color: #ff8a8d; }
.badge-recording { color: #ff8a8d; }
.badge-processing, .badge-queued { color: var(--accent); }

/* ---------- Гость ---------- */
.guest-title { margin: -8px 0 8px; font-size: clamp(28px, 8vw, 40px); line-height: 1.1; letter-spacing: -0.02em; overflow-wrap: anywhere; }
#guest .btn-ghost { margin-top: -4px; }

/* ---------- Админка ---------- */
.screen.wide { max-width: 860px; }
.panel { margin-top: 24px; }
.panel .small { margin: -4px 0 14px; }
.link-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.link-form .grow { flex: 1 1 240px; }
.link-form .btn { height: 52px; margin: 0; }
.link-form .btn svg { width: 20px; height: 20px; }
.field select {
  height: 52px; padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-field);
  font: inherit; font-size: 16px;
}
.btn-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); padding: 8px 0; font-size: 15px; }
.btn-link svg { width: 18px; height: 18px; }
.btn-link:hover { color: var(--text); }
.rec-view { margin-top: 8px; }
.rec-title { margin: 8px 0 4px; font-size: clamp(26px, 6vw, 36px); line-height: 1.15; letter-spacing: -0.02em; outline: none; border-radius: 6px; }
.rec-title:focus { box-shadow: 0 0 0 2px var(--accent); }
.rec-view > .muted { margin: 0 0 12px; font-size: 14px; }
.note-line { margin: 0 0 12px; color: var(--accent); }
.note-line.bad { color: #ff8a8d; }
#rec-video { width: 100%; max-height: 60vh; background: #000; border-radius: var(--r-field); display: block; }
#rec-video.audio { height: 54px; background: var(--surface); }
.rec-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.rec-hint { display: grid; gap: 6px; margin: 4px 0 8px; }
.rec-hint textarea {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  color: var(--text);
  font: inherit; font-size: 15px;
  resize: vertical;
}
.rec-hint textarea:focus { border-color: var(--accent); outline: none; }
.rec-sec { margin-top: 28px; }
.rec-sec p { margin: 0 0 8px; }
.rec-sec ul, .rec-sec ol { margin: 0 0 8px; padding-left: 22px; }
.tasks { list-style: none; padding: 0 !important; display: grid; gap: 6px; margin-bottom: 14px !important; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-field); background: var(--surface); cursor: pointer; }
.task input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.md h3 { font-size: 20px; margin: 20px 0 8px; }
.md h4 { font-size: 17px; margin: 16px 0 6px; }
.md p { margin: 0 0 8px; }
details.rec-sec summary { cursor: pointer; }
.transcript { white-space: pre-wrap; font: 14px/1.6 var(--font); color: var(--muted); background: var(--surface); padding: 16px; border-radius: var(--r-field); max-height: 60vh; overflow: auto; }

/* ---------- Вызов ---------- */
.ring .who { align-items: center; text-align: center; }
.ring .avatar { width: 120px; height: 120px; font-size: 48px; }
.pulse::before, .pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ring 2.4s ease-out infinite;
}
.pulse::after { animation-delay: 1.2s; }
@keyframes ring { from { transform: scale(1); opacity: .7; } to { transform: scale(1.7); opacity: 0; } }

.ring-actions { display: flex; justify-content: space-around; gap: 16px; padding-bottom: 24px; }
.ring-col { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }

.round {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
}
.round svg { width: 28px; height: 28px; }
.round-ok { background: var(--ok); }
.round-ok:active { background: var(--ok-press); }
.round-danger { background: var(--danger); }
.round-danger:active { background: var(--danger-press); }

/* ---------- Разговор ---------- */
.call {
  max-width: none;
  padding: 0;
  position: relative;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}
/* Плитки собеседников: одна — на весь экран, больше — сеткой. */
.tiles {
  position: absolute; inset: 0;
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
}
/* Несколько плиток — не под панелью кнопок и не под строкой сверху. */
.tiles:not([data-count="1"]) { top: calc(52px + var(--safe-t)); bottom: calc(96px + var(--safe-b)); padding: 0 4px; }
.tiles[data-count="2"] { grid-template-columns: 1fr; }
.tile { border-radius: 12px; }
.tiles[data-count="1"] .tile { border-radius: 0; }
.tiles[data-count="3"], .tiles[data-count="4"] { grid-template-columns: 1fr 1fr; }
.tiles[data-count="5"], .tiles[data-count="6"] { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) {
  .tiles[data-count="2"] { grid-template-columns: 1fr 1fr; }
  .tiles[data-count="5"], .tiles[data-count="6"] { grid-template-columns: 1fr 1fr 1fr; }
}
/* Кто-то показывает экран (или плитку выбрали двойным нажатием) — он крупно. */
.tiles.focus { grid-template-columns: repeat(var(--strip), 1fr); grid-template-rows: 1fr 22%; grid-auto-rows: 0; }
.tiles.focus .tile.focused { grid-column: 1 / -1; grid-row: 1; }
.tile {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile.cover video { object-fit: cover; }
.tile-info {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 16px; text-align: center;
}
.tile-name { margin: 12px 0 0; font-size: clamp(22px, 6vw, 40px); font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.tile-status { margin: 0; min-height: 1.45em; }
.tiles[data-count="1"] .avatar { width: 120px; height: 120px; font-size: 48px; }
.tiles:not([data-count="1"]) .avatar { width: 64px; height: 64px; font-size: 26px; }
.tiles:not([data-count="1"]) .tile-name { font-size: 20px; margin-top: 4px; }
.tiles.focus .tile:not(.focused) .avatar { width: 40px; height: 40px; font-size: 18px; }
.tiles.focus .tile:not(.focused) .tile-name { font-size: 14px; }
.tiles.focus .tile:not(.focused) .tile-status { display: none; }
.tile-label {
  position: absolute; left: 10px; bottom: 10px;
  padding: 4px 10px; border-radius: 12px;
  background: rgba(15, 17, 21, .72); font-size: 13px;
}
.tiles[data-count="1"] .tile-label { display: none; }

.call-top {
  position: absolute;
  top: calc(12px + var(--safe-t)); left: 16px; right: 16px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  pointer-events: none;
}
.timer, .note, .pill {
  padding: 6px 12px;
  border-radius: 16px;
  background: rgba(15, 17, 21, .72);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.note { color: var(--accent); }
.rec-badge { color: #ff8a8d; }
.pill-btn { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; }
.pill-btn svg { width: 16px; height: 16px; }
.toggle.recording { background: var(--danger); color: #fff; }
.toggle.recording svg { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

.self {
  position: absolute;
  right: 16px;
  bottom: calc(112px + var(--safe-b));
  width: 28vw;
  max-width: 180px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--r-self);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  touch-action: none;
}
.self.mirror { transform: scaleX(-1); }

.controls {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(20px + var(--safe-b));
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-radius: 44px;
  background: rgba(22, 25, 31, .86);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.toggle {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2);
}
.toggle[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
#t-mic[aria-pressed="false"] { background: var(--text); color: var(--bg); }

.unmute {
  position: absolute; left: 50%; top: 40%;
  transform: translateX(-50%);
  padding: 14px 20px;
  border-radius: 24px;
  background: var(--accent); color: var(--bg);
  font-weight: 500;
}

/* ---------- Запись вживую ---------- */
.live-form { margin: auto 0; display: flex; flex-direction: column; gap: 16px; padding: 24px 0; }
.live-form .small, .live-run .small { margin: 0; }
.btn-stop { background: var(--danger); color: #fff; }
.btn-stop:active { background: var(--danger-press); }
.btn-stop svg { width: 20px; height: 20px; }
.live-run { margin: auto 0; display: flex; flex-direction: column; gap: 20px; padding: 24px 0; }
.live-state { display: flex; align-items: center; gap: 10px; margin: 0; color: #ff8a8d; font-weight: 500; }
.live-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1.6s ease-in-out infinite; }
.live-state.saving { color: var(--accent); }
.live-state.saving .live-dot { background: var(--accent); }
.live-title { margin: 0; font-size: clamp(26px, 7vw, 36px); line-height: 1.15; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.live-timer { font-size: clamp(56px, 18vw, 88px); font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.live-meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.live-meter span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 4px; transition: width .15s linear; }

/* «В карман»: чёрный экран поверх всего, нажатия не проходят. Экран при этом
   включён (Wake Lock) — иначе телефон заглушит микрофон. */
.pocket {
  position: fixed; inset: 0; z-index: 20;
  background: #000;
  touch-action: none; user-select: none; -webkit-user-select: none;
  display: grid; place-items: end center;
  padding-bottom: calc(64px + var(--safe-b));
}
.pocket-hint {
  margin: 0; text-align: center; line-height: 1.6;
  color: #6b6f78;
  transition: opacity .6s;
}
.pocket-hint b { color: #9aa0aa; font-weight: 500; }
.pocket-hint.off { opacity: 0; }

.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--safe-b));
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: var(--r-field);
  background: var(--surface-2);
  border: 1px solid var(--line);
  z-index: 10;
}

@media (min-width: 900px) {
  .self { width: 240px; max-width: 240px; aspect-ratio: 16 / 10; bottom: 24px; }
  .controls { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse::before, .pulse::after { animation: none; opacity: .5; }
  .toggle.recording svg { animation: none; }
}
