/* ── SquirrelChat Layout ──────────────────────────────────────────────────── */

.sc-layout {
  display: flex;
  height: calc(100vh - 52px); /* below header */
  overflow: hidden;
  background: var(--bg);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sc-sidebar {
  width: 220px;
  min-width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sc-sidebar-section {
  padding: 12px 0 4px;
  border-bottom: 1px solid var(--border2);
}

.sc-sidebar-section:last-child {
  border-bottom: none;
  flex: 1;
}

.sc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.sc-channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  cursor: pointer;
  color: var(--text-dim);
  border-radius: 4px;
  margin: 0 4px;
  font-size: 13px;
  transition: background 0.1s, color 0.1s;
}

.sc-channel-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.sc-channel-active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
}

.sc-unread {
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

/* Mention unread badge — yellow to distinguish from regular unread */
.sc-unread.sc-unread-mention {
  background: var(--yellow, #f5c518);
  color: #000;
}

.sc-agent-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.sc-presence {
  font-size: 9px;
  line-height: 1;
}

.sc-agent-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-project-item {
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  border-radius: 4px;
  margin: 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.sc-project-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.sc-mini-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 3px;
  padding: 1px 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
  transition: color 0.1s, border-color 0.1s;
}

.sc-mini-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

/* ── Main area ───────────────────────────────────────────────────────────── */

.sc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Chat view ───────────────────────────────────────────────────────────── */

.sc-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sc-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sc-channel-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.sc-conn-badge {
  font-size: 11px;
}

.sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sc-no-messages {
  color: var(--text-dimmer);
  font-size: 12px;
  text-align: center;
  padding: 32px 0;
}

.sc-msg {
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}

.sc-msg:hover {
  background: var(--surface2);
}

/* Message row highlight when current user is @mentioned */
.sc-msg.sc-msg-mention {
  background: color-mix(in srgb, var(--yellow, #f5c518) 12%, transparent);
  border-left: 3px solid var(--yellow, #f5c518);
  padding-left: 9px;
}

.sc-msg.sc-msg-mention:hover {
  background: color-mix(in srgb, var(--yellow, #f5c518) 20%, transparent);
}

.sc-msg:hover .sc-msg-actions {
  opacity: 1;
}

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

.sc-msg-from {
  font-weight: 700;
  font-size: 13px;
  color: var(--blue);
}

.sc-msg-ts {
  font-size: 11px;
  color: var(--text-dimmer);
}

.sc-msg-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.1s;
}

.sc-react-btn,
.sc-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 1px 3px;
  border-radius: 3px;
  opacity: 0.7;
  transition: opacity 0.1s, background 0.1s;
}

.sc-react-btn:hover,
.sc-del-btn:hover {
  opacity: 1;
  background: var(--surface);
}

.sc-msg-content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.sc-msg-body {
  display: inline;
}

.sc-mention {
  color: var(--blue);
  font-weight: 700;
}

/* ── Input area ──────────────────────────────────────────────────────────── */

.sc-input-area {
  padding: 10px 18px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.sc-mention-dropdown {
  position: absolute;
  bottom: calc(100% - 10px);
  left: 18px;
  right: 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
  z-index: 10;
  overflow: hidden;
}

.sc-mention-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
}

.sc-mention-item:hover {
  background: var(--surface);
  color: var(--blue);
}

.sc-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.sc-textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.15s;
}

.sc-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.sc-textarea::placeholder {
  color: var(--text-dimmer);
}

.sc-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
}

.sc-send-btn:hover {
  background: var(--blue);
}

.sc-sending {
  opacity: 0.6;
  cursor: not-allowed;
}

.sc-mic-btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sc-mic-btn:hover {
  background: var(--surface3);
  border-color: var(--accent);
}

.sc-mic-recording {
  background: #3a0a0a;
  border-color: #c0392b;
  color: #fff;
}

.sc-mic-recording:hover {
  background: #4a1010;
}

.sc-recording-indicator {
  font-size: 13px;
  font-weight: 500;
}

.sc-transcribing {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  animation: sc-pulse 1.2s ease-in-out infinite;
}

@keyframes sc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Project panel ───────────────────────────────────────────────────────── */

.sc-project-panel {
  padding: 20px 24px;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sc-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.sc-close-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  transition: color 0.1s, border-color 0.1s;
}

.sc-close-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.sc-project-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sc-proj-desc {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.sc-proj-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sc-meta-item {
  font-size: 12px;
  color: var(--text-dim);
}

.sc-meta-label {
  color: var(--text-dimmer);
  margin-right: 2px;
}

.sc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sc-tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
}

.sc-files-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.sc-files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.sc-dl-btn {
  color: var(--blue);
  text-decoration: none;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}

.sc-dl-btn:hover {
  background: var(--surface2);
}

.sc-empty-files {
  color: var(--text-dimmer);
  font-size: 12px;
  padding: 4px 0;
}

.sc-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border2);
  font-size: 12px;
}

.sc-file-item:last-of-type {
  border-bottom: none;
}

.sc-file-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.sc-file-size {
  color: var(--text-dimmer);
  font-size: 11px;
}

.sc-upload-btn {
  display: inline-block;
  background: var(--surface2);
  border: 1px dashed var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  text-align: center;
  margin-top: 6px;
  transition: border-color 0.1s, color 0.1s;
}

.sc-upload-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.sc-delete-btn {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  margin-top: auto;
  align-self: flex-start;
  transition: background 0.1s;
}

.sc-delete-btn:hover {
  background: rgba(248, 81, 73, 0.12);
}

/* ── New project modal ───────────────────────────────────────────────────── */

.sc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.sc-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.sc-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.sc-modal-input,
.sc-modal-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  width: 100%;
  transition: border-color 0.15s;
}

