/* ================================================================
   HQ Chat — app.css
   Theme system: data-theme="light|dark|ocean|terminal"
   on the <html> element.
   Typography: DM Sans (UI) + JetBrains Mono (code/timestamps)
   Mobile-first, 3-panel layout unlocks at 900px.
================================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body { height: 100%; overflow: hidden; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea { font: inherit; border: none; outline: none; background: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
ul { list-style: none; }

/* ── Theme tokens ─────────────────────────────────────────────── */

/* DARK (default / base) */
:root,
[data-theme="dark"] {
  --bg-app:        #0f1117;
  --bg-sidebar:    #16181f;
  --bg-surface:    #1e2029;
  --bg-raised:     #262831;
  --bg-input:      #1a1c25;
  --bg-hover:      rgba(255,255,255,0.05);
  --bg-active:     rgba(255,255,255,0.09);

  --text-primary:  #e8eaf0;
  --text-secondary:#9499aa;
  --text-muted:    #5c6070;
  --text-inverse:  #0f1117;

  --accent:        #5b7fff;
  --accent-hover:  #7090ff;
  --accent-subtle: rgba(91,127,255,0.12);
  --accent-text:   #a0b4ff;

  --danger:        #ff5b6b;
  --danger-subtle: rgba(255,91,107,0.12);
  --success:       #3ecf8e;
  --success-subtle:rgba(62,207,142,0.12);
  --warning:       #f5a623;

  --border:        rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.13);

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.6);

  --sidebar-width: 260px;
  --header-height: 52px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-full:   9999px;

  --font-ui:    'DM Sans', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  color-scheme: dark;
}

/* LIGHT */
[data-theme="light"] {
  --bg-app:        #f0f2f7;
  --bg-sidebar:    #ffffff;
  --bg-surface:    #ffffff;
  --bg-raised:     #f7f8fc;
  --bg-input:      #f0f2f7;
  --bg-hover:      rgba(0,0,0,0.04);
  --bg-active:     rgba(0,0,0,0.07);

  --text-primary:  #1a1d27;
  --text-secondary:#5c6278;
  --text-muted:    #9499aa;
  --text-inverse:  #ffffff;

  --accent:        #3d5eff;
  --accent-hover:  #2d4eef;
  --accent-subtle: rgba(61,94,255,0.08);
  --accent-text:   #3d5eff;

  --danger:        #e53935;
  --danger-subtle: rgba(229,57,53,0.08);
  --success:       #2ea869;
  --success-subtle:rgba(46,168,105,0.08);
  --warning:       #e67e22;

  --border:        rgba(0,0,0,0.07);
  --border-strong: rgba(0,0,0,0.13);

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);

  color-scheme: light;
}

/* OCEAN */
[data-theme="ocean"] {
  --bg-app:        #0a1628;
  --bg-sidebar:    #0d1e38;
  --bg-surface:    #102240;
  --bg-raised:     #152b50;
  --bg-input:      #0d1e38;
  --bg-hover:      rgba(100,180,255,0.06);
  --bg-active:     rgba(100,180,255,0.11);

  --text-primary:  #d6eaff;
  --text-secondary:#7aabdc;
  --text-muted:    #3d6a9a;
  --text-inverse:  #0a1628;

  --accent:        #00b4d8;
  --accent-hover:  #00cff7;
  --accent-subtle: rgba(0,180,216,0.12);
  --accent-text:   #7ae4f7;

  --danger:        #ff6b8a;
  --danger-subtle: rgba(255,107,138,0.12);
  --success:       #2de2a5;
  --success-subtle:rgba(45,226,165,0.12);
  --warning:       #ffc857;

  --border:        rgba(100,180,255,0.08);
  --border-strong: rgba(100,180,255,0.15);

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.5);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.6);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.7);

  color-scheme: dark;
}

/* TERMINAL */
[data-theme="terminal"] {
  --bg-app:        #0c0e0c;
  --bg-sidebar:    #101410;
  --bg-surface:    #141a14;
  --bg-raised:     #1a231a;
  --bg-input:      #101410;
  --bg-hover:      rgba(0,255,100,0.05);
  --bg-active:     rgba(0,255,100,0.09);

  --text-primary:  #c8f0c8;
  --text-secondary:#6aab6a;
  --text-muted:    #3a5c3a;
  --text-inverse:  #0c0e0c;

  --accent:        #00e564;
  --accent-hover:  #00ff72;
  --accent-subtle: rgba(0,229,100,0.1);
  --accent-text:   #7affa0;

  --danger:        #ff4d6a;
  --danger-subtle: rgba(255,77,106,0.1);
  --success:       #00e564;
  --success-subtle:rgba(0,229,100,0.1);
  --warning:       #e5c000;

  --border:        rgba(0,255,100,0.08);
  --border-strong: rgba(0,255,100,0.14);

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.5);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.6);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.7);

  color-scheme: dark;
}

