/* Корпоративный мессенджер — веб-клиент.
   Палитра ТУРЫ86: фуксия, янтарь, золото и бирюза на тёплом белом — значения взяты
   из `tury86/styles.css` (тема «классика», тёмная — из «полночной сливы»).
   Светлая/тёмная тема выбирается по системной настройке.

   Фуксия живёт в трёх ролях, не путать:
     --brand      заливка (кнопка, аватар, счётчик) — на ней всегда белый текст;
     --brand-deep наведение на заливку;
     --brand-ink  фуксия КАК ТЕКСТ — на светлом нужен тон темнее, на тёмном светлее,
                  иначе подписи и ссылки теряют контраст. */
:root {
  --brand: #E5097F; --brand-deep: #B40764; --brand-ink: #B40764;
  --gold: #D4AF37; --aqua: #00A7D1;
  --grad: linear-gradient(120deg, #E5097F 0%, #FF003F 48%, #FFBF00 100%);
  --bg: #FFF4EC; --panel: #FFFFFF;
  --ink: #371224; --ink-soft: #7A5566;
  --line: #F0DCE7; --mine: #FAD9EA; --hover: #FCEFF7;
  --green: #17A673; --red: #E4003A;
  --shade: rgba(55, 18, 36, .22);
  --radius: 14px;
  /* шрифты сайта, самохост — см. fonts.css. Unbounded широкий и тяжёлый: он только
     для брендовых заголовков, весь интерфейс и переписка — Manrope. */
  --font-body: 'Manrope', system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Unbounded', var(--font-body);
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #D50877; --brand-deep: #E5097F; --brand-ink: #FF6AB8;
    --gold: #E5C15C; --aqua: #37C0E8;
    --bg: #170A12; --panel: #221019;
    --ink: #F7ECF2; --ink-soft: #BC93A6;
    --line: #3A2130; --mine: #40182F; --hover: #2C1622;
    --green: #35C48F; --red: #FF5C6E;
    --shade: rgba(0, 0, 0, .6);
  }
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
/* accent-color — иначе галочки и радиокнопки остаются браузерно-синими мимо всей палитры */
html { accent-color: var(--brand); }
body {
  font: 15px/1.45 var(--font-body);
  background: var(--bg); color: var(--ink);
}
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  html { color-scheme: dark; scrollbar-color: var(--brand) var(--bg); }
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); }
[hidden] { display: none !important; }

/* ---------- вход ---------- */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card {
  position: relative; overflow: hidden;
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 28px; text-align: center;
  box-shadow: 0 24px 60px -30px var(--shade);
}
/* фирменная полоса ТУРЫ86 по верхнему краю карточки входа */
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--grad); }
.auth-logo { font-size: 44px; }
.auth-card h1 { font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1.25; margin: 10px 0 6px; }
.auth-sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 18px; }
.auth-tabs { display: flex; gap: 6px; background: var(--bg); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button {
  flex: 1; border: 0; background: none; color: var(--ink-soft);
  padding: 8px; border-radius: 999px; font-weight: 600;
}
.auth-tabs button.on { background: var(--panel); color: var(--ink); box-shadow: 0 2px 8px var(--shade); }
.auth-card form { display: grid; gap: 12px; text-align: left; }
.auth-card label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.auth-card input {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 11px 12px; font-size: 15px; outline: none;
}
.auth-card input:focus { border-color: var(--brand); }
.auth-card small { font-weight: 400; color: var(--ink-soft); }
.auth-err { color: var(--red); font-size: 13px; text-align: center; }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; font-weight: 700;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
/* шапка сайдбара — кнопка «мой профиль», поэтому гасим оформление button */
.me {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  border: 0; background: none; padding: 4px 6px; margin: -4px -6px;
  color: inherit; font: inherit; text-align: left; border-radius: 12px;
}
.me:hover { background: var(--hover); }
.me-names { min-width: 0; }
.me-names b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-names span { font-size: 11px; color: var(--ink-soft); }
.icon-btn {
  border: 0; background: none; font-size: 18px; padding: 8px; border-radius: 10px;
  color: var(--ink-soft); line-height: 1;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.side-tabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.side-tabs button {
  flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 9px;
  color: var(--ink-soft); font-weight: 700; font-size: 13px;
}
.side-tabs button.on { background: var(--hover); color: var(--brand-ink); }
.side-body { flex: 1; overflow-y: auto; padding: 8px; }
.side-actions { display: flex; gap: 6px; padding: 2px 2px 8px; }
.side-actions .btn { flex: 1; padding: 8px; font-size: 12.5px; }

.ava {
  width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff;
  display: inline-grid; place-items: center; font-weight: 800; font-size: 15px; flex: none;
  position: relative; overflow: visible;
}
.ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ava .dot {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--panel);
}

.chat-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; padding: 9px 10px; border-radius: 12px; color: var(--ink);
}
.chat-item:hover { background: var(--hover); }
.chat-item.on { background: var(--mine); }
.ci-mid { flex: 1; min-width: 0; }
.ci-mid b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-mid span { display: block; font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-right { display: grid; justify-items: end; gap: 4px; font-size: 11px; color: var(--ink-soft); }
.badge {
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 800;
  min-width: 19px; height: 19px; border-radius: 999px; display: grid; place-items: center; padding: 0 5px;
}
.side-sect { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); padding: 10px 10px 4px; }

