/* style.css — вёрстка StickMeet. Палитра и почерк повторяют основной
   сайт (см. public/index.html :root), чтобы продукт не выглядел чужим,
   но масштаб крупнее: это рабочий инструмент на весь экран, а не
   страница-визитка, мелкий текст тут читать целый день неудобно. */

:root {
  --red: #FA1E1E;
  --red-dim: #c41616;
  --ink: #12100f;
  --paper: #f4f1ec;
  --paper-2: #e8e3da;
  --line: #d6cfc2;
  --muted: #6d675e;
  --card: #fff;
  --shadow: #12100f;
  --green: #1eaa5a;
  --radius: 4px;
  --radius-lg: 14px;
  --ease: cubic-bezier(.34,1.4,.5,1);
  --font: 'Caveat','Comic Sans MS',cursive;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --head-h: 70px;
  --sidebar-w: 340px;
}
[data-font="normal"] {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
[data-theme="dark"] {
  --ink: #f0ece6; --paper: #131211; --paper-2: #1e1c1a;
  --line: #35312c; --muted: #9a938a; --card: #1a1817; --shadow: #000; --red-dim: #ff5757;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --ink: #f0ece6; --paper: #131211; --paper-2: #1e1c1a;
    --line: #35312c; --muted: #9a938a; --card: #1a1817; --shadow: #000; --red-dim: #ff5757;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 22px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* аккуратный скроллбар — дефолтный слишком грубо режет светлую бумагу */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 19px var(--font); text-decoration: none;
  padding: 11px 20px; border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--shadow); cursor: pointer; background: var(--card); color: var(--ink);
  transition: transform .12s var(--ease), box-shadow .12s, background .16s;
}
.btn:hover { transform: translate(1px,1px); box-shadow: 2px 2px 0 var(--shadow); }
.btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--shadow); }
.btn-primary { background: var(--red); border-color: var(--ink); color: #fff; }
.btn-secondary { background: var(--card); }
.btn-sm { padding: 6px 14px; font-size: 16px; box-shadow: 2px 2px 0 var(--shadow); }

/* ── экран входа ── */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; }
.gate-card {
  width: min(420px, 92vw); text-align: center; background: var(--card); border: 2px solid var(--ink);
  border-radius: var(--radius); box-shadow: 7px 7px 0 var(--shadow); padding: 40px 34px;
}
.gate-logo { font-size: 46px; font-weight: 700; margin-bottom: 6px; letter-spacing: .5px; }
.gate-card p { color: var(--muted); margin-bottom: 24px; font-size: 20px; }
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-form input {
  font: 21px var(--font); padding: 12px 14px; border: 2px solid var(--ink);
  border-radius: var(--radius); background: var(--card); color: var(--ink); width: 100%; text-align: center;
  transition: box-shadow .15s;
}
.gate-form input:focus { outline: none; box-shadow: 0 0 0 3px rgba(250,30,30,.25); }
.gate-error { color: var(--red-dim); font-size: 18px; margin-top: 16px; margin-bottom: 0; }

/* ── layout ── */
.app { display: flex; flex-direction: column; height: 100vh; }
.body { flex: 1; display: flex; min-height: 0; }

.icon-btn {
  width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--card); font: 700 20px var(--font); cursor: pointer; line-height: 1;
  box-shadow: 2px 2px 0 var(--shadow); flex: none; color: var(--ink);
  display: inline-grid; place-items: center;
  transition: transform .12s var(--ease), box-shadow .12s, background .16s;
}
.icon-btn:hover { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--shadow); background: var(--paper-2); }
.only-mobile { display: none; }

