/* ===== Design tokens ===== */
:root {
  --bg: #0F1113;
  --bg-2: #181A1F;
  --bg-3: #1C1F24;
  --border: #22262D;
  --border-2: #2a2d33;
  --text: #E6EDF3;
  --muted: #7D8590;
  --accent: #00F5FF;
  --danger: #ff5577;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* ===== Logo mark ===== */
.logo-mark {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #00F5FF22, #00F5FF44);
  border: 1px solid #00F5FF66;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-wave { display: flex; gap: 2px; align-items: center; }
.logo-wave span { display: block; background: var(--accent); width: 2px; border-radius: 1px; }
.logo-wave span:nth-child(1) { height: 8px; }
.logo-wave span:nth-child(2) { height: 14px; }
.logo-wave span:nth-child(3) { height: 10px; }
.logo-wave span:nth-child(4) { height: 16px; }
.logo-wave span:nth-child(5) { height: 6px; }

/* ===== Auth View ===== */
.auth-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 50%, #1a1d23 0%, #0f1113 100%);
}
.auth-card {
  width: 100%; max-width: 360px; padding: 40px 24px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 24px;
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; justify-content: center; }
.app-name { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.auth-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.auth-sub { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 32px; }

.auth-form { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
input {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; color: var(--text); font-family: inherit; font-size: 15px;
  transition: all .2s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,245,255,0.1); }

.btn-primary {
  background: var(--accent); color: #0F1113; border: none; border-radius: 12px;
  padding: 14px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all .2s;
  margin-top: 8px;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.auth-footer { margin-top: 24px; text-align: center; }
.btn-link { background: none; border: none; color: var(--accent); font-size: 14px; font-weight: 500; cursor: pointer; }

/* ===== App Layout ===== */
.app-wrap { display: flex; height: 100vh; width: 100%; }
.sidebar {
  width: 320px; min-width: 320px; background: var(--bg-2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}

.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 18px; font-weight: 600; }

.search-bar { padding: 12px 16px; }
.search-input-wrapper {
  position: relative; display: flex; align-items: center;
}
.search-icon { position: absolute; left: 12px; pointer-events: none; }
.search-bar input { width: 100%; padding: 10px 12px 10px 38px; font-size: 14px; border-radius: 10px; }

.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  cursor: pointer; transition: background .2s; border-left: 3px solid transparent;
}
.chat-item:hover { background: var(--bg-3); }
.chat-item.active { background: var(--bg-3); border-left-color: var(--accent); }

.avatar {
  width: 44px; height: 44px; border-radius: 15px; background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--accent); flex-shrink: 0; font-size: 18px;
}
.chat-info-cell { flex: 1; min-width: 0; }
.chat-name-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.chat-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--muted); }
.chat-last-msg { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  padding: 16px; background: var(--bg-2); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.user-me { display: flex; align-items: center; gap: 10px; }
.user-me .avatar { width: 36px; height: 36px; font-size: 14px; }
.me-name { font-size: 14px; font-weight: 600; }

/* ===== Chat Main ===== */
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg); position: relative; }
.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted);
}
.empty-icon {
  width: 80px; height: 80px; border-radius: 30px; background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: var(--border); margin-bottom: 16px;
}

.chat-view { flex: 1; display: flex; flex-direction: column; }
.chat-header {
  height: 64px; padding: 0 24px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
  background: rgba(15,17,19,0.8); backdrop-filter: blur(10px);
}
.chat-info { display: flex; align-items: center; gap: 12px; }
.chat-info .avatar { width: 38px; height: 38px; font-size: 16px; }
.chat-name-top { font-size: 16px; font-weight: 600; }
.chat-status { font-size: 12px; color: var(--accent); }

.messages-container {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 8px;
}

/* Bubbles */
.msg { max-width: 70%; padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.4; position: relative; }
.msg-in { align-self: flex-start; background: var(--bg-2); border-bottom-left-radius: 4px; }
.msg-out { align-self: flex-end; background: var(--accent); color: #0F1113; border-bottom-right-radius: 4px; }
.msg-sender { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 4px; display: block; }
.msg-info { display: flex; align-items: center; gap: 6px; margin-top: 4px; justify-content: flex-end; }
.msg-time { font-size: 10px; opacity: 0.6; }

.input-area {
  padding: 20px 24px; display: flex; align-items: center; gap: 16px;
}
.input-actions { color: var(--muted); cursor: pointer; }
.input-area input { flex: 1; background: var(--bg-2); border-radius: 14px; padding: 14px 20px; }
.send-btn {
  width: 48px; height: 48px; border-radius: 14px; background: var(--accent);
  border: none; display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.modal-content {
  background: var(--bg-2); width: 100%; max-width: 400px; padding: 32px;
  border-radius: 28px; border: 1px solid var(--border);
}
.modal h2 { margin-bottom: 20px; font-size: 20px; }
.modal input { width: 100%; margin-bottom: 16px; }
.users-list { max-height: 240px; overflow-y: auto; margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.btn-secondary {
  width: 100%; background: var(--bg-3); color: var(--text); border: none;
  border-radius: 12px; padding: 14px; cursor: pointer; font-weight: 600;
}
.modal-actions { display: flex; gap: 12px; }

.user-search-item {
  display: flex; align-items: center; gap: 12px; padding: 8px;
  background: var(--bg); border-radius: 8px; border: 1px solid var(--border-2);
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text); }
.user-username { font-size: 12px; color: var(--muted); }
.btn-small {
  padding: 6px 12px; background: var(--accent); border: none; border-radius: 6px;
  color: #0F1113; font-size: 12px; font-weight: 500; cursor: pointer;
}

.icon-btn-small {
  width: 28px; height: 28px; border-radius: 8px; background: transparent;
  border: none; color: var(--muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all .2s;
}
.icon-btn-small:hover { background: var(--bg-3); color: var(--accent); }