.sc-modal-input:focus,
.sc-modal-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.sc-modal-textarea {
  min-height: 80px;
  resize: vertical;
}

.sc-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.sc-btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px 18px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.1s;
}

.sc-btn-primary:hover {
  background: var(--blue);
}

.sc-btn-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 7px 14px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  transition: color 0.1s;
}

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

/* ─── Emoji Picker (Bullwinkle) ────────────────────────────────────────────── */

.sc-emoji-picker {
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  position: absolute;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  margin-top: 2px;
}

.sc-emoji-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 3px 5px;
  border-radius: 4px;
  transition: background 0.1s, transform 0.1s;
  line-height: 1;
}

.sc-emoji-btn:hover {
  background: var(--border);
  transform: scale(1.2);
}

/* ─── Reactions Bar (Bullwinkle) ───────────────────────────────────────────── */

.sc-reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-left: 2px;
}

.sc-reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.1s, border-color 0.1s;
  line-height: 1.3;
}

.sc-reaction-pill:hover {
  background: var(--border);
}

.sc-reaction-mine {
  border-color: var(--blue-dim, #3b82f6);
  background: rgba(59, 130, 246, 0.1);
}

.sc-reaction-mine:hover {
  background: rgba(59, 130, 246, 0.2);
}

.sc-reaction-emoji {
  font-size: 13px;
}

.sc-reaction-count {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
}

/* ─── Thread Panel (Bullwinkle) ────────────────────────────────────────────── */

.sc-thread-panel {
  width: 340px;
  min-width: 280px;
  max-width: 400px;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

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

.sc-thread-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.sc-thread-parent {
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.sc-thread-reply-count {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.sc-thread-divider {
  height: 1px;
  background: var(--border);
}

.sc-thread-replies {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
}

.sc-thread-msg {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sc-thread-msg:last-child {
  border-bottom: none;
}

.sc-thread-input {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.sc-thread-textarea {
  flex: 1;
  min-height: 36px;
  max-height: 80px;
  resize: vertical;
}

.sc-thread-send {
  align-self: flex-end;
  padding: 6px 12px;
  font-size: 12px;
}

/* ─── Thread Button (Bullwinkle) ───────────────────────────────────────────── */

.sc-thread-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 1px 3px;
  border-radius: 3px;
  opacity: 0.7;
  transition: opacity 0.1s, background 0.1s;
  color: var(--text-dim);
}

.sc-thread-btn:hover {
  opacity: 1;
  background: var(--surface);
}

/* ─── Channel Modal (Bullwinkle) ───────────────────────────────────────────── */

.sc-modal-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  margin-top: 10px;
}

.sc-modal-slug {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: var(--font-mono, monospace);
}

/* ─── Message position: relative for picker ────────────────────────────────── */

.sc-msg {
  position: relative;
}

/* ── Phase 3: DMs, Search, Attachments ─────────────────────────────────────── */

/* Search bar */
.sc-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--surface2);
  background: var(--surface1);
  flex-shrink: 0;
}

.sc-search-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--overlay0);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
}

