/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg-dark: #111B21;
  --bg-panel: #1F2C34;
  --bg-input: #2A3942;
  --bg-bubble-out: #005C4B;
  --bg-bubble-in: #202C33;
  --bg-hover: #2A3942;
  --accent: #128C7E;
  --accent-light: #25D366;
  --text: #E9EDEF;
  --text-secondary: #8696A0;
  --text-muted: #54656F;
  --border: #2A3942;
  --danger: #F15C6D;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}


/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ── Auth Screens ──────────────────────────────────────────────────────────── */
.login-screen,
.qr-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  background: var(--bg-dark);
  padding: 20px;
}

.auth-card {
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .logo img,
.auth-card .logo svg {
  width: 64px;
  height: 64px;
}

.auth-card h1 {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
}

.auth-card p {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 8px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: #0e7a72; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
}

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

.error-msg {
  background: rgba(241, 92, 109, 0.15);
  border: 1px solid rgba(241, 92, 109, 0.3);
  color: var(--danger);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── QR Screen ─────────────────────────────────────────────────────────────── */
.qr-container {
  text-align: center;
}

.qr-container img {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  background: white;
  padding: 8px;
  margin: 20px auto;
  display: block;
}

.qr-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

.status-dot.connecting { background: #F5A623; animation: pulse 1.5s infinite; }
.status-dot.ready { background: var(--accent-light); }
.status-dot.qr { background: #4A9EFF; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── App Layout ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  justify-content: center;
  height: 100vh;
  background: var(--bg);
}

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  width: 100%;
  max-width: 1200px;
  box-shadow: 0 0 40px rgba(0,0,0,0.4);
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  height: 100%;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-size: 18px;
}

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

.wa-status-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}

.wa-connect-btn {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 2px 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.wa-connect-btn.hidden { display: none; }

.sidebar-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-search input {
  width: 100%;
  padding: 7px 12px;
  background: var(--bg-input);
  border: none;
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

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

.sidebar-archive-bar {
  padding: 4px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.archive-toggle-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.archive-toggle-btn:hover { background: var(--bg-hover); color: var(--text); }
.archive-toggle-btn.active { color: var(--accent-light); font-weight: 600; }

.archive-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-input); }

.chat-archive-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-left: 4px;
  transition: background 0.15s, color 0.15s;
}
.chat-item:hover .chat-archive-btn { display: block; }
.chat-archive-btn:hover { background: var(--bg-input); color: var(--text); }

.chat-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.chat-item:hover .chat-menu-btn { display: block; }
.chat-menu-btn:hover { background: var(--bg-input); color: var(--text); }

.chat-mute-icon {
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0.6;
  margin-left: 2px;
}

.chat-ctx-menu {
  position: fixed;
  z-index: 3000;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  min-width: 210px;
  overflow: hidden;
}
.chat-ctx-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.chat-ctx-item:hover { background: var(--bg-hover, rgba(255,255,255,0.06)); }

.chat-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  margin-right: 12px;
}

.chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
}

.chat-avatar.group { background: #54656F; }

.chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-messenger-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  display: block;
  line-height: 1;
}

.messenger-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 0 2px var(--bg-panel);
}

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

.chat-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.chat-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-left: 8px;
}

.chat-last-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.unread-badge {
  background: var(--accent-light);
  color: #111;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-left: 8px;
  min-width: 20px;
  text-align: center;
}

/* ── Chat View ─────────────────────────────────────────────────────────────── */
.chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  min-width: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.chat-view-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 16px;
}

.chat-view-empty .icon {
  font-size: 64px;
  opacity: 0.3;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}

.chat-settings-panel {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  flex-shrink: 0;
}

.chat-settings-panel.hidden { display: none; }

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.settings-toggle-row input[type="checkbox"] {
  width: 36px;
  height: 20px;
  appearance: none;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.settings-toggle-row input[type="checkbox"]:checked {
  background: var(--accent);
}

.settings-toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.settings-toggle-row input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

.chat-lists-panel {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  flex-shrink: 0;
}
.chat-lists-panel.hidden { display: none; }
.lists-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}
.lists-create-form {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: flex-end;
}
.lists-create-form input {
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  width: 160px;
}
.lists-create-form button {
  padding: 5px 12px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.lists-panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lists-panel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}
.lists-panel-link {
  flex: 1;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lists-panel-link:hover { text-decoration: underline; }
.lists-panel-del {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  opacity: 0.6;
  padding: 0 2px;
}
.lists-panel-del:hover { opacity: 1; color: var(--danger, #e53e3e); }
.lists-panel-empty, .lists-panel-loading, .lists-panel-error {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.chat-header .back-btn {
  display: none;
}

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

.chat-header-menu-btn {
  display: none;
  flex-shrink: 0;
}

.chat-header-dropdown {
  position: fixed;
  z-index: 1000;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  min-width: 180px;
}

.chat-header-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.chat-header-dropdown-item:hover {
  background: var(--bg-hover);
}

.chat-header-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

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

.chat-header-status {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-status[data-presence="online"] {
  color: #4caf50;
}

.message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.load-older-btn {
  display: block;
  width: fit-content;
  margin: 8px auto;
  padding: 6px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.load-older-btn:hover { background: var(--hover); }
.load-older-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Message Bubbles ───────────────────────────────────────────────────────── */
.message-bubble {
  max-width: 65%;
  padding: 6px 8px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
  box-shadow: var(--shadow);
}

.bubble-wrapper {
  display: flex;
  margin-bottom: 2px;
}

.bubble-wrapper.out {
  justify-content: flex-end;
}

.bubble-wrapper.in {
  justify-content: flex-start;
}

.reaction-badge {
  font-size: 18px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.bubble-wrapper.out .reaction-badge {
  justify-content: flex-end;
}

.bubble-wrapper.in .reaction-badge {
  justify-content: flex-start;
}

.reaction-indicator {
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 6px;
  opacity: 0.7;
  cursor: default;
}

.reaction-indicator.wa {
  background: rgba(18, 140, 126, 0.25);
  color: var(--accent);
}

.reaction-indicator.local {
  background: rgba(134, 150, 160, 0.2);
  color: var(--text-secondary);
}

.bubble-out {
  background: var(--bg-bubble-out);
  border-radius: 8px 8px 2px 8px;
}

.bubble-in {
  background: var(--bg-bubble-in);
  border-radius: 8px 8px 8px 2px;
}

.bubble-text {
  font-size: 14px;
  color: var(--text);
  white-space: normal;
  word-break: break-word;
}

.bubble-text .inline-code {
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 12px;
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.bubble-time {
  font-size: 11px;
  color: var(--text-secondary);
}

.bubble-tick {
  font-size: 12px;
  color: var(--text-secondary);
}

.bubble-tick.tick-sent      { color: var(--text-secondary); }
.bubble-tick.tick-delivered { color: var(--text-secondary); }
.bubble-tick.tick-read      { color: #53BDEB; }
.bubble-tick.tick-pending   { font-size: 10px; color: var(--text-muted); }

.sender-name {
  font-size: 12px;
  font-weight: 600;
  color: #7BC67E;
  margin-bottom: 2px;
}

.date-divider {
  text-align: center;
  padding: 12px 0 4px;
}

.date-divider span {
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 8px;
}

/* ── Media Bubbles ─────────────────────────────────────────────────────────── */
.media-bubble img,
.media-bubble video {
  max-width: 100%;
  max-height: 240px;
  border-radius: 6px;
  display: block;
  cursor: pointer;
}

.doc-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.doc-icon {
  font-size: 28px;
  flex-shrink: 0;
}

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

.doc-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-size {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Voice Message ─────────────────────────────────────────────────────────── */
.voice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  min-width: 180px;
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background 0.2s;
}

.voice-play-btn:hover { background: rgba(255,255,255,0.25); }
.voice-play-btn.playing { color: var(--accent-light); }

.voice-waveform {
  flex: 1;
  height: 24px;
  position: relative;
}

.voice-progress-bar {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  width: 100%;
  cursor: pointer;
}

.voice-progress-fill {
  height: 100%;
  background: var(--accent-light);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s;
}

.voice-duration {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
}

/* ── Transcript Spoiler ────────────────────────────────────────────────────── */
.transcript-spoiler {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.transcript-spoiler-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.2s;
}

.transcript-spoiler-btn:hover { color: var(--text); }

.transcript-text {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  transition: filter 0.3s;
}


.transcript-text.hidden {
  display: none;
}

/* ── Sentiment Spoiler ─────────────────────────────────────────────────────── */
.sentiment-spoiler {
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 4px;
}
.sentiment-spoiler-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 0;
  width: 100%;
  text-align: left;
  transition: color 0.15s;
}
.sentiment-spoiler-btn:hover { color: var(--text); }
.sentiment-score-badge {
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 7px;
}
.sentiment-spoiler-btn.sentiment-pos .sentiment-score-badge { background: rgba(37,211,102,.18); color: #25d366; }
.sentiment-spoiler-btn.sentiment-neg .sentiment-score-badge { background: rgba(220,53,69,.18); color: #e05260; }
.sentiment-spoiler-btn.sentiment-neu .sentiment-score-badge { background: rgba(100,149,237,.18); color: #82a8f0; }
.sentiment-body {
  padding: 6px 0 2px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sentiment-body.hidden { display: none; }
.sentiment-moods {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.sentiment-mood-tag {
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  font-size: 11px;
  padding: 2px 7px;
  color: var(--text-secondary);
}
.sentiment-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Location Bubble ───────────────────────────────────────────────────────── */
.location-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: none;
}

.location-icon { font-size: 24px; }

.location-info .location-label {
  font-size: 13px;
  color: var(--text);
}

.location-info .location-coords {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Input Bar ─────────────────────────────────────────────────────────────── */
.poll-bubble {
  min-width: 180px;
}
.poll-question {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}
.poll-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.poll-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.poll-option-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  padding: 7px 12px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  width: 100%;
}
.poll-option-btn:hover:not(:disabled) { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); }
.poll-option-btn:disabled { opacity: 0.6; cursor: default; }
.poll-option-btn.poll-option-voted { background: rgba(37,211,102,.15); border-color: var(--accent-light); }

.poll-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.poll-option-name { flex: 1; }
.poll-option-count {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.poll-option-voted .poll-option-count { color: var(--accent-light); }

.poll-option-bar {
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}
.poll-option-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.poll-option-voted .poll-option-bar-fill { background: var(--accent-light); }

.poll-total {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: right;
}

.reply-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 4px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: var(--bg-panel);
}
.reply-suggestions.hidden { display: none; }

.suggestion-chip {
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  padding: 5px 12px;
  max-width: 100%;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  white-space: normal;
}
.suggestion-chip:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.suggestions-loading {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 4px;
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrapper {
  flex: 1;
  background: var(--bg-input);
  border-radius: 24px;
  display: flex;
  align-items: flex-end;
  padding: 6px 12px;
  gap: 8px;
}

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 36px;
  line-height: 1.5;
  font-family: inherit;
  overflow-y: auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  padding: 6px 0;
}

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

.attach-btn {
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 2px;
  flex-shrink: 0;
  transition: color 0.2s;
}

.attach-btn:hover { color: var(--text); }

.send-btn,
.record-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

.send-btn {
  background: var(--accent);
  color: white;
}

.send-btn:hover { background: #0e7a72; }
.send-btn:active { transform: scale(0.95); }

.record-btn {
  background: var(--bg-input);
  color: var(--text-secondary);
}

.record-btn:hover { background: var(--bg-hover); color: var(--text); }
.record-btn.recording { background: var(--danger); color: white; animation: pulse 1s infinite; }

.recording-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-size: 13px;
  padding: 0 8px;
}

.recording-indicator.active { display: flex; }
.recording-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }

/* ── File attachment preview ───────────────────────────────────────────────── */
.attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

.attach-preview.hidden { display: none; }
.attach-preview-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-preview-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 18px; padding: 0; }

/* ── Calendar Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--bg-panel);
  border-radius: 12px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.event-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.event-date-block {
  text-align: center;
  min-width: 44px;
}

.event-day {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.event-month {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.event-info-block { flex: 1; min-width: 0; }

.event-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.event-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* .event-source styles moved to Message Context Menu section below */

.no-events {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 32px 0;
}

.add-event-form .form-group { margin-bottom: 12px; }

.add-event-form input,
.add-event-form textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.add-event-form input:focus,
.add-event-form textarea:focus {
  border-color: var(--accent);
}

.add-event-form textarea {
  resize: vertical;
  min-height: 60px;
}

/* ── Media Lightbox ────────────────────────────────────────────────────────── */
.media-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: zoom-out;
  padding: 20px;
}

.media-modal img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
}

.media-modal video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  outline: none;
}

/* ── Scroll-to-bottom button ───────────────────────────────────────────────── */
.scroll-bottom-btn {
  position: absolute;
  bottom: 80px;
  right: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.2s;
  color: var(--text);
}

.scroll-bottom-btn.hidden {
  display: none;
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-panel);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Message Context Menu ──────────────────────────────────────────────────── */
.msg-menu-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  background: rgba(0,0,0,0.35);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 15px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  padding: 0;
  line-height: 1;
}

.message-bubble:hover .msg-menu-btn {
  opacity: 1;
  pointer-events: auto;
}

.msg-menu-dropdown {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 200;
  min-width: 170px;
  overflow: hidden;
}

.msg-menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  background: none;
  border: none;
}

.msg-menu-item:hover {
  background: var(--bg-hover);
}

/* ── Calendar event source badges ──────────────────────────────────────────── */
.event-source-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.event-source {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 4px;
  opacity: 0.8;
}

.event-source--google    { background: rgba(66,133,244,0.2); color: #4285f4; }
.event-source--nextcloud { background: rgba(0,130,201,0.2);  color: #0082c9; }
.event-source--lokal,
.event-source--ollama    { background: rgba(18,140,126,0.2); color: var(--accent); }

.event-chat-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  opacity: 0.7;
}

.event-chat-link:hover { opacity: 1; }

.event-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  opacity: 0.5;
  margin-left: auto;
}

.event-delete-btn:hover { opacity: 1; }

/* ── Typing indicator ──────────────────────────────────────────────────────── */
.typing-indicator {
  padding: 4px 16px 0;
  display: flex;
  align-items: center;
}

.typing-indicator.hidden { display: none; }

.typing-bubble {
  background: var(--bg-hover);
  border-radius: 16px;
  padding: 8px 14px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing-dot 1.2s infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.2); }
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .chat-header-actions {
    display: none;
  }

  .chat-header-menu-btn {
    display: flex;
  }

  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    height: 100vh;
    border-right: none;
  }

  .sidebar.hidden { display: none; }

  .chat-view {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
  }

  .chat-view.active { display: flex; }

  .chat-header .back-btn {
    display: flex;
  }

  .message-bubble {
    max-width: 80%;
  }

  .msg-menu-btn {
    opacity: 0.6;
    pointer-events: auto;
  }
}

/* ── Next event bar ────────────────────────────────────────────────────────── */
.next-event-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(37,211,102,0.08);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.15s;
}

