/* Банзай — личный мессенджер владельца.
   Список диалогов, внутри — настоящая переписка и готовый ответ. */

:root {
  --bg: #0f1216;
  --panel: #171c22;
  --panel-2: #212832;
  --line: #2a323d;
  --text: #e9edf2;
  --muted: #8a94a3;
  --accent: #4a9eff;
  --mine: #2b5f9e;
  --danger: #ff6b6b;
  --warn: #ffb648;
  --ok: #4ade80;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- вход */

.gate-box { margin: auto; padding: 28px 22px; width: 100%; max-width: 360px; text-align: center; }
.logo { font-size: 52px; line-height: 1; margin-bottom: 10px; }
.gate-box h1 { font-size: 24px; margin: 0 0 6px; }
.gate-box p { margin: 0 0 18px; font-size: 15px; }

input[type=password], textarea {
  width: 100%; padding: 13px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-size: 16px; font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

button { font: inherit; border: none; border-radius: 12px; padding: 13px 16px; font-weight: 600; }
button.primary { background: var(--accent); color: #07131f; }
button.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
button.icon-btn { background: transparent; color: var(--muted); padding: 6px 10px; font-size: 22px; }
button:disabled { opacity: .45; }
.gate-box button.primary { width: 100%; margin-top: 12px; }

/* ---------------------------------------------------------------- шапка */

.bar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  border-bottom: 1px solid var(--line); background: var(--bg);
  flex-shrink: 0;
}
.bar-title { flex: 1; font-size: 19px; font-weight: 700; min-width: 0; }
.chat-name { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { font-size: 12px; color: var(--muted); font-weight: 400; }
.pill {
  background: var(--accent); color: #07131f; border-radius: 999px;
  padding: 2px 9px; font-size: 13px; font-weight: 700; margin-left: 6px;
}
.pill.urgent { background: var(--danger); color: #2b0808; }
#back, #muted-back { font-size: 30px; line-height: 1; padding: 0 8px 4px; color: var(--accent); }

/* ---------------------------------------------------------------- список */

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.row {
  display: flex; gap: 12px; padding: 12px 14px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.row:active { background: var(--panel); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700; color: #07131f; background: var(--accent);
}
.avatar.urgent { background: var(--danger); color: #2b0808; }
.row-body { flex: 1; min-width: 0; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.row-text {
  color: var(--muted); font-size: 14px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-tags { margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted);
}
.tag.urgent { background: rgba(255,107,107,.18); color: var(--danger); }
.tag.warn { background: rgba(255,182,72,.15); color: var(--warn); }
.tag.late { background: rgba(255,182,72,.15); color: var(--warn); }

.empty { text-align: center; padding: 70px 20px; }
.empty p { margin: 4px 0; }

/* ---------------------------------------------------------------- переписка */

.thread {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 12px; display: flex; flex-direction: column; gap: 8px;
}
.msg { max-width: 82%; padding: 9px 13px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.msg.in  { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 5px; }
.msg.out { align-self: flex-end; background: var(--mine); border-bottom-right-radius: 5px; }
.msg-time { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.msg.in .msg-time { text-align: left; }
.day {
  align-self: center; font-size: 12px; color: var(--muted);
  background: var(--panel); padding: 3px 11px; border-radius: 999px; margin: 6px 0;
}
.thin-note {
  align-self: center; text-align: center; font-size: 12px; color: var(--muted);
  padding: 6px 14px; max-width: 90%;
}

.composer {
  border-top: 1px solid var(--line); background: var(--panel);
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  flex-shrink: 0;
}
.draft-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: 6px;
}
.composer textarea { background: var(--bg); resize: none; max-height: 40vh; }
.problems {
  margin-bottom: 8px; padding: 9px 12px; border-radius: 10px;
  background: rgba(255,182,72,.12); border: 1px solid rgba(255,182,72,.3);
  color: var(--warn); font-size: 13px;
}
.problems div + div { margin-top: 4px; }
.actions { display: flex; gap: 9px; margin-top: 9px; }
.actions button { flex: 1; }
.actions .primary { flex: 2; }

/* ---------------------------------------------------------------- прочее */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(150%);
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; font-size: 15px;
  transition: transform .22s ease; z-index: 30; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- отключённые */

.avatar.muted-avatar { background: var(--panel-2); color: var(--muted); }
button.ghost.small {
  padding: 8px 14px; font-size: 14px; align-self: center; flex-shrink: 0;
}

/* ---------------------------------------------------------------- вкладки */

.tab { padding-bottom: 62px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; background: none; border: none; border-radius: 0;
  color: var(--muted); font-size: 11px; font-weight: 600;
  padding: 7px 0 8px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; position: relative;
}
.tab-btn span { font-size: 21px; line-height: 1; }
.tab-btn.active { color: var(--accent); }
.badge {
  position: absolute; top: 3px; right: 50%; margin-right: -24px;
  background: var(--danger); color: #2b0808; font-style: normal;
  font-size: 10px; font-weight: 800; border-radius: 999px;
  min-width: 17px; padding: 1px 4px; text-align: center;
}

/* поиск и переключатели */

.search { padding: 8px 12px; flex-shrink: 0; }
.search input {
  width: 100%; padding: 9px 13px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-size: 16px; font-family: inherit; -webkit-appearance: none;
}
.search input:focus { outline: none; border-color: var(--accent); }

.segments {
  display: flex; gap: 6px; padding: 0 12px 10px; flex-shrink: 0;
}
.seg {
  flex: 1; padding: 8px 10px; border-radius: 10px; font-size: 14px;
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
}
.seg.active { background: var(--accent); color: #07131f; border-color: var(--accent); }
.seg span { font-weight: 800; }

.row.dim { opacity: .6; }
.tag.ok { background: rgba(74,222,128,.15); color: var(--ok); }

/* настройки */

.settings { padding: 6px 0; }
.setting {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.setting:active { background: var(--panel); }
.setting-name { font-weight: 600; }
.setting-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chev { color: var(--muted); font-size: 20px; }
.stats { padding: 18px 16px; color: var(--muted); font-size: 14px; line-height: 1.9; }

/* ---------------------------------------------------------------- карточка контакта */

.contact-body { padding: 16px 14px 80px; }
.card-block {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; margin-bottom: 12px;
}
.card-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: 10px;
}
.kid { padding: 10px 0; border-bottom: 1px solid var(--line); }
.kid:last-child { border-bottom: none; padding-bottom: 0; }
.kid-name { font-weight: 700; font-size: 16px; }
.kid-facts { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.chip {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); margin-left: 6px;
}
.chip.on { background: rgba(74,222,128,.16); color: var(--ok); }
.chip.off { background: rgba(255,107,107,.14); color: var(--danger); }
.card-actions { display: flex; gap: 9px; margin-top: 12px; }
.card-actions button { flex: 1; }
.field { display: flex; justify-content: space-between; padding: 7px 0; font-size: 15px; }
.field span:first-child { color: var(--muted); }

.chan {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 5px; background: var(--panel-2);
  color: var(--muted); margin-right: 6px; vertical-align: 1px;
}
.chan.max { background: rgba(74,158,255,.18); color: var(--accent); }
.chan.telegram { background: rgba(74,222,128,.16); color: var(--ok); }

.msg img.photo {
  display: block; max-width: 100%; border-radius: 11px; margin-bottom: 5px;
  background: var(--panel-2); min-height: 60px;
}