.sc-search-input:focus {
  outline: none;
  border-color: var(--blue);
}

.sc-search-clear {
  background: none;
  border: none;
  color: var(--subtext0);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}

.sc-search-results {
  position: absolute;
  top: 56px;
  left: 240px;
  right: 0;
  background: var(--mantle);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.sc-search-results-header {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--subtext0);
  border-bottom: 1px solid var(--surface2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sc-search-empty {
  padding: 16px;
  color: var(--subtext0);
  text-align: center;
  font-size: 13px;
}

.sc-search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--surface2, #313244);
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  align-items: baseline;
}

.sc-search-result-item:hover {
  background: var(--surface1);
}

.sc-search-ch {
  font-size: 11px;
  color: var(--blue);
  font-weight: 600;
}

.sc-search-from {
  font-size: 11px;
  color: var(--mauve);
  font-weight: 600;
}

.sc-search-ts {
  font-size: 10px;
  color: var(--overlay0);
  text-align: right;
}

.sc-search-text {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* DM items in sidebar */
.sc-dm-item {
  color: var(--teal);
}

/* DM agent picker dropdown */
.sc-dm-picker {
  background: var(--bg-alt, #1e1e2e);
  border: 1px solid var(--border-dim, #333);
  border-radius: 6px;
  margin: 0.25rem 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.sc-dm-picker-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.sc-dm-picker-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sc-dm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
}
.sc-dm-dot.sc-online {
  background: #3ba55c;
}

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

.sc-attachment {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 8px;
  background: var(--surface2);
  border-radius: 6px;
  max-width: 360px;
}

.sc-attachment-image {
  flex-direction: column;
  align-items: flex-start;
}

.sc-attachment-img {
  max-width: 240px;
  max-height: 160px;
  border-radius: 4px;
  cursor: pointer;
  object-fit: contain;
}

.sc-attachment-name a {
  color: var(--blue);
  text-decoration: none;
}

.sc-attachment-name a:hover {
  text-decoration: underline;
}

.sc-attachment-size {
  color: var(--subtext0);
  font-size: 11px;
}

/* Attach button in composer */
.sc-attach-btn {
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  transition: background 0.1s;
  user-select: none;
}

.sc-attach-btn:hover {
  background: var(--surface3, var(--overlay0));
}

.sc-attach-preview {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--subtext1);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 12px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-attach-clear {
  background: none;
  border: none;
  color: var(--overlay0);
  cursor: pointer;
  padding: 0;
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Phase 4: Notifications, Markdown, Keyboard shortcuts ──────────────────── */

/* Markdown rendering */
.sc-md { display: contents; }

.sc-md strong { font-weight: 700; color: var(--text); }
.sc-md em { font-style: italic; color: var(--subtext1); }

.sc-inline-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.88em;
  color: var(--green);
}

.sc-code-block {
  background: var(--crust);
  border: 1px solid var(--surface2);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 6px 0;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  line-height: 1.5;
  color: var(--text);
}

.sc-code-lang {
  display: block;
  font-size: 10px;
  color: var(--overlay0);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.sc-md-link {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.1s;
}

.sc-md-link:hover {
  text-decoration-color: var(--blue);
}

/* Channel switcher (Cmd+K) */
.sc-switcher-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}

.sc-switcher {
  background: var(--mantle);
  border: 1px solid var(--surface2);
  border-radius: 10px;
  width: 480px;
  max-height: 440px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  overflow: hidden;
}

.sc-switcher-header {
  padding: 10px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--subtext0);
  border-bottom: 1px solid var(--surface2);
}

.sc-switcher-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--surface2);
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

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

.sc-switcher-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: background 0.1s;
}

.sc-switcher-item:hover, .sc-switcher-item.sc-switcher-active {
  background: var(--surface1);
  border-left-color: var(--blue);
}

.sc-switcher-empty {
  padding: 16px 14px;
  color: var(--subtext0);
  font-size: 13px;
  text-align: center;
}

.sc-switcher-footer {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--overlay0);
  border-top: 1px solid var(--surface2);
  text-align: center;
}

