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

:root {
  --bg:       #1a1a2e;
  --sidebar:  #16213e;
  --accent:   #0f3460;
  --highlight:#e94560;
  --text:     #eaeaea;
  --muted:    #888;
  --sent-bg:  #0f3460;
  --recv-bg:  #16213e;
  --nav-h:    56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Tab system ── */

.tab-content {
  flex: 1;
  display: none;
  overflow: hidden;
  min-height: 0;
}

.tab-content.active { display: flex; }

/* Чаты tab = sidebar + chat side by side */
#tab-chats { flex-direction: row; }

/* ── Bottom Navigation ── */

#bottom-nav {
  flex-shrink: 0;
  display: flex;
  background: var(--sidebar);
  border-top: 1px solid #2a2a4a;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.15s;
}

.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--highlight); }

.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 11px; }

/* ── Sidebar ── */

#sidebar {
  width: 240px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  border-right: 1px solid #2a2a4a;
  overflow-y: auto;
  flex-shrink: 0;
}

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 4px;
}

#display-name {
  color: #c9d1d9;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

#cell-id {
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--highlight);
  margin-bottom: 6px;
}

#status {
  font-size: 12px;
  color: var(--muted);
}

#event-log {
  font-size: 10px;
  font-family: monospace;
  max-height: 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(0,0,0,.3);
  border-radius: 4px;
  padding: 4px;
}

#contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

#contact-list li {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
#contact-list li:hover { background: var(--accent); }
#contact-list li.active { background: var(--highlight); color: #fff; }

button {
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.8; }

#add-contact-btn { width: 100%; }
#share-id-btn { width: 100%; }

/* ── Chat ── */

#chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid #2a2a4a;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.msg .from {
  font-size: 10px;
  color: var(--muted);
}
.msg.sent {
  align-self: flex-end;
  background: var(--sent-bg);
  border-bottom-right-radius: 4px;
}
.msg.recv {
  align-self: flex-start;
  background: var(--recv-bg);
  border-bottom-left-radius: 4px;
}

#input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #2a2a4a;
  flex-shrink: 0;
}

#msg-input {
  flex: 1;
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  resize: none;
  font-family: inherit;
  outline: none;
}

#send-btn {
  padding: 10px 18px;
  background: var(--highlight);
  font-size: 18px;
  border-radius: 12px;
}

#attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 12px;
  background: var(--accent);
  user-select: none;
  flex-shrink: 0;
}

#mic-btn {
  font-size: 18px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--accent);
  flex-shrink: 0;
  transition: background 0.15s;
}
#mic-btn.recording {
  background: #c0392b;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ── Нода tab ── */

#tab-node {
  flex-direction: column;
  background: var(--bg);
}

#node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
}

#node-refresh-btn {
  background: none;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 16px;
}

#node-member-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.member-item:hover { background: var(--accent); }
.member-item.me { opacity: 0.6; cursor: default; }
.member-item.me:hover { background: none; }

.member-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
  color: var(--highlight);
}

.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 14px; font-weight: 500; }
.member-id { font-size: 11px; color: var(--muted); font-family: monospace; margin-top: 2px; }

/* ── Placeholder tabs (Сеть, AI) ── */

.tab-placeholder {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

.placeholder-icon { font-size: 48px; }
.placeholder-title { font-size: 18px; color: var(--text); }
.placeholder-sub { font-size: 13px; }

/* ── Mobile ── */
@media (max-width: 600px) {
  #sidebar { width: 200px; padding: 12px; }
  .msg { max-width: 85%; }
}