/* ---------- справочник ---------- */
.dir-search {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 8px; outline: none;
}
.dir-dept { font-weight: 800; font-size: 13px; padding: 10px 10px 4px; color: var(--brand-ink); }
.dir-user {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; padding: 8px 10px; border-radius: 12px; color: var(--ink);
}
.dir-user:hover { background: var(--hover); }
.dir-user .du-pos { font-size: 12px; color: var(--ink-soft); display: block; }

/* ---------- админ ---------- */
.adm-sect { padding: 8px 6px; }
.adm-sect h3 { font-size: 14px; margin-bottom: 8px; }
.adm-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.adm-row b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-row .mut { color: var(--ink-soft); font-size: 12px; }
.adm-add { display: flex; gap: 6px; margin-top: 8px; }
.adm-add input { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 8px 10px; }
.inv-code { font-family: ui-monospace, monospace; font-weight: 800; letter-spacing: .1em; }

/* ---------- чат ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--ink-soft); }
.empty span { font-size: 52px; display: block; margin-bottom: 10px; }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.chat-title { flex: 1; min-width: 0; }
.chat-title b { display: block; font-size: 15px; }
.chat-title span { font-size: 12px; color: var(--ink-soft); }
.chat-actions { display: flex; gap: 4px; }

.msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.day-sep { text-align: center; font-size: 12px; color: var(--ink-soft); margin: 14px 0 6px; }
.sys { text-align: center; font-size: 12.5px; color: var(--ink-soft); margin: 6px 0; }
.m { display: flex; gap: 8px; max-width: 72%; margin-top: 8px; align-items: flex-end; }
.m.mine { align-self: flex-end; flex-direction: row-reverse; }
.m .ava { width: 30px; height: 30px; font-size: 12px; }
.bubble {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; position: relative; min-width: 60px;
}
.m.mine .bubble { background: var(--mine); border-color: transparent; }
.b-who { font-size: 12.5px; font-weight: 800; color: var(--brand-ink); margin-bottom: 2px; }
.b-reply {
  border-left: 3px solid var(--brand-ink); padding: 2px 8px; margin: 2px 0 6px;
  font-size: 12.5px; color: var(--ink-soft); background: color-mix(in srgb, var(--brand) 7%, transparent);
  border-radius: 6px; cursor: pointer;
}
.b-reply b { color: var(--brand-ink); display: block; font-size: 12px; }
.b-text { white-space: pre-wrap; word-break: break-word; }
.b-meta { display: flex; gap: 6px; align-items: center; justify-content: flex-end; font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
.b-meta .edited { font-style: italic; }
.b-photo img { max-width: min(380px, 100%); max-height: 320px; border-radius: 10px; display: block; cursor: pointer; }
.b-video video { max-width: min(380px, 100%); max-height: 320px; border-radius: 10px; display: block; }
.b-file {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  padding: 4px 0;
}
.b-file .bf-ico { font-size: 26px; }
.b-file b { font-size: 13.5px; word-break: break-all; }
.b-file span { display: block; font-size: 11.5px; color: var(--ink-soft); }
.b-voice { display: flex; align-items: center; gap: 8px; min-width: 210px; }
.b-voice audio { height: 36px; max-width: 240px; }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.react {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  font-size: 12px; padding: 1px 7px;
}
.react.my { background: var(--mine); border-color: var(--brand); }
.m-menu { position: absolute; top: -14px; right: 6px; display: none; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 1px; }
.bubble:hover .m-menu { display: flex; }
.m-menu button { border: 0; background: none; font-size: 13px; padding: 3px 6px; border-radius: 7px; }
.m-menu button:hover { background: var(--hover); }
.deleted { font-style: italic; color: var(--ink-soft); }

.typing { padding: 0 20px 4px; font-size: 12.5px; color: var(--ink-soft); }

.composer-wrap { background: var(--panel); border-top: 1px solid var(--line); }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 14px 0; }
.reply-txt { flex: 1; border-left: 3px solid var(--brand-ink); padding: 2px 8px; font-size: 12.5px; color: var(--ink-soft); min-width: 0; }
.reply-txt b { color: var(--brand-ink); display: block; font-size: 12px; }
.reply-txt span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 10px 12px; }
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); background: var(--bg);
  border-radius: 12px; padding: 10px 14px; max-height: 140px; outline: none;
}
.composer textarea:focus { border-color: var(--brand); }
.icon-btn.send { color: var(--brand-ink); font-size: 20px; }
.icon-btn.rec { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.composer-lock { text-align: center; font-size: 13px; color: var(--ink-soft); padding: 12px; }

/* ---------- звонок ---------- */
.call-ov { position: fixed; inset: 0; background: rgba(23, 10, 18, .86); display: grid; place-items: center; z-index: 1000; }
.call-card { text-align: center; color: #fff; width: min(720px, 94vw); }
.call-videos { position: relative; margin-bottom: 14px; }
#remoteVideo { width: 100%; max-height: 62vh; border-radius: 16px; background: #000; }
#localVideo {
  position: absolute; right: 12px; bottom: 12px; width: 152px; border-radius: 10px;
  border: 2px solid rgba(255,255,255,.5); background: #000;
}
.call-peer { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.call-status { color: rgba(255,255,255,.75); margin-bottom: 18px; }
.call-btns { display: flex; gap: 14px; justify-content: center; }
.call-btns button {
  width: 58px; height: 58px; border-radius: 50%; border: 0; font-size: 22px;
  background: rgba(255,255,255,.14); color: #fff;
}
.call-btns button:hover { background: rgba(255,255,255,.25); }
.call-btns .accept { background: var(--green); }
.call-btns .drop { background: var(--red); }
.call-btns button.off { background: rgba(255,255,255,.55); color: #371224; }

/* ---------- прочее ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 22px; border-radius: 999px;
  font-weight: 700; font-size: 13.5px; z-index: 1200; box-shadow: 0 18px 40px -12px var(--shade);
}
.modal-ov { position: fixed; inset: 0; background: rgba(55, 18, 36, .45); display: grid; place-items: center; z-index: 900; padding: 20px; }
.modal {
  background: var(--panel); border-radius: 16px; padding: 20px;
  width: min(440px, 100%); max-height: 86vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 12px; }
.modal label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 10px; }
.modal input, .modal select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 9px 11px;
}
.modal .pick-user { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 14px; }

/* ---------- профиль ---------- */
.pf-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.pf-top .ava { width: 62px; height: 62px; font-size: 22px; }
.pf-top .btn { padding: 6px 10px; font-size: 12.5px; font-weight: 600; }
.pf-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.pf-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.pf-row span { color: var(--ink-soft); width: 128px; flex: none; }
.pf-row b { min-width: 0; word-break: break-word; font-weight: 700; }
.pf-row .mono { font-family: ui-monospace, "Cascadia Mono", monospace; letter-spacing: .02em; }
.pf-sect { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); margin: 18px 0 6px; }
.pf-dev { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.pf-dev div { flex: 1; min-width: 0; }
.pf-dev small { display: block; color: var(--ink-soft); font-size: 11.5px; }
.pf-dev .now { color: var(--green); font-weight: 700; font-size: 11.5px; }
.pf-dev button { border: 0; background: none; color: var(--red); font-size: 12.5px; font-weight: 700; padding: 4px 6px; border-radius: 8px; }
.pf-dev button:hover { background: var(--hover); }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* на десктопе кнопка «назад» не нужна: список и чат видны одновременно */
.back-btn { display: none; }

/* ---------- телефон ----------
   Экран один, поэтому список чатов и сам чат сменяют друг друга: открыли чат —
   список уезжает (.folded), кнопка «‹» возвращает обратно. */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0; z-index: 500; width: 100%; }
  .side.folded { display: none; }
  .back-btn { display: block; font-size: 26px; padding: 4px 10px; margin-left: -6px; }
  .m { max-width: 88%; }
  .msgs { padding: 12px 10px; }
  .chat-head { padding: 10px 10px; }
  .composer { padding: 8px 8px; }
  .modal { padding: 16px; border-radius: 14px; }
  .modal-btns { flex-wrap: wrap; }
  .pf-row span { width: 104px; }
  /* поля ввода мельче 16px заставляют Safari «подпрыгивать» зумом при фокусе */
  .modal input, .modal select, .composer textarea, .dir-search, .adm-add input { font-size: 16px; }
}