/* Help modal */
.sc-help-modal {
  background: var(--mantle);
  border: 1px solid var(--surface2);
  border-radius: 10px;
  width: 400px;
  padding: 0 0 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.sc-help-grid {
  padding: 8px 0;
}

.sc-help-md {
  border-top: 1px solid var(--surface2);
  margin-top: 4px;
}

.sc-help-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 14px;
  font-size: 13px;
}

.sc-help-row kbd {
  background: var(--surface2);
  border: 1px solid var(--overlay0);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  min-width: 100px;
  text-align: center;
}

.sc-help-close {
  display: block;
  margin: 8px 14px 0;
  background: var(--surface2);
  border: none;
  color: var(--text);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.sc-help-close:hover {
  background: var(--surface3, var(--overlay0));
}

/* ── Phase 5: Mobile responsive, PWA, edit/delete/pin polish ───────────────── */

/* Hamburger — hidden on desktop */
.sc-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sc-hamburger:hover { background: var(--surface2); }

/* Pins panel */
.sc-pins-btn {
  background: none;
  border: none;
  color: var(--subtext0);
  font-size: 13px;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: background 0.1s;
  margin-left: auto;
}

.sc-pins-btn:hover, .sc-pins-btn.sc-pins-active {
  background: var(--surface2);
  color: var(--yellow, #f5c518);
}

.sc-pins-panel {
  background: var(--mantle);
  border-bottom: 1px solid var(--surface2);
  max-height: 220px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sc-pins-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--subtext0);
  border-bottom: 1px solid var(--surface2);
}

.sc-pins-empty {
  padding: 12px;
  color: var(--overlay0);
  font-size: 13px;
  text-align: center;
}

.sc-pin-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--surface2, #313244);
  font-size: 13px;
}

.sc-pin-from {
  color: var(--mauve);
  font-weight: 600;
  flex-shrink: 0;
}

.sc-pin-text {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-pin-remove {
  background: none;
  border: none;
  color: var(--overlay0);
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
  padding: 0 2px;
}

.sc-pin-remove:hover { color: var(--red); }

/* Edit/pin buttons (shown on msg hover) */
.sc-edit-btn, .sc-pin-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: opacity 0.1s, background 0.1s;
}

.sc-msg:hover .sc-edit-btn,
.sc-msg:hover .sc-pin-btn { opacity: 1; }

.sc-edit-btn:hover { background: var(--surface2); }
.sc-pin-btn:hover  { background: var(--surface2); }

/* Inline edit form */
.sc-edit-form {
  margin-top: 4px;
}

.sc-edit-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--blue);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  outline: none;
  box-sizing: border-box;
}

.sc-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.sc-edit-hint {
  font-size: 11px;
  color: var(--subtext0);
}

.sc-edit-save {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.sc-edit-save:hover { filter: brightness(1.1); }

/* ── Mobile responsive breakpoints ─────────────────────────────────────────── */

@media (max-width: 640px) {
  .sc-layout {
    position: relative;
    overflow: hidden;
  }

  .sc-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sc-sidebar {
    position: absolute;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 150;
    width: 260px !important;
    min-width: 260px !important;
    transition: left 0.25s ease;
    box-shadow: none;
  }

  .sc-sidebar.sc-sidebar-open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .sc-main {
    width: 100%;
  }

  .sc-search-results {
    left: 0;
  }

  .sc-switcher {
    width: 90vw;
  }

  .sc-chat-header {
    gap: 6px;
  }

  .sc-channel-title {
    font-size: 14px;
  }

  /* Composer full-width on mobile */
  .sc-composer-row {
    flex-wrap: wrap;
  }

  /* Attachment preview wraps */
  .sc-attach-preview {
    max-width: 100%;
  }

  /* Thread panel full-width on mobile */
  .sc-thread-panel {
    width: 100% !important;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
  }
}

@media (max-width: 400px) {
  .sc-msg-actions {
    flex-wrap: wrap;
    gap: 2px;
  }

  .sc-code-block {
    font-size: 11px;
  }
}

/* Focus-visible keyboard nav improvements */
.sc-channel-item:focus-visible,
.sc-switcher-item:focus-visible,
button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Smooth tab order for sidebar */
.sc-channel-item {
  tabindex: 0;
}

/* ── Agent presence dots ────────────────────────────────────────────────────── */

.sc-presence-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 6px;
  border: 1px solid rgba(255,255,255,0.15);
}