.next-event-bar:hover { background: rgba(37,211,102,0.15); }
.next-event-bar.hidden { display: none; }

.next-event-icon { flex-shrink: 0; }
.next-event-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ── Scripts modal ─────────────────────────────────────────────────────────── */
.modal--wide { width: min(960px, 95vw); height: min(700px, 92vh); display: flex; flex-direction: column; }
.modal--fullscreen { width: 97vw; height: 97vh; border-radius: 6px; display: flex; flex-direction: column; }

.scripts-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

.scripts-list-panel {
  width: 180px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.scripts-editor-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.scripts-editor-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 60px 20px;
  font-size: 14px;
}

.scripts-editor-form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.scripts-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.script-name-input {
  flex: 1;
  min-width: 120px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text);
  font-size: 13px;
}

.script-name-input:focus { outline: none; border-color: var(--accent); }

.scripts-editor-toolbar select {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text);
  font-size: 13px;
}

.script-enabled-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.script-code-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.script-code-container .cm-editor {
  height: 100%;
  font-size: 14px;
}

.script-code-container .cm-scroller {
  overflow: auto;
  font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
}

.script-code-container .cm-content {
  padding: 8px 0;
}

.script-ai-panel {
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 8px 12px;
}

.script-ai-panel.hidden { display: none; }

.script-ai-inner { display: flex; align-items: flex-end; gap: 8px; }

.script-ai-prompt {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  resize: none;
  outline: none;
  font-family: inherit;
  min-height: 36px;
  max-height: 120px;
}

.script-ai-prompt:focus { border-color: var(--accent); }

.script-ai-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-bottom: 6px;
}

.script-test-output {
  font-family: monospace;
  font-size: 12px;
  padding: 10px 14px;
  background: var(--bg-hover);
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
  color: var(--text-secondary);
}

.script-test-output.hidden { display: none; }

.script-list-item {
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.1s;
}

.script-list-item:hover { background: var(--bg-hover); }
.script-list-item.active { background: rgba(37,211,102,0.1); }

.script-list-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-list-meta {
  display: flex;
  gap: 6px;
  align-items: center;
}

.script-trigger-badge {
  font-size: 10px;
  background: var(--bg-hover);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-secondary);
}

.script-enabled-badge {
  font-size: 10px;
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 600;
}

.script-enabled-badge.enabled  { background: rgba(37,211,102,0.15); color: var(--accent); }
.script-enabled-badge.disabled { background: rgba(200,50,50,0.15);  color: #e05555; }

.btn-danger {
  background: rgba(200,50,50,0.1);
  border: 1px solid rgba(200,50,50,0.3);
  color: #e05555;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-danger:hover { background: rgba(200,50,50,0.2); }

/* ── Script logs overlay ──────────────────────────────────────────────────── */
.script-logs-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-dark);
  z-index: 2;
  padding: 16px;
  overflow-y: auto;
}

