/* call — стили в духе Telegram, тёмная тема */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #0b0d12; color: #e8eaef;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
input, button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: #7a8398; }
.error { color: #ff6b7a; min-height: 1.4em; margin-top: 8px; font-size: 13px; }

/* ---- Auth ---- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 360px; background: #131722;
  border: 1px solid #1f2433; border-radius: 16px; padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.auth-card h1 { margin: 8px 0 4px; font-size: 28px; }
.auth-card .logo { font-size: 48px; }
.tabs { display: flex; gap: 4px; margin: 20px 0 16px; background: #0e111a; padding: 4px; border-radius: 10px; }
.tabs button {
  flex: 1; padding: 8px; background: transparent; color: #7a8398; border: 0;
  border-radius: 8px; font-weight: 500;
}
.tabs button.active { background: #2a3144; color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  padding: 12px 14px; border-radius: 10px; border: 1px solid #2a3144;
  background: #0e111a; color: #fff; outline: none;
}
.auth-form input:focus { border-color: #5a8dff; }
.primary {
  background: linear-gradient(180deg, #4a8eff, #2f6dde); color: white;
  border: 0; padding: 12px; border-radius: 10px; font-weight: 600;
}
.primary:hover { filter: brightness(1.05); }
.link { background: none; border: 0; color: #7a8398; padding: 0; font-size: 12px; }
.link:hover { color: #b8c0d0; }

/* ---- Shell ---- */
.shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100dvh - var(--banner-h, 0px));
}
body:has(.verify-banner:not(.hidden)) { --banner-h: 36px; }
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .shell[data-active="chat"] .sidebar { display: none; }
  .shell:not([data-active="chat"]) .chat-panel { display: none; }
}
.sidebar { background: #0e111a; border-right: 1px solid #1a1f2c; display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { padding: 14px 16px; border-bottom: 1px solid #1a1f2c; }
.side-nav { display: flex; gap: 6px; margin-top: 12px; }
.side-nav button {
  flex: 1; padding: 8px; background: #131722; color: #b8c0d0; border: 0;
  border-radius: 8px; font-weight: 500;
}
.side-nav button.active { background: #2a3144; color: #fff; }
.side-nav button:last-child { flex: 0 0 40px; }
.sidebar-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar-body.hidden { display: none; }

/* ---- AI ---- */
.ai-list { flex: 1; overflow: auto; }
.ai-card {
  display: flex; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid #1a1f2c; cursor: pointer;
  align-items: flex-start;
}
.ai-card:hover { background: #131722; }
.ai-card .avatar { background: linear-gradient(135deg, #4a8eff, #9333ea); }
.ai-card-body { flex: 1; min-width: 0; }
.ai-card-name { font-weight: 600; }
.ai-card-tag {
  display: inline-block; font-size: 10px; padding: 1px 6px;
  border-radius: 6px; background: #2a3144; color: #b8c0d0; margin-left: 6px;
  vertical-align: middle;
}
.ai-card-tag.public { background: #2db74e30; color: #6abf6a; }
.ai-card-tag.owner { background: #ffd17030; color: #ffd170; }
.ai-card-desc { font-size: 12px; color: #7a8398; margin-top: 2px; }

.ai-actions {
  padding: 12px 14px; border-bottom: 1px solid #1a1f2c;
  display: flex; gap: 8px;
}
.ai-actions button {
  flex: 1; padding: 8px; background: #2a3144; color: #fff; border: 0;
  border-radius: 8px; font-size: 13px;
}
.ai-actions button.primary { background: linear-gradient(180deg, #4a8eff, #2f6dde); }

/* form modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: grid; place-items: center; z-index: 200; padding: 20px;
}
.modal {
  background: #131722; border-radius: 14px; padding: 24px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow: auto;
}
.modal h3 { margin: 0 0 16px; }
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-row label { font-size: 12px; color: #7a8398; }
.form-row input, .form-row textarea, .form-row select {
  background: #0e111a; border: 1px solid #2a3144; color: #fff;
  padding: 10px 12px; border-radius: 8px; outline: none; font: inherit;
}
.form-row textarea { min-height: 80px; resize: vertical; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  border-color: #4a8eff;
}
.form-row .row-2 { display: flex; gap: 8px; }
.form-row .row-2 > * { flex: 1; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button {
  padding: 10px 18px; border: 0; border-radius: 8px; color: #fff;
  background: #2a3144;
}
.modal-actions button.primary { background: #4a8eff; }
.modal-actions button.danger { background: #d33a3a; }

.keys-list { padding: 0; }
.key-row {
  padding: 10px 14px; border-bottom: 1px solid #1a1f2c;
  display: flex; align-items: center; gap: 10px;
}
.key-row .grow { flex: 1; min-width: 0; }
.key-row .badge { padding: 2px 8px; font-size: 11px; border-radius: 6px; }
.key-row .badge.ok { background: #2db74e30; color: #6abf6a; }
.key-row .badge.bad { background: #d33a3a30; color: #ff6b7a; }
.me { display: flex; align-items: center; gap: 12px; }
.me-info { display: flex; flex-direction: column; }
.me-name { font-weight: 600; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; flex: 0 0 auto;
  font-weight: 600; color: #fff; font-size: 18px;
}
.avatar.small { width: 32px; height: 32px; font-size: 14px; }
.avatar > span { width: 100%; height: 100%; display: grid; place-items: center; }
.avatar > img { width: 100%; height: 100%; object-fit: cover; }

.search-row { padding: 10px 14px; }
.search-row input {
  width: 100%; padding: 10px 14px; border: 1px solid #1a1f2c;
  border-radius: 10px; background: #131722; color: #fff; outline: none;
}
.search-row input:focus { border-color: #2a3144; }
.search-results { max-height: 240px; overflow: auto; }
.search-row-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; cursor: pointer;
}
.search-row-item:hover { background: #131722; }

.chat-list { flex: 1; overflow: auto; }
.chat-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #11151f;
}
.chat-list-item:hover { background: #131722; }
.chat-list-item.active { background: #1d2436; }
.chat-list-body { flex: 1; min-width: 0; }
.chat-list-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: #7a8398; }
.chat-sub {
  font-size: 13px; color: #8a93a8; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.badge {
  background: #4a8eff; color: white; border-radius: 10px;
  font-size: 11px; padding: 2px 7px; min-width: 20px; text-align: center;
}

/* ---- Chat panel ---- */
.chat-panel {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background:
    radial-gradient(ellipse at top, rgba(74,142,255,0.05), transparent 60%),
    #0b0d12;
}
.empty-state {
  flex: 1; display: grid; place-content: center; gap: 12px;
  color: #5a6379; font-size: 14px; text-align: center;
}
.empty-state > div:first-child { font-size: 64px; }

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid #1a1f2c; background: #0e111a;
}
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-title { font-weight: 600; }
.chat-head-sub { font-size: 12px; color: #7a8398; }

.icon-btn {
  background: transparent; border: 0; color: #b8c0d0;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px;
}
.icon-btn:hover { background: #1a1f2c; color: #fff; }
.icon-btn.primary { background: #4a8eff; color: white; }
.icon-btn.primary:hover { background: #5a99ff; }
.icon-btn.recording { background: #d33a3a; color: white; }

.messages {
  flex: 1; overflow: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 4px;
}
.msg {
  max-width: 70%; padding: 8px 12px; border-radius: 14px;
  word-wrap: break-word; position: relative;
}
.msg.mine { align-self: flex-end; background: #2f6dde; }
.msg.theirs { align-self: flex-start; background: #1d2436; }
.msg.system { align-self: center; background: #14182260; color: #7a8398; font-size: 12px; padding: 4px 10px; }
.msg-sender { font-size: 12px; font-weight: 600; color: #ffd170; margin-bottom: 2px; }
.msg-text { white-space: pre-wrap; }
.msg-time { font-size: 10px; color: rgba(255,255,255,0.6); margin-top: 2px; text-align: right; }
.msg-img { max-width: 280px; border-radius: 8px; display: block; }
.msg-voice { display: flex; align-items: center; gap: 8px; }
.msg-voice audio { max-width: 220px; }
.msg-file { color: #fff; text-decoration: none; }

.composer {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-top: 1px solid #1a1f2c; background: #0e111a;
}
#msgInput {
  flex: 1; padding: 10px 14px; border-radius: 20px;
  background: #1d2436; border: 0; color: #fff; outline: none;
}

/* ---- Call overlay ---- */
.call-overlay {
  position: fixed; inset: 0; background: rgba(11,13,18,0.96);
  display: grid; place-items: center; z-index: 1000;
}
.call-card {
  background: #131722; padding: 36px 40px; border-radius: 18px;
  text-align: center; min-width: 280px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
}
.call-avatar {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden;
  margin: 0 auto 16px; background: #2a3144;
  display: grid; place-items: center; font-size: 40px; color: #fff;
}
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }
.call-name { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.call-status { color: #7a8398; font-size: 14px; }
.call-timer { color: #b8c0d0; font-size: 24px; margin: 16px 0; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }
.call-btn-big {
  padding: 12px 22px; border-radius: 30px; border: 0; font-weight: 600; color: white;
  background: #2a3144;
}
.call-btn-big.primary { background: #2db74e; }
.call-btn-big.danger { background: #d33a3a; }
.call-btn-big:hover { filter: brightness(1.1); }

/* ---- email verify banner ---- */
.verify-banner {
  padding: 8px 14px; background: #ffd170; color: #1a1f2c;
  font-size: 13px; text-align: center;
}
.verify-banner .link { color: #2a3144; font-weight: 600; margin-left: 6px; }

.info { color: #6abf6a; min-height: 1.4em; margin-top: 6px; font-size: 13px; }
.small { font-size: 12px; margin: 0 0 8px; }

/* ---- scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #2a3144; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }
