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

:root {
  --blue: #007AFF;
  --gray-light: #f2f2f7;
  --gray-mid: #e5e5ea;
  --gray-text: #8e8e93;
  --black: #1c1c1e;
  --white: #ffffff;
  --bubble-user: #007AFF;
  --bubble-bot: #e9e9eb;
  --radius: 18px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f0f5;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.screen { display: flex; justify-content: center; align-items: center; min-height: 100vh; width: 100%; }
.hidden { display: none !important; }

/* iPhone Frame */
.iphone-frame {
  position: relative;
  overflow: hidden;
  width: 390px;
  height: min(844px, calc(100vh - 40px));
  height: min(844px, calc(100dvh - 40px));
  background: var(--white);
  border-radius: 44px;
  box-shadow: 0 0 0 2px #d1d1d6, 0 20px 60px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* On actual mobile, fill the screen */
@media (max-width: 430px) {
  body { background: var(--white); }
  .iphone-frame {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Login */
.login-frame {
  justify-content: center;
  align-items: center;
}

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
}

.logo {
  font-size: 36px;
  font-weight: 600;
  color: var(--black);
  letter-spacing: -1px;
}

.tagline {
  font-size: 15px;
  color: var(--gray-text);
  margin-bottom: 24px;
}

.google-sign-in-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: var(--white);
  border: 1px solid var(--gray-mid);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--black);
  text-decoration: none;
  transition: background 0.15s;
}
.google-sign-in-btn:hover { background: var(--gray-light); }

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--gray-mid);
  flex-shrink: 0;
  background: var(--white);
  padding-top: 20px;
}

.header-left { flex-shrink: 0; }
.header-logo {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-text);
  letter-spacing: -0.3px;
}

.header-center {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.header-title { font-size: 16px; font-weight: 600; color: var(--black); }
.header-status {
  font-size: 11px;
  color: #34C759;
  font-weight: 500;
}
.header-status.thinking { color: #FF9500; }

.header-right { flex-shrink: 0; }
.settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-text);
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}
.settings-btn:hover { background: var(--gray-light); }

/* Settings Panel */
.settings-panel {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--white);
  z-index: 10;
  padding: 20px;
  overflow-y: auto;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.settings-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}