.sc-presence-online  { background: var(--green,  #a6e3a1); box-shadow: 0 0 4px var(--green, #a6e3a1); }
.sc-presence-away    { background: var(--yellow, #f9e2af); }
.sc-presence-offline { background: var(--red,    #f38ba8); opacity: 0.5; }
.sc-presence-unknown { background: var(--overlay0, #6c7086); opacity: 0.4; }

.sc-agent-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--subtext1);
  cursor: default;
}

.sc-agent-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.sc-online-count {
  font-size: 10px;
  color: var(--green, #a6e3a1);
  font-weight: 600;
  margin-left: auto;
  opacity: 0.85;
}

/* ── Typing indicator ──────────────────────────────────────────────────────── */

.sc-typing-indicator {
  padding: 2px 16px 0;
  min-height: 18px;
  font-size: 12px;
  font-style: italic;
  color: var(--subtext0, #a6adc8);
}

.sc-typing-indicator::after {
  content: '';
  display: inline-block;
  animation: sc-ellipsis 1.4s infinite;
}

@keyframes sc-ellipsis {
  0%   { content: ''; }
  33%  { content: '.'; }
  66%  { content: '..'; }
  100% { content: '...'; }
}

/* ── Thread Polish ──────────────────────────────────────────────────────────── */

/* New-reply badge on thread button */
.sc-thread-new-badge {
  background: var(--red);
  color: #fff;
  border-radius: 8px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  animation: sc-thread-pulse 1.5s ease infinite;
}

@keyframes sc-thread-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Reply count with new replies */
.sc-reply-count.sc-reply-new {
  color: var(--red);
  font-weight: 700;
}

/* Active threads sidebar */
.sc-thread-sidebar-item {
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  border-left: 2px solid var(--surface2);
  margin-bottom: 2px;
  transition: background 0.1s;
}

.sc-thread-sidebar-item:hover {
  background: var(--surface2);
  border-left-color: var(--blue);
}

.sc-thread-sidebar-item.sc-thread-has-new {
  border-left-color: var(--red);
  background: color-mix(in srgb, var(--red) 8%, transparent);
}

.sc-thread-preview {
  display: block;
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-thread-reply-count {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--subtext0);
  margin-top: 2px;
}

/* ── AI Suggest ─────────────────────────────────────────────────────────────── */
.sc-ai-loading {
    padding: 8px 12px;
    color: #888;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sc-ai-spinner {
    display: inline-block;
    animation: sc-spin 1s linear infinite;
}
@keyframes sc-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.sc-ai-preview {
    margin: 8px 0;
    padding: 10px 12px;
    background: #1e2a3a;
    border: 1px solid #2d6a9f;
    border-radius: 8px;
}
.sc-ai-preview-label {
    font-size: 11px;
    color: #6fa3d0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.sc-ai-textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    background: #111;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
}
.sc-ai-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.sc-ai-send {
    padding: 5px 14px;
    background: #2d6a9f;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.sc-ai-send:hover { background: #3a80c0; }
.sc-ai-discard {
    padding: 5px 14px;
    background: #333;
    color: #aaa;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.sc-ai-discard:hover { background: #444; color: #ccc; }
.sc-ai-error {
    padding: 8px 12px;
    color: #e05050;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Login / Identity Modal ─────────────────────────────────────────────── */

.sc-login-overlay {
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.sc-login-modal {
  max-width: 400px;
  text-align: center;
  padding: 32px 28px;
}

.sc-login-header h2 {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--text, #cdd6f4);
}

.sc-login-subtitle {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--subtext0, #a6adc8);
}

.sc-login-input {
  width: 100%;
  text-align: center;
  font-size: 18px !important;
  padding: 12px 16px !important;
  border-radius: 8px;
  margin-bottom: 12px;
}

.sc-login-error {
  color: var(--red, #f38ba8);
  font-size: 13px;
  margin-bottom: 8px;
}

.sc-login-btn {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.sc-login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sc-login-hint {
  margin: 0;
  font-size: 12px;
  color: var(--subtext0, #a6adc8);
  font-style: italic;
}

/* ── User identity display in sidebar ───────────────────────────────────── */

.sc-user-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--surface1, #45475a);
  font-size: 13px;
  color: var(--text, #cdd6f4);
}

.sc-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--mauve, #cba6f7);
  color: var(--base, #1e1e2e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
  text-transform: uppercase;
}

.sc-user-name {
  font-weight: 600;
}

.sc-user-role {
  font-size: 11px;
  color: var(--subtext0, #a6adc8);
  margin-left: auto;
}

/* ── Cmd+K semantic search overlay ───────────────────────────────────────── */

.sc-msg.sc-msg-highlight {
  background: color-mix(in srgb, var(--blue, #89b4fa) 18%, transparent);
  border-left: 3px solid var(--blue, #89b4fa);
  padding-left: 9px;
  transition: background 0.4s ease;
  animation: sc-highlight-fade 3s ease forwards;
}

@keyframes sc-highlight-fade {
  0%   { background: color-mix(in srgb, var(--blue, #89b4fa) 35%, transparent); }
  100% { background: transparent; }
}

.sc-search-overlay-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.sc-search-overlay {
  background: var(--mantle, #181825);
  border: 1px solid var(--surface1, #45475a);
  border-radius: 12px;
  width: 640px;
  max-width: 94vw;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}

.sc-search-overlay-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--surface0, #313244);
}

.sc-search-overlay-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.sc-search-overlay-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text, #cdd6f4);
  font-size: 16px;
  font-family: inherit;
}

.sc-search-overlay-input::placeholder {
  color: var(--overlay0, #6c7086);
}

.sc-search-spinner {
  font-size: 14px;
  animation: spin 1s linear infinite;
}

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

.sc-search-overlay-close {
  background: transparent;
  border: none;
  color: var(--overlay1, #7f849c);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}

.sc-search-overlay-close:hover {
  background: var(--surface0, #313244);
}

.sc-search-overlay-results {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.sc-search-overlay-empty {
  text-align: center;
  color: var(--overlay0, #6c7086);
  padding: 32px 16px;
  font-size: 14px;
}

.sc-search-result-card {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: background 0.15s;
}

.sc-search-result-card:hover {
  background: var(--surface0, #313244);
  border-color: var(--surface1, #45475a);
}

.sc-search-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.sc-search-result-channel {
  color: var(--mauve, #cba6f7);
  font-weight: 600;
}

.sc-search-result-sender {
  color: var(--green, #a6e3a1);
}

.sc-search-result-time {
  color: var(--overlay0, #6c7086);
  margin-left: auto;
}

.sc-search-result-preview {
  color: var(--text, #cdd6f4);
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.sc-search-overlay-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--surface0, #313244);
  font-size: 11px;
  color: var(--overlay0, #6c7086);
  text-align: center;
}

/* ── Inline composer login bar (replaces full-screen gate) ── */
.sc-composer-login-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--sc-surface, #1e2130);
  border-top: 1px solid var(--sc-border, #2d3149);
}

.sc-composer-login-label {
  font-size: 0.85rem;
  color: var(--sc-muted, #8892b0);
  white-space: nowrap;
}

.sc-composer-login-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--sc-input-bg, #252840);
  border: 1px solid var(--sc-border, #2d3149);
  border-radius: 6px;
  color: var(--sc-text, #cdd6f4);
  font-size: 0.9rem;
  outline: none;
  min-width: 0;
}

.sc-composer-login-input:focus {
  border-color: var(--sc-accent, #7c83fd);
}

.sc-composer-login-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.sc-composer-login-error {
  font-size: 0.8rem;
  color: var(--sc-error, #f38ba8);
  white-space: nowrap;
}