/* ── Base ──────────────────────────────────────────────────────── */
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-app);
  font-feature-settings: 'kern' 1, 'liga' 1;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

/* Mobile: sidebar slides over content */
@media (max-width: 899px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100dvh;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }
  .sidebar-overlay.visible {
    display: block;
  }
}

/* Sidebar header */
.sidebar-header {
  padding: 0 16px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-wordmark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-wordmark .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Sidebar search */
.sidebar-search {
  padding: 10px 12px;
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 32px;
  font-size: 13px;
  color: var(--text-primary);
  transition: border-color 0.15s;
}

.sidebar-search input::placeholder { color: var(--text-muted); }
.sidebar-search input:focus { border-color: var(--accent); }

.sidebar-search-wrap {
  position: relative;
}

.sidebar-search-wrap .search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.channel-group {
  margin-bottom: 4px;
}

.channel-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.channel-group-header:hover { color: var(--text-secondary); }

.channel-group-header .add-btn {
  opacity: 0;
  transition: opacity 0.15s;
  color: var(--text-muted);
  padding: 2px;
  border-radius: 4px;
}

.channel-group-header:hover .add-btn {
  opacity: 1;
}

.channel-group-header .add-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Channel items */
.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 16px;
  margin: 0 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
  position: relative;
  font-size: 13.5px;
}

.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.channel-item.active {
  background: var(--accent-subtle);
  color: var(--accent-text);
  font-weight: 500;
}

.channel-item.unread {
  color: var(--text-primary);
  font-weight: 500;
}

.channel-item .channel-icon {
  flex-shrink: 0;
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.channel-item .channel-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-item .unread-badge {
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* DM item with avatar */
.channel-item .dm-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.channel-item .dm-avatar-placeholder {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Presence indicator */
.channel-item .presence {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.channel-item .presence.online { background: var(--success); box-shadow: 0 0 4px var(--success); }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-status {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-footer-actions {
  display: flex;
  gap: 2px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Main content area ─────────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Channel header */
.channel-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg-surface);
}

.channel-header-hamburger {
  display: none;
}

@media (max-width: 899px) {
  .channel-header-hamburger {
    display: flex;
  }
}

.channel-header-title {
  flex: 1;
  min-width: 0;
}

.channel-header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-header-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.channel-header-actions {
  display: flex;
  gap: 2px;
}

/* ── Message list ──────────────────────────────────────────────── */
.message-list-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: var(--bg-surface);
}

.message-list-wrap::-webkit-scrollbar { width: 5px; }
.message-list-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.message-list {
  padding: 16px 0 8px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  justify-content: flex-end;
}

.message-load-more {
  text-align: center;
  padding: 12px;
}

.message-load-more button {
  font-size: 12px;
  color: var(--accent);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--accent-subtle);
  transition: background 0.15s;
}

.message-load-more button:hover { background: var(--accent-subtle); }

/* Day divider */
.day-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.day-divider::before,
.day-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Message row */
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 3px 16px;
  transition: background 0.1s;
  position: relative;
}

.msg-row:hover { background: var(--bg-hover); }
.msg-row.grouped { padding-top: 1px; padding-bottom: 1px; }

/* Avatar */
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-top: 2px;
}

/* Grouped: hide avatar, show timestamp on hover */
.msg-row.grouped .msg-avatar,
.msg-row.grouped .msg-avatar-placeholder {
  visibility: hidden;
}

.msg-row.grouped .msg-time-hover {
  display: flex;
}

.msg-time-hover {
  display: none;
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: center;
  pointer-events: none;
}

/* Message content */
.msg-content {
  flex: 1;
  min-width: 0;
}

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.msg-sender {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.msg-sender:hover { text-decoration: underline; }

.msg-time {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.msg-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
}

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

.msg-edited {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Mentions */
.msg-body .mention {
  background: var(--accent-subtle);
  color: var(--accent-text);
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 500;
}

/* Message actions (appear on hover) */
.msg-actions {
  position: absolute;
  right: 12px;
  top: -14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  display: none;
  gap: 2px;
  padding: 3px;
  z-index: 10;
}

.msg-row:hover .msg-actions { display: flex; }

.msg-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
  transition: background 0.1s, color 0.1s;
}

.msg-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Reactions */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.reaction-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}