.settings-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
.settings-name { font-size: 16px; font-weight: 600; color: var(--black); }
.settings-email { font-size: 13px; color: var(--gray-text); }
.settings-divider { height: 1px; background: var(--gray-mid); margin: 12px 0; }
.settings-label { font-size: 12px; font-weight: 600; color: var(--gray-text); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

/* Integration search */
.int-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-mid);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--gray-light);
  color: var(--black);
  outline: none;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.int-search:focus { border-color: #4285F4; background: #fff; }
.int-search::placeholder { color: #999; }

/* Integration list */
.int-list { display: flex; flex-direction: column; gap: 2px; }
.int-row {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.15s;
  gap: 8px;
}
.int-row:hover { background: var(--gray-light); }
.int-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  flex-shrink: 0;
}
.int-row-name { font-size: 13px; font-weight: 500; color: var(--black); }
.int-row-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.int-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bbb;
  flex-shrink: 0;
  transition: background 0.2s;
}
.int-dot.green { background: #4caf50; }
.int-dot.amber { background: #ff9800; animation: pulse-warn 2s ease-in-out infinite; }
.int-dot.gray { background: #bbb; }
@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.int-status-text { font-size: 12px; color: #777; white-space: nowrap; }
.int-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}
.int-btn {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--gray-mid);
  background: #fff;
  color: var(--black);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.int-btn:hover { background: var(--gray-light); }
.int-btn.connect { border-color: #4285F4; color: #4285F4; }
.int-btn.connect:hover { background: #e8f0fe; }
.int-btn.reconnect { background: #ff9800; color: #fff; border-color: #ff9800; }
.int-btn.reconnect:hover { background: #f57c00; }
.int-btn.danger { color: #d32f2f; border-color: #eee; }
.int-btn.danger:hover { background: #ffebee; }
/* Auth expired toast */
.auth-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.auth-toast a {
  color: #e65100;
  font-weight: 700;
  text-decoration: underline;
}
.auth-toast .dismiss {
  cursor: pointer;
  opacity: 0.6;
  font-size: 18px;
  margin-left: 8px;
}

.settings-logout {
  width: 100%;
  padding: 12px;
  background: none;
  border: 1px solid #ff3b30;
  border-radius: 12px;
  color: #ff3b30;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.settings-logout:hover { background: #fff5f5; }

/* Messages Area */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

/* Welcome state */
.welcome-msg {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

/* Message Bubbles */
.msg-row {
  display: flex;
  max-width: 82%;
}
.msg-row.user { align-self: flex-end; }
.msg-row.bot { align-self: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg-row.user .bubble {
  background: var(--bubble-user);
  color: var(--white);
  border-bottom-right-radius: 6px;
}

.msg-row.bot .bubble {
  background: var(--bubble-bot);
  color: var(--black);
  border-bottom-left-radius: 6px;
}

/* Markdown in bot bubbles */
.msg-row.bot .bubble p { margin: 0 0 8px; }
.msg-row.bot .bubble p:last-child { margin: 0; }
.msg-row.bot .bubble code {
  background: rgba(0,0,0,0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.msg-row.bot .bubble pre {
  background: rgba(0,0,0,0.06);
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg-row.bot .bubble pre code {
  background: none;
  padding: 0;
}
.msg-row.bot .bubble ul, .msg-row.bot .bubble ol {
  margin: 8px 0;
  padding-left: 28px;
}
.msg-row.bot .bubble li {
  margin-bottom: 4px;
  padding-left: 4px;
}

/* Thinking indicator */
.thinking-row {
  align-self: flex-start;
  max-width: 82%;
}
.thinking-bubble {
  background: var(--bubble-bot);
  border-radius: var(--radius);
  border-bottom-left-radius: 6px;
  padding: 12px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.thinking-bubble span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: blink 1.4s infinite both;
}
.thinking-bubble span:nth-child(2) { animation-delay: 0.2s; }
.thinking-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Input Bar */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px 24px;
  border-top: 1px solid var(--gray-mid);
  background: var(--white);
  flex-shrink: 0;
}

@media (max-width: 430px) {
  .input-bar {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

.input-bar textarea {
  flex: 1;
  border: 1px solid var(--gray-mid);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  background: var(--gray-light);
  transition: border-color 0.15s;
}
.input-bar textarea:focus { border-color: var(--blue); }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.send-btn:hover { opacity: 0.85; }
.send-btn:active { transform: scale(0.95); }

/* Timestamp */
.msg-time {
  font-size: 11px;
  color: var(--gray-text);
  margin-top: 2px;
  padding: 0 4px;
}
.msg-row.user .msg-time { text-align: right; }

/* History divider */
.history-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
  margin: 8px 0;
}
.history-divider span {
  font-size: 11px;
  color: #999;
  background: #f8f8f8;
  padding: 2px 12px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Hidden history block */
.history-hidden {
  display: none;
}
.history-visible {
  display: block;
}
.history-divider {
  cursor: pointer;
}
.history-divider:hover span {
  background: #eee;
}

/* Input bar icons */
.input-icon-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s;
}
.input-icon-btn:hover {
  background: #f0f0f0;
}
.input-icon-btn:hover svg {
  stroke: #007AFF;
}
.input-icon-btn.recording svg {
  stroke: #FF3B30;
}
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

/* Chat images */
.chat-image {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 4px;
  display: block;
}
.bubble .chat-image + * {
  margin-top: 4px;
}

/* oneed icon */
.oneed-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

/* Integrations Bar */
.integrations-bar {
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
}
.integrations-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: color 0.15s;
}
.integrations-toggle:hover {
  color: #333;
}
.integrations-toggle .chevron {
  margin-left: auto;
  transition: transform 0.2s;
}
.integrations-bar.expanded .integrations-toggle .chevron {
  transform: rotate(180deg);
}
.integrations-panel {
  padding: 0 16px 12px;
  animation: slideDown 0.2s ease;
}
.integrations-panel.hidden {
  display: none;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.int-section {
  margin-bottom: 10px;
}
.int-section:last-child {
  margin-bottom: 0;
}
.int-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #999;
  margin-bottom: 6px;
}
.int-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.int-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: #f5f5f5;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.int-pill:hover {
  background: #eee;
}
.int-pill.active {
  background: #E8F4FD;
  color: #007AFF;
  border-color: #B8DFFB;
}
.int-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ccc;
}
.int-dot.green {
  background: #34C759;
}

/* Hamburger */
.hamburger-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #333;
  display: flex;
  align-items: center;
}
.hamburger-btn:hover {
  color: #007AFF;
}

/* Nav overlay + menu */
.nav-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
}
.nav-overlay.hidden { display: none; }

.nav-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 220px;
  height: 100%;
  background: #fff;
  z-index: 101;
  box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  border-radius: 20px 0 0 20px;
  overflow: hidden;
  animation: slideIn 0.2s ease;
}
.nav-menu.hidden { display: none; }

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  font-size: 15px;
  font-weight: 600;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}
.nav-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
}
.nav-close:hover { color: #333; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-size: 14px;
  color: #555;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-item:hover {
  background: #f5f5f5;
}
.nav-item.active {
  color: #007AFF;
  font-weight: 500;
  background: #E8F4FD;
}

/* Story Circles - Instagram style */
.story-circles {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  border-bottom: 1px solid #f0f0f0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.story-circles::-webkit-scrollbar {
  display: none;
}
.story-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.circle-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007AFF, #5AC8FA);
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.circle-ring.dashed {
  background: none;
  border: 2px dashed #007AFF;
  padding: 1px;
}
.circle-ring:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 12px rgba(0,122,255,0.3);
}
.circle-icon {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.circle-label {
  font-size: 10px;
  color: #666;
  text-align: center;
  max-width: 70px;
  line-height: 1.2;
}

/* Input Area - two rows */
.input-area {
  flex-shrink: 0;
  border-top: 1px solid #f0f0f0;
  background: #fff;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

/* Voice Row */
.voice-row {
  margin-bottom: 8px;
  position: relative;
}
.voice-big-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border: none;
  border-radius: 16px;
  background: #007AFF;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.voice-big-btn:hover {
  background: #0066DD;
}
.voice-big-btn:active {
  transform: scale(0.98);
  background: #0055CC;
}
.voice-big-btn.recording {
  background: #007AFF;
  box-shadow: 0 0 0 0 rgba(0,122,255,0.4);
  animation: micPulse 1.5s ease-in-out infinite;
}
.voice-big-btn.channel-open {
  background: #007AFF;
  color: #fff;
  animation: micPulse 1.5s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(255,59,48,0); }
}
.voice-label {
  pointer-events: none;
}

/* Recording indicator */
.voice-recording-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #007AFF;
  border-radius: 16px;
  color: #fff;
  font-weight: 500;
}
.voice-recording-indicator.hidden {
  display: none;
}
.voice-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.voice-hint {
  font-size: 12px;
  opacity: 0.7;
}

/* Text Row */
.text-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

/* Remove old input-bar styles conflict */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

/* Telegram-style text input */
.text-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.text-input-container {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: #f0f0f0;
  border-radius: 20px;
  padding: 4px 4px 4px 8px;
  min-height: 40px;
}
.text-input-container:focus-within {
  background: #e8e8e8;
}
.attach-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  transition: color 0.15s;
}
.attach-btn:hover {
  color: #007AFF;
}
.text-input-container textarea {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
  padding: 6px 8px;
  resize: none;
  max-height: 100px;
  color: #333;
}
.text-input-container textarea::placeholder {
  color: #aaa;
}
.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #007AFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.send-btn:hover {
  background: #0066DD;
}
.send-btn:active {
  transform: scale(0.92);
}

/* Voice message bubble */
.voice-bubble { margin-bottom: 6px; }
.voice-player {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.08); border-radius: 16px;
  padding: 8px 12px; min-width: 200px; max-width: 280px;
}
.voice-play-btn {
  background: none; border: none; color: inherit; cursor: pointer;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(255,255,255,0.15); flex-shrink: 0;
}
.voice-play-btn:hover { background: rgba(255,255,255,0.25); }
.voice-progress-wrap { flex: 1; }
.voice-progress {
  height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; overflow: hidden;
}
.voice-progress-bar { height: 100%; width: 0%; background: #34C759; border-radius: 2px; transition: width 0.1s linear; }
.voice-duration { font-size: 11px; opacity: 0.7; min-width: 30px; text-align: right; }

/* Fix vertical proportions */
.story-circles {
  padding: 8px 16px;
  gap: 12px;
  flex-shrink: 0;
}
.circle-ring {
  width: 52px;
  height: 52px;
}
.circle-label {
  font-size: 9px;
}
.voice-row {
  margin-bottom: 6px;
}
.voice-big-btn {
  padding: 10px;
  font-size: 13px;
}
.input-area {
  padding: 6px 12px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.chat-header {
  padding: 8px 16px;
  flex-shrink: 0;
}
.messages-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Mic pulse - blue glow */
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,122,255,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(0,122,255,0); }
}

/* Waveform container */
.waveform-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.waveform-container canvas {
  display: block;
}

/* ---- Workgroup Styles ---- */

/* Nav workgroups */
.nav-divider { height: 1px; background: #f0f0f0; margin: 8px 16px; }
.nav-section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: #999; padding: 8px 16px 4px; }
.nav-wg-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  font-size: 14px; color: #555; cursor: pointer; transition: background 0.15s;
}
.nav-wg-item:hover { background: #f5f5f5; }
.nav-wg-item .wg-count { font-size: 11px; color: #999; margin-left: auto; }

/* Workgroup tab bar */
.workgroup-tabs {
  display: flex; align-items: center; gap: 0; padding: 0 16px;
  border-bottom: 1px solid #f0f0f0; flex-shrink: 0; background: #fff;
}
.wg-tab {
  flex: 1; padding: 10px 0; background: none; border: none; border-bottom: 2px solid transparent;
  font-size: 14px; font-weight: 500; color: #999; cursor: pointer; text-align: center; transition: all 0.15s;
}
.wg-tab.active { color: #007AFF; border-bottom-color: #007AFF; }
.wg-invite-btn, .wg-back-btn {
  background: none; border: none; padding: 8px; cursor: pointer; color: #999; display: flex; align-items: center;
}
.wg-invite-btn:hover, .wg-back-btn:hover { color: #007AFF; }

/* Group messages with sender info */
.wg-msg-row { display: flex; flex-direction: column; max-width: 82%; gap: 2px; }
.wg-msg-row.self { align-self: flex-end; }
.wg-msg-row.other { align-self: flex-start; }
.wg-sender { font-size: 11px; color: #999; padding: 0 4px; }
.wg-msg-row.self .wg-sender { text-align: right; }
.wg-bot-label { font-size: 10px; color: #007AFF; font-weight: 500; }
.wg-msg-bubble {
  padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.4;
  word-wrap: break-word; overflow-wrap: break-word;
}
.wg-msg-row.self .wg-msg-bubble { background: #f8f9fa; color: #1c1c1e; border: 1px solid #e0e0e0; border-bottom-right-radius: 6px; }
.wg-msg-row.other .wg-msg-bubble { background: #fff; color: #1c1c1e; border: 1px solid #e5e5ea; border-bottom-left-radius: 6px; }
.wg-msg-row.bot-post .wg-msg-bubble { background: #E8F4FD; color: #1c1c1e; border-bottom-left-radius: 6px; }
.wg-avatar {
  width: 24px; height: 24px; border-radius: 50%; display: inline-block; vertical-align: middle; margin-right: 4px;
}
.wg-avatar-initial {
  width: 24px; height: 24px; border-radius: 50%; background: #007AFF; color: #fff;
  font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle; margin-right: 4px;
}

/* Copy to chat button */
.copy-to-chat-btn {
  background: none; border: 1px solid #ddd; border-radius: 12px; padding: 3px 8px;
  font-size: 10px; color: #666; cursor: pointer; margin-top: 4px; transition: all 0.15s;
}
.copy-to-chat-btn:hover { background: #f0f0f0; border-color: #007AFF; color: #007AFF; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 200; display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none !important; }
.modal-box {
  background: #fff; border-radius: 16px; padding: 24px; width: 300px; max-width: 90vw;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-box h3 { font-size: 17px; font-weight: 600; margin-bottom: 16px; color: #1c1c1e; }
.modal-box input {
  width: 100%; padding: 10px 14px; border: 1px solid #e5e5ea; border-radius: 10px;
  font-size: 15px; outline: none; margin-bottom: 16px;
}
.modal-box input:focus { border-color: #007AFF; }
.modal-buttons { display: flex; gap: 8px; justify-content: flex-end; }
.modal-cancel {
  padding: 8px 16px; background: none; border: 1px solid #e5e5ea; border-radius: 10px;
  font-size: 14px; cursor: pointer; color: #666;
}
.modal-confirm {
  padding: 8px 16px; background: #007AFF; border: none; border-radius: 10px;
  font-size: 14px; cursor: pointer; color: #fff; font-weight: 500;
}
.modal-confirm:hover { background: #0066DD; }

/* Markdown body in full-screen reader */
.markdown-body { word-wrap: break-word; overflow-wrap: break-word; white-space: normal; }
.markdown-body pre { white-space: pre-wrap; word-wrap: break-word; overflow-x: auto; max-width: 100%; }
.markdown-body code { white-space: pre-wrap; word-wrap: break-word; }
.markdown-body table { display: block; overflow-x: auto; max-width: 100%; }
.markdown-body img { max-width: 100%; height: auto; }
.markdown-body p, .markdown-body li, .markdown-body blockquote { word-wrap: break-word; overflow-wrap: break-word; }

/* Markdown wrap in bot bubbles */
.bubble { word-wrap: break-word; overflow-wrap: break-word; max-width: 100%; }
.bubble pre { white-space: pre-wrap; word-wrap: break-word; overflow-x: auto; max-width: 100%; }
.bubble code { white-space: pre-wrap; word-wrap: break-word; }
.bubble table { display: block; overflow-x: auto; max-width: 100%; }
.bubble p, .bubble li, .bubble blockquote, .bubble h1, .bubble h2, .bubble h3 { word-wrap: break-word; overflow-wrap: break-word; }

/* Markdown toolbar buttons */
.md-tb { background:#EDF2F7; border:1px solid #CBD5E0; border-radius:6px; padding:5px 9px; font-size:12px; cursor:pointer; color:#007AFF; min-width:28px; text-align:center; font-weight:500; }
.md-tb:hover { background:#E2E8F0; }
.md-tb:active { background:#BEE3F8; }

/* Online Friends Section */
.online-friends-section { padding: 0 16px 8px; }
.online-friends-title { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; font-weight: 600; }
.online-friends-list { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.online-friend { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; }
.online-friend-avatar { position: relative; width: 40px; height: 40px; border-radius: 50%; background: #E0E7EF; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600; color: #555; overflow: hidden; }
.online-friend-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.online-friend-dot { position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%; background: #34C759; border: 2px solid #1a1a2e; }
.offline-friend-dot { background: #666; }
.online-friend-name { font-size: 11px; color: #ccc; max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }

/* Refresh icon button */
.int-refresh-icon {
  font-size: 1.3em;
  line-height: 1;
  padding: 4px 8px;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.3s ease, color 0.2s;
  title: "Refresh";
}
.int-refresh-icon:hover {
  color: #333;
  transform: rotate(180deg);
}

/* Integration group labels */
.int-group-label {
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  color: #999;
  letter-spacing: 0.05em;
  padding: 12px 0 4px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
}
.int-group-label:first-child {
  padding-top: 4px;
}

/* Integration row - add refresh column */
.int-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

/* Refresh column (left) */
.int-row-refresh {
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Phase 1: Stream Filter Bar ---- */
.stream-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
}
.stream-filters {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.stream-filters::-webkit-scrollbar { display: none; }
.stream-filter {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid #e5e5ea;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.stream-filter.active {
  background: #007AFF;
  color: #fff;
  border-color: #007AFF;
}
.stream-filter:hover:not(.active) {
  background: #f5f5f5;
}
.stream-filter-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ---- Phase 1: Stream Message Types ---- */

/* Bot messages - indigo tint */
.stream-msg-bot .wg-msg-bubble {
  background: #EEF0FF !important;
  color: #1c1c1e !important;
  border-bottom-left-radius: 6px;
}
.stream-bot-label {
  font-size: 11px;
  color: #5B5FC7;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* File cards */
.stream-file-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 14px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  max-width: 85%;
  cursor: default;
}
.stream-file-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.stream-file-info {
  flex: 1;
  min-width: 0;
}
.stream-file-name {
  font-size: 14px;
  font-weight: 500;
  color: #1c1c1e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stream-file-meta {
  font-size: 11px;
  color: #8e8e93;
}
.stream-file-actions {
  display: flex;
  gap: 6px;
}
.stream-file-btn {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid #e5e5ea;
  background: #fff;
  font-size: 11px;
  font-weight: 500;
  color: #007AFF;
  cursor: pointer;
  transition: background 0.15s;
}
.stream-file-btn:hover { background: #f0f0f5; }

/* Activity events */
.stream-activity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  color: #8e8e93;
  font-size: 12px;
  width: 100%;
}
.stream-activity-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.stream-activity-text {
  flex: 1;
}
.stream-activity-time {
  font-size: 10px;
  color: #bbb;
  flex-shrink: 0;
}
.stream-activity-detail {
  font-size: 11px;
  color: #007AFF;
  cursor: pointer;
  flex-shrink: 0;
}

/* Date dividers */
.stream-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 8px;
}
.stream-date-divider span {
  font-size: 11px;
  color: #999;
  background: #f0f0f5;
  padding: 3px 12px;
  border-radius: 10px;
  font-weight: 500;
}

/* File card inline preview */
.stream-file-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.stream-file-expand-icon {
  font-size: 0.8em;
  color: #999;
  transition: transform 0.2s;
}
.stream-file-preview {
  margin-top: 8px;
  border-top: 1px solid #eee;
  max-height: 500px;
  overflow-y: auto;
}
.stream-file-md {
  padding: 12px 8px;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
}
.stream-file-md h1, .stream-file-md h2, .stream-file-md h3 {
  margin-top: 16px;
  margin-bottom: 8px;
}
.stream-file-md h1 { font-size: 1.3em; }
.stream-file-md h2 { font-size: 1.15em; }
.stream-file-md h3 { font-size: 1.05em; }
.stream-file-md p { margin: 8px 0; }
.stream-file-md ul, .stream-file-md ol { padding-left: 20px; margin: 8px 0; }
.stream-file-md code {
  background: #f4f4f4;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}
.stream-file-md pre {
  background: #f4f4f4;
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85em;
}
.stream-file-md table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
}
.stream-file-md th, .stream-file-md td {
  border: 1px solid #ddd;
  padding: 6px 10px;
  text-align: left;
  font-size: 0.9em;
}
.stream-file-md th { background: #f8f8f8; font-weight: 600; }
.stream-file-pre {
  padding: 12px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8f8f8;
  border-radius: 6px;
}
.stream-file-loading {
  padding: 12px;
  color: #999;
  font-style: italic;
}
.stream-file-error {
  padding: 12px;
  color: #E44332;
}