.script-logs-panel { height: 100%; }

.log-entry {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12px;
}

.log-entry.log-error { background: rgba(241,92,109,0.08); border-color: rgba(200,50,50,0.4); }

.log-entry-time {
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: 11px;
}

.log-entry-output,
.log-entry-error {
  margin: 4px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: monospace;
  font-size: 12px;
  background: var(--bg-input);
  padding: 6px 8px;
  border-radius: 4px;
}

.log-entry-error { color: #e05555; }

/* ── Script version history ────────────────────────────────────────────────── */
.script-versions-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-dark);
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.script-versions-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.script-versions-header h3 { margin: 0; flex: 1; font-size: 15px; }

.script-versions-list {
  flex: 1;
  overflow-y: auto;
}

.script-version-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  margin-bottom: 6px;
  font-size: 13px;
}

.script-version-item:hover { background: var(--bg-hover); }

.script-version-num {
  font-weight: 600;
  color: var(--accent-light);
  min-width: 32px;
}

.script-version-time { flex: 1; color: var(--text-secondary); font-size: 12px; }

.script-version-restore {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}

.script-version-restore:hover { border-color: var(--accent); color: var(--accent-light); }

/* ── Admin Layout ─────────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  height: 100vh;
  overflow: auto;
  background: var(--bg-dark);
}

.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 16px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav-item {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
}
.admin-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.admin-nav-item.active { background: var(--accent-bg); color: var(--accent-light); font-weight: 600; }

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.admin-section {
  padding: 32px 32px;
}
.admin-section h2 { margin: 0 0 20px; font-size: 20px; }
.admin-section h3 { margin: 0 0 12px; font-size: 15px; color: var(--text-secondary); }

/* ── Integration Cards ────────────────────────────────────────────────────── */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 20px;
}
.integration-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.integration-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-dark);
}
.integration-icon { font-size: 28px; flex-shrink: 0; }
.integration-title { font-weight: 600; font-size: 15px; }
.integration-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.integration-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
}
.integration-badge.configured { background: rgba(37,211,102,.15); color: var(--accent-light); }
.integration-badge.not-configured { background: var(--bg-hover); color: var(--text-muted); }
.integration-body { padding: 20px; }

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Admin Table ──────────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}
.admin-table td { padding: 10px 10px; border-bottom: 1px solid var(--border-subtle, var(--border)); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-hover); }