.reaction-pill:hover { background: var(--bg-active); }
.reaction-pill.mine { border-color: var(--accent); background: var(--accent-subtle); }
.reaction-pill .rcount { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

/* Attachments */
.msg-attachments { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }

.attachment-image {
  max-width: min(340px, 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
}

.attachment-image img { width: 100%; display: block; }

.attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 320px;
  cursor: pointer;
  transition: background 0.12s;
}

.attachment-file:hover { background: var(--bg-active); }

.attachment-file-icon { font-size: 24px; flex-shrink: 0; }

.attachment-file-info { min-width: 0; }
.attachment-file-name { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-file-size { font-size: 11px; color: var(--text-muted); }

/* Voice note */
.attachment-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  max-width: 280px;
}

.voice-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: background 0.12s;
}

.voice-play-btn:hover { background: var(--accent-hover); }

.voice-waveform {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.voice-waveform span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.5;
}

.voice-duration {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Thread indicator */
.msg-thread-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--accent-text);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}

.msg-thread-btn:hover { background: var(--accent-subtle); }

/* Link preview */
.link-preview {
  margin-top: 6px;
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  background: var(--bg-raised);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  max-width: 400px;
}

.link-preview-site { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.link-preview-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.link-preview-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }

/* Typing indicator */
.typing-indicator {
  padding: 0 16px 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  min-height: 24px;
}

.typing-dots { display: inline-flex; gap: 3px; margin-right: 4px; vertical-align: middle; }
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40%           { transform: scale(1.1); opacity: 1; }
}

/* ── Composer ──────────────────────────────────────────────────── */
.composer {
  padding: 10px 16px 14px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.composer-attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.composer-attach-thumb {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.composer-attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.composer-attach-thumb .remove-thumb {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: white;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.composer-textarea {
  flex: 1;
  resize: none;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.composer-textarea::placeholder { color: var(--text-muted); }

.composer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.composer-action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 17px;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

.composer-action-btn:hover { background: var(--bg-hover); color: var(--accent); }

.composer-send-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.12s, opacity 0.12s;
  flex-shrink: 0;
}

.composer-send-btn:hover { background: var(--accent-hover); }
.composer-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Voice recording state */
.composer-voice-recording {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--danger);
  font-size: 13px;
}

.voice-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: voicePulse 1s infinite;
}

@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.85); }
}

/* ── Theme switcher panel ──────────────────────────────────────── */
.theme-picker {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
}

.theme-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}

.theme-swatch:hover, .theme-swatch.active { border-color: var(--text-primary); transform: scale(1.15); }
.theme-swatch[data-theme="dark"]     { background: linear-gradient(135deg, #1e2029, #5b7fff); }
.theme-swatch[data-theme="light"]    { background: linear-gradient(135deg, #f0f2f7, #3d5eff); }
.theme-swatch[data-theme="ocean"]    { background: linear-gradient(135deg, #102240, #00b4d8); }
.theme-swatch[data-theme="terminal"] { background: linear-gradient(135deg, #141a14, #00e564); }

/* ── Modal / overlay ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
}

@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title { font-size: 16px; font-weight: 600; }
.modal-body  { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; letter-spacing: 0.03em; text-transform: uppercase; }

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input::placeholder { color: var(--text-muted); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, opacity 0.12s;
  cursor: pointer;
  border: none;
  font-family: var(--font-ui);
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--bg-hover); color: var(--text-primary); }
.btn-ghost:hover { background: var(--bg-active); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }

/* ── Toast notifications ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

@media (max-width: 899px) {
  .toast-container { bottom: 20px; right: 16px; left: 16px; }
}

.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
  max-width: 380px;
  width: 100%;
}

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.toast.error   { border-color: var(--danger);  }
.toast.success { border-color: var(--success); }
.toast.info    { border-color: var(--accent);  }
.toast-icon    { font-size: 18px; flex-shrink: 0; }

/* ── Empty / loading states ────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 40px;
  text-align: center;
}

.empty-state-icon { font-size: 40px; opacity: 0.5; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state-body  { font-size: 13px; line-height: 1.5; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-raised) 25%, var(--bg-active) 50%, var(--bg-raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Login page ────────────────────────────────────────────────── */
.login-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: 24px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.login-logo-name { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }

.login-tagline { font-size: 14px; color: var(--text-secondary); margin-bottom: 28px; line-height: 1.5; }

.login-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font-ui);
  text-decoration: none;
}

.login-google-btn:hover { background: var(--bg-active); border-color: var(--accent); }

.login-google-btn svg { flex-shrink: 0; }

.login-footer { margin-top: 20px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ── Responsive tweaks ─────────────────────────────────────────── */
@media (max-width: 499px) {
  .msg-row { padding: 3px 10px; }
  .composer { padding: 8px 10px 12px; }
  .channel-header { padding: 0 10px; }
  .login-card { padding: 28px 20px; }
}

/* ── Scrollbar global ──────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }
