:root {
  --sidebar-bg: #12141c;
  --sidebar-fg: #cbd0dc;
  --sidebar-fg-muted: #7d8394;
  --sidebar-active-bg: #1f2230;
  --accent: #ff69b4;
  --accent-soft: #ffe8f3;
  --bg: #f7f7f9;
  --surface: #ffffff;
  --border: #e6e7eb;
  --text: #16181d;
  --text-muted: #71757f;
  --radius: 12px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  transition: width 0.18s ease, padding 0.18s ease;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .conn-pill span {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  white-space: nowrap;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--sidebar-fg-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.sidebar.collapsed .icon-btn svg {
  transform: rotate(180deg);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sidebar-fg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.conn-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--sidebar-fg-muted);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}

.conn-dot.online { background: #22c55e; }
.conn-dot.error { background: #ef4444; }

/* ---------- Main ---------- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topbar .icon-btn { color: var(--text-muted); }
.topbar .icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.topbar .icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.topbar .icon-btn[hidden] { display: none; }

.topbar-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 380px;
  color: var(--text-muted);
}

.empty-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg.pending {
  color: var(--text-muted);
  font-style: italic;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 28px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 14px;
  max-height: 160px;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--accent);
}

.send-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
}

.send-btn:hover { opacity: 0.9; }
.send-btn:disabled { opacity: 0.5; cursor: default; }

.mic-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mic-btn:hover { color: var(--accent); border-color: var(--accent); }
.mic-btn[hidden] { display: none; }

.mic-btn.recording {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  animation: mic-pulse 1.4s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 10; height: 100%; }
  .sidebar:not(.collapsed) { width: 220px; }
}

/* ---------- Embedded views (Teammates, Vector DB, Postmaster) ---------- */

[hidden] { display: none !important; }

.frame-view {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--surface);
}

.frame-view iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.frame-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}