/* ── Session Cards ────────────────────────────────────────────────────────── */
.session-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.session-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.session-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.session-type-icon { flex-shrink: 0; display: flex; align-items: center; }
.session-card-name { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.session-status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-muted);
}
.session-status-badge.active,
.session-status-badge.ready { background: rgba(40,167,69,0.15); color: #5cb85c; }

.session-autostart-btn.autostart-off { color: var(--text-muted); opacity: 0.5; }
.session-status-badge.connecting,
.session-status-badge.awaiting_qr { background: rgba(255,193,7,0.15); color: #ffc107; }
.session-status-badge.disconnected,
.session-status-badge.auth_failure { background: rgba(220,53,69,0.15); color: #e05555; }

/* ── Session Type Grid (wizard) ───────────────────────────────────────────── */
.session-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.session-type-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 8px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.session-type-btn:hover { background: var(--bg-hover); border-color: var(--accent); transform: translateY(-2px); }
.session-type-btn-icon { display: flex; align-items: center; justify-content: center; }

/* ── Setup Instructions ──────────────────────────────────────────────────────── */
.setup-instructions {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.setup-instructions-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 8px;
}
.setup-instructions-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.7;
}
.setup-instructions-steps code {
  background: rgba(255,255,255,0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ── Mini Charts ──────────────────────────────────────────────────────────── */
.chart-section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.chart-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 52px;
  overflow: hidden;
}
.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 3px;
  cursor: default;
}
.chart-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: opacity 0.15s;
}
.chart-col:hover .chart-bar { opacity: 0.75; }
.chart-lbl {
  font-size: 8px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
  text-align: center;
}

/* ── Admin Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .admin-layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .admin-sidebar {
    width: 100%;
    flex-direction: column;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px;
  }

  .admin-logo {
    padding: 4px 8px 10px;
    margin-bottom: 8px;
    font-size: 14px;
  }

  .admin-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .admin-nav::-webkit-scrollbar { display: none; }

  .admin-nav-item {
    padding: 6px 10px;
    white-space: nowrap;
    font-size: 13px;
    flex-shrink: 0;
  }

  .admin-content {
    overflow-y: visible;
  }

  .admin-section {
    padding: 16px;
  }

  .integration-grid,
  .chart-section {
    grid-template-columns: 1fr;
  }

  .session-cards {
    grid-template-columns: 1fr;
  }

  .session-type-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    min-width: 500px;
  }
}

/* ── Form helpers ─────────────────────────────────────────────────────────── */
.input-field {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  box-sizing: border-box;
}
.input-field:focus { border-color: var(--accent); }
.input-field:disabled { opacity: 0.5; cursor: not-allowed; }

.select-field {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 7px 10px;
  outline: none;
}

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Auth card improvements ───────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 5px; }

