:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #0b1220;
  --accent: #38bdf8;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #1f2937;
  --in: #0ea5e9;
  --out: #22c55e;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

.public-url {
  padding: 8px 12px;
  background: rgba(56,189,248,0.1);
  color: var(--accent);
  text-align: center;
  font-size: 13px;
}
.public-url a { color: var(--accent); text-decoration: none; }

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}

.logo {
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.section { display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.section-title { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.08em; }

#accounts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.account-chip {
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}
.account-chip.active {
  background: var(--accent);
  color: #0b1220;
  border-color: var(--accent);
  font-weight: 600;
}

.chat-list {
  overflow-y: auto;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}
.chat-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}
.chat-item:hover { background: rgba(255,255,255,0.03); }
.chat-item.active { background: rgba(56,189,248,0.15); border-left: 3px solid var(--accent); }
.chat-title { font-weight: 600; }
.chat-preview { color: var(--muted); font-size: 13px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-date { color: var(--muted); font-size: 12px; margin-top: 4px; }
.chat-list.empty, .messages.empty { display: grid; place-items: center; color: var(--muted); }

.content { display: flex; flex-direction: column; height: 100vh; }
.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.title { font-size: 18px; font-weight: 700; }
.meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.status { color: var(--accent); font-size: 13px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
}
.message {
  max-width: 70%;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.message.out { margin-left: auto; background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.2); }
.message.in { margin-right: auto; background: rgba(14,165,233,0.12); border-color: rgba(14,165,233,0.2); }
.message .header { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.message .body { margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.message .footer { margin-top: 6px; display: flex; gap: 10px; color: var(--muted); font-size: 12px; align-items: center; }
.badge { padding: 2px 6px; border-radius: 8px; background: rgba(255,255,255,0.08); border: 1px solid var(--border); }
.tag { padding: 2px 6px; border-radius: 8px; background: rgba(56,189,248,0.15); color: var(--text); font-size: 11px; }
.placeholder { color: var(--muted); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: column; height: auto; }
  .messages { padding: 12px; }
}
