* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #000000;
  --panel: #0c0c0c;
  --panel-2: #161616;
  --panel-3: #1e1e1e;
  --border: #262626;
  --text: #f4f4f4;
  --muted: #8a8a8a;
  --green: #22c55e;
  --red: #ef4444;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }

/* ---------- кнопки ---------- */
.btn, .btn-mini, .btn-send, .chip-btn {
  cursor: pointer;
  border: none;
  font-weight: 600;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:active, .btn-mini:active, .btn-send:active, .chip-btn:active { transform: scale(.96); }

.btn { width: 100%; padding: 14px; border-radius: 12px; font-size: 16px; margin-top: 6px; }
.btn-white { background: #fff; color: #000; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }

.btn-mini { padding: 7px 12px; border-radius: 9px; font-size: 13px; }
.btn-red { background: transparent; color: var(--red); border: 1px solid #3a2222; }

.chip-btn { padding: 7px 12px; border-radius: 9px; font-size: 13px; color: #000; }
.chip-btn.green { background: var(--green); }
.chip-btn.red { background: var(--red); }
.chip-btn.gray { background: var(--panel-3); color: var(--muted); cursor: default; }
.chip-btn.gray:active { transform: none; }

/* ---------- вход ---------- */
.auth-screen { height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-box {
  width: 100%; max-width: 360px; background: var(--panel);
  border: 1px solid var(--border); padding: 34px 24px; border-radius: 20px;
  animation: fade-up .3s ease;
}
.logo { font-size: 30px; text-align: center; letter-spacing: 0.5px; }
.subtitle { text-align: center; color: var(--muted); margin: 8px 0 22px; font-size: 14px; }

input {
  width: 100%; padding: 14px 16px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel-2); color: var(--text); font-size: 16px; outline: none;
  transition: border-color .15s ease;
}
input:focus { border-color: #555; }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin-bottom: 6px; text-align: center; }

/* ---------- каркас ---------- */
.app { display: flex; height: 100%; }
.sidebar {
  width: 330px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.me { display: flex; align-items: center; gap: 10px; }
.me-name { font-weight: 600; font-size: 15px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #fff; color: #000; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; font-size: 16px;
}
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }

.search-box { padding: 12px 16px 6px; }

.scroll-area { flex: 1; overflow-y: auto; }
.section:empty { display: none; }
.section-title { padding: 14px 16px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

/* строки списка */
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid #141414; transition: background .15s ease;
  animation: fade-up .18s ease;
}
.row:hover, .row.active { background: var(--panel-2); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .actions { display: flex; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex-shrink: 0; }

/* ---------- чат ---------- */
.chat { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); padding: 24px; text-align: center; line-height: 1.6; }
.chat-active { flex: 1; display: flex; flex-direction: column; height: 100%; }
.chat-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel);
  display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px;
}
.btn-back { display: none; background: transparent; border: none; color: var(--text); font-size: 30px; cursor: pointer; line-height: 1; padding: 0 4px; }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble {
  max-width: 75%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.4;
  word-wrap: break-word; white-space: pre-wrap; animation: bubble-in .18s ease;
}
.bubble.me { background: #fff; color: #000; align-self: flex-end; border-bottom-right-radius: 5px; }
.bubble.them { background: var(--panel-2); color: var(--text); align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble .time { display: block; font-size: 11px; opacity: .55; margin-top: 4px; }

.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--panel); }
.composer input { margin-bottom: 0; }
.btn-send {
  background: var(--green); color: #000; width: 50px; border-radius: 12px; font-size: 18px; flex-shrink: 0;
}
.btn-send:disabled { opacity: .4; cursor: default; transform: none; }

.hint { text-align: center; color: var(--muted); font-size: 12px; padding: 4px; min-height: 18px; }

/* ---------- анимации (по времени — одинаковые на любой герцовке) ---------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- телефон ---------- */
@media (max-width: 720px) {
  .sidebar { width: 100%; }
  .chat { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .chat { display: flex; }
  .btn-back { display: block; }
  .chat-empty { display: none; }
}