/* ── шторка/модалки поверх ── */
.scrim {
  position: fixed; inset: 0; z-index: 70; background: rgba(18,16,15,.55);
  opacity: 0; pointer-events: none; transition: opacity .3s;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* ── боковая панель диалогов: своя "шапка" — единственная линия сверху,
   на той же высоте --head-h, что и шапка чата справа, чтобы линии
   совпадали в одну сплошную ── */
.sidebar {
  width: var(--sidebar-w); flex: none; border-right: 2px solid var(--ink); background: var(--paper-2);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between; height: var(--head-h);
  padding: 0 18px; border-bottom: 2px solid var(--ink); box-sizing: border-box; flex: none;
}
.sidebar-label { font-size: 15px; color: var(--muted); font-family: var(--mono); letter-spacing: .5px; text-transform: uppercase; }
.sidebar-head-actions { display: flex; align-items: center; gap: 8px; }

/* ── кнопка аккаунта — низ списка диалогов, тут живут настройки ── */
.account-bar {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-top: 2px solid var(--ink); background: var(--paper); flex: none; cursor: pointer;
  transition: background .16s;
}
.account-bar:hover { background: var(--card); }
.account-name { flex: 1; min-width: 0; font-size: 21px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.conversations { flex: 1; overflow-y: auto; }
.conv-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; padding: 13px 18px;
  border: none; border-left: 4px solid transparent; background: transparent; cursor: pointer; color: var(--ink);
  font-family: inherit; transition: background .16s;
}
.conv-item:hover { background: var(--card); }
.conv-item.active { background: var(--card); border-left-color: var(--red); }
.conv-body { min-width: 0; flex: 1; }
.conv-title { font-size: 22px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { font-size: 15px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv-empty { padding: 28px 20px; color: var(--muted); font-size: 19px; text-align: center; }

/* ── аватарки: инициалы на цвете, детерминированном от id ── */
.avatar {
  width: 48px; height: 48px; flex: none; border-radius: 50%; border: 2px solid var(--ink);
  display: grid; place-items: center; font-weight: 700; font-size: 19px; color: #fff;
  font-family: var(--mono); letter-spacing: -.5px; user-select: none;
}
.avatar.sm { width: 38px; height: 38px; font-size: 15px; }
.avatar.lg { width: 110px; height: 110px; font-size: 42px; border-width: 3px; }

/* ── чат ── */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); font-size: 24px; padding: 20px; text-align: center; }
.chat-active { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 14px; height: var(--head-h); padding: 0 22px;
  border-bottom: 2px solid var(--ink); box-sizing: border-box; flex: none; background: var(--paper);
}
.chat-title { font-size: 26px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }
.chat-back { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 22px 26px; display: flex; flex-direction: column; gap: 10px; }
.day-divider {
  align-self: center; font-size: 14px; font-family: var(--mono); color: var(--muted);
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 20px; padding: 5px 16px; margin: 12px 0;
}
.msg {
  max-width: 62%; padding: 11px 16px; border: 2px solid var(--ink); background: var(--card);
  align-self: flex-start; border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  box-shadow: 2px 2px 0 var(--shadow); animation: msgIn .22s var(--ease) both;
}
.msg.mine {
  align-self: flex-end; background: var(--red); color: #fff; border-color: var(--ink);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.msg-text { white-space: pre-wrap; word-break: break-word; font-size: 21px; }
.msg-meta { font-size: 12px; font-family: var(--mono); opacity: .65; margin-top: 4px; text-align: right; }

.send-form { display: flex; gap: 12px; padding: 16px 22px; border-top: 2px solid var(--ink); background: var(--paper); flex: none; }
.send-form textarea {
  flex: 1; resize: none; font: 21px var(--font); padding: 11px 14px; border: 2px solid var(--ink);
  border-radius: var(--radius); background: var(--card); color: var(--ink); max-height: 160px;
  transition: box-shadow .15s;
}
.send-form textarea:focus { outline: none; box-shadow: 0 0 0 3px rgba(250,30,30,.2); }

/* ── модалки ── */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(.96); z-index: 90;
  width: min(460px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: 8px 8px 0 var(--shadow); padding: 24px 26px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .24s var(--ease);
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%,-50%) scale(1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; font-size: 28px; font-weight: 700; margin-bottom: 18px; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.modal-tab {
  flex: 1; padding: 9px 6px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--paper-2);
  font: 700 18px var(--font); cursor: pointer; color: var(--ink); transition: background .16s, color .16s;
}
.modal-tab:hover { background: var(--line); }
.modal-tab.active { background: var(--red); color: #fff; }
.modal-panel { display: flex; flex-direction: column; gap: 12px; }
.modal-panel input {
  font: 20px var(--font); padding: 10px 13px; border: 2px solid var(--ink);
  border-radius: var(--radius); background: var(--card); color: var(--ink); width: 100%;
  transition: box-shadow .15s;
}
.modal-panel input:focus { outline: none; box-shadow: 0 0 0 3px rgba(250,30,30,.2); }
.modal-hint { color: var(--muted); font-size: 18px; text-align: center; padding: 8px 0; }

/* ── список выбора друзей (модалка нового диалога) ── */
.pick-list { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.pick-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 2px solid var(--ink);
  border-radius: var(--radius); background: var(--paper-2); cursor: pointer; transition: background .16s, color .16s;
}
.pick-item:hover { background: var(--line); }
.pick-item.selected { background: var(--red); color: #fff; }
.pick-item input[type="checkbox"], .pick-item input[type="radio"] { accent-color: var(--red); width: 20px; height: 20px; flex: none; }
.pick-name { font-size: 21px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--red); color: #fff; font-size: 13px; font-family: var(--mono);
  margin-left: 6px; border: 1px solid var(--ink);
}

/* ── модалка друзей ── */
.friend-section { margin-top: 20px; }
.friend-section-title { font-size: 14px; color: var(--muted); font-family: var(--mono); margin-bottom: 9px; text-transform: uppercase; letter-spacing: .5px; }
.friend-add-form { flex-direction: row !important; }
.friend-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid var(--ink);
  border-radius: var(--radius); background: var(--paper-2); margin-bottom: 8px;
}
.friend-row .friend-name { flex: 1; min-width: 0; font-size: 21px; font-weight: 700; }
.friend-row .friend-name input {
  font: 20px var(--font); padding: 4px 8px; border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--card); color: var(--ink); width: 100%;
}
.friend-row .friend-actions { display: flex; gap: 8px; flex: none; align-items: center; }

/* ── настройки: профиль / оформление / аккаунт ── */
.settings-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.settings-panel { display: flex; flex-direction: column; gap: 14px; }
.settings-panel textarea {
  font: 20px var(--font); padding: 10px 13px; border: 2px solid var(--ink);
  border-radius: var(--radius); background: var(--card); color: var(--ink); width: 100%; resize: vertical; min-height: 90px;
}
.settings-panel textarea:focus { outline: none; box-shadow: 0 0 0 3px rgba(250,30,30,.2); }
.settings-field label { display: block; font-size: 13px; color: var(--muted); font-family: var(--mono); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.font-choice { display: flex; gap: 12px; }
.font-choice label {
  flex: 1; text-align: center; padding: 16px 10px; border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--paper-2); cursor: pointer; font-size: 19px; transition: background .16s;
}
.font-choice label:hover { background: var(--line); }
.font-choice input { display: none; }
.font-choice input:checked + span { color: var(--red); font-weight: 700; }
.settings-save-hint { font-size: 18px; color: var(--muted); font-family: var(--mono); word-break: break-all; }

/* ── звонки: полноэкранный слой поверх всего ── */
.call-layer {
  position: fixed; inset: 0; z-index: 120; background: #0d0c0b;
  display: none; flex-direction: column; color: #f0ece6;
}
.call-layer.open { display: flex; }

.call-stage { flex: 1; position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.call-remote-video { width: 100%; height: 100%; object-fit: cover; background: #0d0c0b; }
.call-local-video {
  position: absolute; right: 22px; bottom: 22px; width: 210px; max-width: 34vw; aspect-ratio: 4/3;
  object-fit: cover; background: #1a1817; border: 2px solid #f0ece6; border-radius: var(--radius);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6); transform: scaleX(-1); /* зеркалим себя, как в зеркале */
}
.call-local-video.hidden-video { display: none; }

/* когда видео нет (голосовой звонок) — крупная аватарка вместо чёрного экрана */
.call-poster { position: absolute; inset: 0; display: grid; place-items: center; gap: 20px; align-content: center; }
.call-poster .avatar { border-color: #f0ece6; }
.call-peer-name { font-size: 34px; font-weight: 700; text-align: center; padding: 0 20px; }
.call-status { font-size: 17px; font-family: var(--mono); color: #9a938a; text-align: center; }

.call-bar {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 22px; background: #131211; border-top: 2px solid #35312c;
}
.call-round {
  width: 66px; height: 66px; border-radius: 50%; border: 2px solid #f0ece6; background: #1e1c1a;
  color: #f0ece6; font-size: 26px; cursor: pointer; display: grid; place-items: center;
  transition: transform .12s var(--ease), background .16s;
}
.call-round:hover { transform: translateY(-2px); background: #2a2724; }
.call-round.off { background: #f0ece6; color: #131211; }
.call-round.hangup { background: var(--red); border-color: var(--red); color: #fff; }
.call-round.accept { background: var(--green); border-color: var(--green); color: #fff; }

/* входящий звонок — карточка поверх интерфейса, звонок ещё не принят */
.call-incoming {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(.96); z-index: 130;
  width: min(400px, 92vw); background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: 8px 8px 0 var(--shadow); padding: 32px 26px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .24s var(--ease);
}
.call-incoming.open { opacity: 1; pointer-events: auto; transform: translate(-50%,-50%) scale(1); }
.call-incoming .avatar { margin: 0 auto 16px; animation: ring 1.4s ease-in-out infinite; }
@keyframes ring { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
.call-incoming-name { font-size: 30px; font-weight: 700; margin-bottom: 4px; }
.call-incoming-kind { font-size: 17px; font-family: var(--mono); color: var(--muted); margin-bottom: 24px; }
.call-incoming-actions { display: flex; gap: 16px; justify-content: center; }

@media (max-width: 720px) {
  body { font-size: 20px; }
  :root { --head-h: 62px; }
  .only-mobile { display: grid; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(340px, 86vw); z-index: 20; transition: transform .3s var(--ease); }
  .sidebar.collapsed { transform: translateX(-101%); }
  .chat-back { display: inline-grid; }
  .msg { max-width: 86%; }
  .messages { padding: 16px 14px; }
  .send-form { padding: 12px 14px; }
  .call-local-video { width: 130px; right: 14px; bottom: 14px; }
  .call-round { width: 60px; height: 60px; font-size: 23px; }
}