/* ── Mood Check Modal ──────────────────────────────────────────────────────── */
.mood-check-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.mood-check-modal {
  background: #1a2632;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 24px;
  max-width: 380px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
  animation: moodCheckIn 0.2s ease-out;
}
@keyframes moodCheckIn {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.mood-check-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.mood-check-score {
  font-size: 13px;
  font-weight: 600;
  color: #e05260;
}
.mood-check-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.mood-check-rewrite {
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mood-check-rewrite-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mood-check-rewrite-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.mood-check-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 4px;
}
.mood-check-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.mood-check-btn:hover { opacity: 0.85; }
.mood-check-cancel { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
.mood-check-send-anyway { background: rgba(224,82,96,0.25); color: #e05260; }
.mood-check-use { background: var(--accent); color: #fff; }
.mood-check-loading-modal {
  align-items: center;
  padding: 32px 24px;
  gap: 16px;
}
.mood-check-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: moodCheckSpin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes moodCheckSpin {
  to { transform: rotate(360deg); }
}
.mood-check-loading-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Deleted message placeholders ───────────────────────────────────────── */
.deleted-placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Deleted-everywhere badge (restored) ─────────────────────────────────── */
.deleted-tag {
  display: inline-block;
  background: rgba(255,80,80,0.18);
  color: #ff6b6b;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 1px 5px;
  margin-bottom: 4px;
}

/* ── TTS audio track ─────────────────────────────────────────────────────── */
.tts-track {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 4px 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
}

.tts-track-label {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── AI Chat ───────────────────────────────────────────────────────────────── */
.ai-bubble-badge {
  font-size: 14px;
  margin-bottom: 2px;
  display: block;
}
.ai-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-compressed-divider {
  text-align: center;
  margin: 8px 0;
  position: relative;
}
.ai-compressed-divider span {
  background: var(--bg-panel);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ── Previous Conversation Note ───────────────────────────────────────────── */
.prev-conv-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
  padding: 8px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.prev-conv-btn {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── PWA Install / Push Banner ─────────────────────────────────────────────── */
.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 999;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.pwa-banner--visible {
  transform: translateY(0);
}
body.pwa-install-visible .chat-view {
  padding-bottom: 56px;
}
.pwa-banner-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.pwa-banner-text {
  flex: 1;
  font-size: 14px;
  color: var(--text);
}
.pwa-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.pwa-banner-btn {
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.pwa-banner-btn--primary {
  background: var(--accent);
  color: #fff;
}
.pwa-banner-btn--secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
}

/* ── Burger Menu + Header Dropdowns ───────────────────────────────────────── */
.burger-btn {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -1px;
}

.header-dropdown {
  position: fixed;
  z-index: 2000;
  background: #1a2632;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  min-width: 200px;
  padding: 6px;
  animation: dropdownIn 0.15s ease-out;
}

@keyframes dropdownIn {
  from { transform: translateY(-6px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* Burger dropdown */
.burger-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.burger-item:hover { background: var(--bg-hover); }

.burger-item--active {
  background: rgba(108,63,197,0.20);
  color: #a78bfa;
}

.burger-item--danger { color: #e05260; }
.burger-item--danger:hover { background: rgba(224,82,96,0.12); }

.burger-item-icon { font-size: 16px; width: 20px; text-align: center; }

.burger-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 4px 6px;
}

/* Status dropdown */
.header-dropdown-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 4px 12px 8px;
}

.sys-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
}

.sys-status-row:hover { background: var(--bg-hover); }

.sys-status-row-dot { font-size: 10px; flex-shrink: 0; }

.sys-status-row-name {
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.sys-status-row-detail {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Status button dot */
.sys-status-dot {
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 4px currentColor);
}

/* ── Avatar gallery ───────────────────────────────────────────────────────── */
.avatar-gallery-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.avatar-gallery-modal {
  background: var(--bg-panel);
  border-radius: 12px;
  width: min(480px, 94vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.avatar-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.avatar-gallery-title {
  font-weight: 600;
  font-size: 15px;
}

.avatar-gallery-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.avatar-gallery-close:hover { background: var(--bg-hover); }

.avatar-gallery-loading {
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
}

.avatar-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
}

.avatar-gallery-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .15s;
}

.avatar-gallery-img:hover { opacity: .85; }

/* ── Forwarded tag ────────────────────────────────────────────────────────── */
.forwarded-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ── Quoted message preview ────────────────────────────────────────────────── */
.quoted-preview {
  border-left: 3px solid var(--accent);
  padding: 4px 8px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 0 6px 6px 0;
  max-width: 100%;
  overflow: hidden;
}
.quoted-from {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}
.quoted-body {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Reply bar ─────────────────────────────────────────────────────────────── */
.reply-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 12px;
}
.reply-bar.hidden { display: none; }
.reply-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}
.reply-bar-content {
  flex: 1;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  min-width: 0;
}
.reply-bar-from {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.reply-bar-preview {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-bar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.reply-bar-close:hover { color: var(--text); }

/* ── Forward modal chat item ───────────────────────────────────────────────── */
.forward-chat-item:hover {
  background: var(--surface-hover, rgba(255,255,255,0.07));
}

/* ── Modal close button ───────────────────────────────────────────────────── */
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.modal-close:hover { background: var(--surface); color: var(--text); }

.modal-header h2, .modal-header h3 { font-size: 16px; font-weight: 600; margin: 0; }

/* ── Loom ─────────────────────────────────────────────────────────────────── */
#loom-messages { gap: 6px; }

.loom-date-separator {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
  margin: 8px 0 4px;
  position: relative;
}
.loom-date-separator::before, .loom-date-separator::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}
.loom-date-separator::before { left: 0; }
.loom-date-separator::after  { right: 0; }

.loom-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}
.loom-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.loom-card-icon   { font-size: 16px; }
.loom-card-type   { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.loom-card-time   { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.loom-time-edit-btn {
  font-size: 12px; color: var(--text-muted); margin-left: auto;
  background: none; border: none; cursor: pointer; padding: 2px 4px; border-radius: 4px;
}
.loom-time-edit-btn:hover { color: var(--accent); background: rgba(255,255,255,0.06); }
.loom-card-status { font-size: 14px; }
.loom-card-delete { margin-left: 4px; font-size: 13px; opacity: 0.6; }
.loom-card-delete:hover { opacity: 1; }
.loom-processing-banner {
  background: rgba(255, 180, 0, 0.12);
  border-bottom: 1px solid rgba(255, 180, 0, 0.25);
  color: #f5c842;
  font-size: 12px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px 8px 0 0;
}
.loom-card-body   { padding: 10px 12px; }
.loom-transcript-wrap { font-size: 14px; line-height: 1.5; }
.loom-transcript-summary {
  list-style: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 4px 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
  user-select: none;
}
.loom-transcript-summary::-webkit-details-marker { display: none; }
.loom-transcript-summary::before { content: '▶'; font-size: 9px; opacity: 0.5; transition: transform 0.15s; flex-shrink: 0; }
details[open] > .loom-transcript-summary::before { transform: rotate(90deg); }
.loom-transcript-meta { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.loom-transcript-full { font-size: 14px; line-height: 1.6; padding-top: 6px; white-space: pre-wrap; word-break: break-word; }
.loom-transcript  { font-size: 14px; line-height: 1.5; }
.loom-speaker     { font-weight: 600; color: var(--accent); font-size: 12px; margin-right: 4px; }
.loom-audio-player {
  width: 100%;
  height: 36px;
  margin-bottom: 8px;
  border-radius: 8px;
  outline: none;
  accent-color: var(--accent);
}
.loom-meta        { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.loom-meta-label  { color: var(--text-muted); }

.loom-qa-pair {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.loom-question-bubble {
  align-self: flex-end;
  position: relative;
  background: var(--accent);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.loom-answer-bubble {
  align-self: flex-start;
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.loom-qa-sender {
  display: block;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.loom-qa-sender--ai { color: var(--accent); opacity: 1; }
.loom-qa-delete-btn {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: inherit;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
  line-height: 1;
}
.loom-question-bubble:hover .loom-qa-delete-btn { opacity: 0.6; }
.loom-qa-delete-btn:hover { opacity: 1 !important; }

.loom-contacts-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 4px 12px 6px;
  border-top: 1px solid var(--border);
}
.loom-contacts-row--empty {
  border-top: none;
  padding-top: 0;
  padding-bottom: 4px;
}
.loom-contact-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px 2px 6px;
  font-size: 12px;
  color: var(--text-primary);
}
.loom-contact-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  margin-left: 2px;
}
.loom-contact-chip-remove:hover { color: var(--danger); }
.loom-contact-add-btn { font-size: 14px; opacity: 0.6; }
.loom-contact-add-btn:hover { opacity: 1; }

.loom-ask-bar { background: var(--bg-primary); }
.loom-webhook-item { background: var(--bg-secondary); }

/* ── Contacts ─────────────────────────────────────────────────────────────── */
.contact-list-item:hover { background: var(--surface-hover, rgba(255,255,255,0.06)); }
.contact-list-item.active { background: var(--surface-active, rgba(255,255,255,0.1)); }

/* ── Contact suggestion modal ─────────────────────────────────────────────── */
.contact-suggestion-modal { backdrop-filter: blur(2px); }
