:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface2: #1c1c27;
  --surface3: #252535;
  --border: #2a2a3e;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-dim: rgba(139, 92, 246, 0.12);
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --success: #34d399;
  --danger: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

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

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--surface3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface2); border-color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.1); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ── Inputs ── */
.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text3); }

.input-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.input-group label { font-size: 13px; font-weight: 500; color: var(--text2); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── Avatar ── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }

/* ── Navbar ── */
.navbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar-brand span { color: var(--accent); }

.navbar-spacer { flex: 1; }

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text2);
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  max-width: 320px;
  animation: slideIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.success::before { content: '✓'; color: var(--success); font-weight: 700; }
.toast.error::before { content: '✕'; color: var(--danger); font-weight: 700; }

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

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  animation: fadeUp 0.2s ease;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

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

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

/* ── Auth Page ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.auth-logo h1 span { color: var(--accent); }
.auth-logo p { font-size: 13px; color: var(--text3); margin-top: 4px; }

.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text3);
  transition: all 0.15s;
  user-select: none;
}
.auth-tab.active { background: var(--surface3); color: var(--text); }

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
  display: none;
}

/* ── Dashboard ── */
.dashboard-layout {
  min-height: calc(100vh - 58px);
  padding: 28px;
  max-width: 1100px;
  margin: 0 auto;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.dashboard-title { font-size: 20px; font-weight: 700; }
.dashboard-subtitle { font-size: 14px; color: var(--text3); margin-top: 2px; }

.dashboard-actions { display: flex; gap: 8px; }

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.room-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.room-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.room-card-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.room-card-desc {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 16px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.room-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text3);
}

.room-card-code {
  font-family: monospace;
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text2);
  margin-left: auto;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ── Room Page ── */
.room-layout {
  height: calc(100vh - 58px);
  display: flex;
  overflow: hidden;
}

/* Sidebar */
.room-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section {
  border-bottom: 1px solid var(--border);
}

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

.members-list {
  padding: 4px 8px 12px;
  max-height: 200px;
  overflow-y: auto;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

.member-name { font-size: 13px; color: var(--text2); }
.member-role {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

/* Tasks */
.tasks-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tasks-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  group: true;
}
.task-item:hover { background: var(--surface2); }

.task-check {
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.task-check:hover { border-color: var(--accent); }
.task-check.done { background: var(--accent); border-color: var(--accent); }
.task-check.done::after { content: '✓'; font-size: 10px; color: #fff; font-weight: 700; }

.task-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  cursor: pointer;
}
.task-text.done { text-decoration: line-through; color: var(--text3); }

.task-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  border-radius: 4px;
  transition: all 0.15s;
}
.task-item:hover .task-delete { opacity: 1; }
.task-delete:hover { color: var(--danger); background: rgba(248, 113, 113, 0.1); }

.task-add-form {
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}
.task-add-form .input { padding: 7px 10px; font-size: 13px; }

/* Chat */
.room-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-group {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  align-items: flex-start;
}

/* Message action buttons row (reply + emoji) */
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}
.msg-group:hover .msg-actions { opacity: 1; }

/* Shared pill style for reply-btn and emoji-btn */
.reply-btn,
.emoji-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text3);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.reply-btn:hover { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }
.emoji-btn:hover { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }

/* Emoji reaction pills below message */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.reaction-pill:hover { background: var(--surface3); }
.reaction-pill.mine { border-color: var(--accent); background: var(--accent-dim); }
.reaction-pill .pill-count { font-size: 11px; font-weight: 600; color: var(--text2); }

/* Floating emoji picker */
.emoji-picker {
  position: fixed;
  z-index: 9999;
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.emoji-picker.hidden { display: none; }
.emoji-option {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
  transition: transform 0.1s, background 0.1s;
}
.emoji-option:hover { background: var(--surface3); transform: scale(1.25); }

/* Quoted reply inside a message */
.msg-reply {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 5px;
  cursor: pointer;
  transition: background 0.12s;
}
.msg-reply:hover { background: var(--surface3); }
.msg-reply-user { font-size: 11px; font-weight: 700; color: var(--accent); }
.msg-reply-text {
  font-size: 12px;
  color: var(--text3);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Flash highlight when jumping to a replied message */
@keyframes msgHighlight {
  0%   { background: var(--accent-dim); }
  100% { background: transparent; }
}
.msg-highlight { animation: msgHighlight 1.2s ease; border-radius: var(--radius-sm); }

.msg-body { flex: 1; min-width: 0; }

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

.msg-username { font-size: 14px; font-weight: 600; }
.msg-time { font-size: 11px; color: var(--text3); }

.msg-content {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.55;
  word-break: break-word;
}

.chat-input-area {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Reply bar — appears above input when replying */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.reply-bar.hidden { display: none; }
.reply-bar-accent { width: 3px; align-self: stretch; background: var(--accent); border-radius: 2px; flex-shrink: 0; }
.reply-bar-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reply-bar-user { font-size: 11px; font-weight: 700; color: var(--accent); }
.reply-bar-text { font-size: 12px; color: var(--text3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reply-bar-cancel { background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px 6px; border-radius: 4px; font-size: 14px; flex-shrink: 0; transition: color 0.1s; }
.reply-bar-cancel:hover { color: var(--danger); }

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 16px;
  position: relative;
}

/* Chat @mention dropdown */
.chat-mention-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 200px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.chat-mention-dropdown.hidden { display: none; }

.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text3); }

/* Room navbar extras */
.room-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.room-name-nav {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invite-badge {
  font-family: monospace;
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
}
.invite-badge:hover { border-color: var(--accent); }

.member-count {
  font-size: 13px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text3);
  font-size: 14px;
  gap: 8px;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile Tab Bar (room page, desktop hidden) ── */
.mobile-tab-bar { display: none; }

/* ── Responsive ── */
@media (max-width: 768px) {
  /* Navbar */
  .navbar { padding: 0 12px; gap: 8px; }
  .invite-badge { display: none; }
  .member-count { display: none; }
  .invite-text { display: none; }

  /* Dashboard */
  .dashboard-layout { padding: 16px; }
  .dashboard-header { flex-direction: column; align-items: flex-start; }
  .dashboard-actions { width: 100%; }
  .dashboard-actions .btn { flex: 1; justify-content: center; }
  .rooms-grid { grid-template-columns: 1fr; }

  /* Room layout: one panel at a time */
  .room-layout {
    flex-direction: column;
    height: calc(100vh - 58px);
    overflow: hidden;
  }
  .room-sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: none;
    flex: 1;
    overflow: hidden;
  }
  .room-layout.show-sidebar .room-sidebar { display: flex; }
  .room-layout.show-sidebar .room-chat   { display: none; }

  /* Bottom tab bar */
  .mobile-tab-bar {
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    height: 50px;
  }
  .mobile-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text3);
    background: none;
    border: none;
    border-top: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    padding: 0;
  }
  .mobile-tab.active { color: var(--accent); border-top-color: var(--accent); }

  /* Modals */
  .modal { margin: 16px; width: calc(100% - 32px); }
  #task-detail-overlay { align-items: flex-end; padding: 0; }
  .task-detail-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  /* Task detail — stack columns on mobile */
  .task-detail-body { flex-direction: column; overflow-y: auto; }
  .td-left-col { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; padding: 20px 16px; }
  .td-right-col { min-height: 320px; }
  .td-comments-header { padding: 14px 16px 12px; }
  .td-comments-scroll { padding: 8px 16px 12px; }
  .td-comment-form { padding: 12px 16px; }
  .td-mention-dropdown { left: 16px; }
  .td-attachment-del { opacity: 0.7; }
  .td-comment-del { opacity: 0.7; }

  /* Auth */
  .auth-card { padding: 24px 20px; }

  /* Task delete always visible on touch */
  .task-delete { opacity: 0.6; }
  /* Keep actions visible on touch (no hover) */
  .msg-actions { opacity: 0.7; }

  /* Toast: full width, above tab bar on room page */
  #toast-container { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .toast { max-width: 100%; }
  body.room-page #toast-container { bottom: 66px; }
}

@media (max-width: 480px) {
  .navbar-brand { font-size: 16px; }
  .room-name-nav { font-size: 13px; }
  .dashboard-title { font-size: 18px; }
  .auth-logo h1 { font-size: 22px; }
  .chat-input-area { padding: 8px 10px; }
  .task-detail-body { padding: 16px; gap: 20px; }
}

/* ── Task Detail Modal ── */
.task-item { cursor: pointer; }

.task-detail-modal {
  max-width: 780px;
  width: calc(100vw - 40px);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.task-detail-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.task-detail-title-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.task-detail-title-row .task-check {
  width: 22px;
  height: 22px;
  min-width: 22px;
  margin-top: 3px;
}

.task-detail-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  word-break: break-word;
  letter-spacing: -0.2px;
}

/* Two-column body */
.task-detail-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left column — Notes + Attachments */
.td-left-col {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 20px;
  gap: 28px;
}

/* Right column — Comments */
.td-right-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.td-comments-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.td-comments-badge {
  font-size: 11px;
  color: var(--text3);
  background: var(--surface3);
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
}

.td-comments-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 24px 16px;
}

.td-section { display: flex; flex-direction: column; gap: 10px; }

.td-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
}

.td-section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.td-section-footer { display: flex; justify-content: flex-end; }

.td-notes-area {
  resize: vertical;
  min-height: 110px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.65;
  background: var(--surface3);
  border-color: transparent;
}
.td-notes-area:focus { border-color: var(--accent); }

.td-attach-btn { cursor: pointer; flex-shrink: 0; }

.td-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 6px;
  transition: border-color 0.12s;
}
.td-attachment:hover { border-color: var(--accent); }

.td-attachment-icon { font-size: 18px; flex-shrink: 0; }

.td-attachment-name {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}
.td-attachment-name:hover { color: var(--accent); text-decoration: underline; }

.td-attachment-size { color: var(--text3); font-size: 11px; flex-shrink: 0; white-space: nowrap; }

.td-attachment-del {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0;
  transition: all 0.1s;
}
.td-attachment:hover .td-attachment-del { opacity: 1; }
.td-attachment-del:hover { color: var(--danger); background: rgba(248, 113, 113, 0.1); }

.td-comment {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.td-comment:last-child { border-bottom: none; }

.td-comment-body { flex: 1; min-width: 0; }

.td-comment-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.td-comment-username { font-size: 13px; font-weight: 600; color: var(--text); }

.td-comment-time { font-size: 11px; color: var(--text3); }

.td-comment-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.55;
  word-break: break-word;
}

.mention { color: var(--accent); font-weight: 500; }

.td-comment-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
  align-self: flex-start;
  flex-shrink: 0;
  opacity: 0;
  transition: all 0.1s;
}
.td-comment:hover .td-comment-del { opacity: 1; }
.td-comment-del:hover { color: var(--danger); background: rgba(248, 113, 113, 0.1); }

/* Comment input — pinned at bottom of right column */
.td-comment-form {
  position: relative;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.td-mention-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 200px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.td-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.td-mention-item:hover, .td-mention-item.active { background: var(--surface3); }

.td-empty { color: var(--text3); font-size: 13px; padding: 8px 0; }

/* ── Unread badge (dashboard) ── */
.room-card-name { display: flex; align-items: center; gap: 8px; }
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Pinned message bar ── */
.pinned-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.pinned-bar.hidden { display: none; }
.pinned-icon { flex-shrink: 0; }
.pinned-user { font-weight: 600; color: var(--accent); white-space: nowrap; }
.pinned-text { flex: 1; min-width: 0; color: var(--text2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pinned-jump { background: none; border: none; color: var(--accent); cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 13px; transition: background 0.1s; flex-shrink: 0; }
.pinned-jump:hover { background: var(--accent-dim); }

/* ── Typing indicator ── */
.typing-indicator {
  padding: 4px 16px 2px;
  font-size: 12px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}
.typing-indicator.hidden { display: none; }
.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.typing-dots span {
  width: 5px; height: 5px;
  background: var(--text3);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* ── Message: edited / deleted states ── */
.msg-edited { font-size: 10px; color: var(--text3); font-style: italic; margin-left: 4px; }
.msg-deleted { color: var(--text3); font-style: italic; font-size: 13px; }
.msg-group-deleted { opacity: 0.5; padding: 2px 0 2px 40px; }
.msg-deleted-placeholder { font-size: 12px; color: var(--text3); font-style: italic; padding: 4px 0; }

/* Message edit inline area */
.msg-edit-area { display: flex; flex-direction: column; gap: 6px; }
.msg-edit-input { resize: none; font-size: 14px; width: 100%; }
.msg-edit-btns { display: flex; gap: 6px; }

/* Message action buttons: edit / delete / pin */
.edit-btn, .delete-btn, .pin-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text3);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.edit-btn:hover { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }
.delete-btn:hover { color: var(--danger); background: rgba(248,113,113,0.1); border-color: var(--danger); }
.pin-btn:hover { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }

/* ── Chat attach button ── */
.chat-attach-btn {
  padding: 0 10px;
  color: var(--text3);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.1s;
}
.chat-attach-btn:hover { color: var(--text); }

/* ── Inline images / files in chat ── */
.msg-image-wrap { display: block; margin-top: 6px; }
.msg-image {
  max-width: 320px;
  max-height: 240px;
  border-radius: var(--radius-sm);
  display: block;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}
.msg-image:hover { opacity: 0.9; }
.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.1s;
}
.msg-file:hover { background: var(--surface3); }
.msg-file-icon { font-size: 18px; }
.msg-file-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Search modal ── */
.search-modal {
  width: min(560px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.search-modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.search-input { flex: 1; font-size: 15px; }
.search-results {
  overflow-y: auto;
  flex: 1;
}
.search-hint { padding: 24px; text-align: center; color: var(--text3); font-size: 13px; }
.search-result {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.search-result:hover { background: var(--surface2); }
.search-result-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.search-result-user { font-size: 12px; font-weight: 700; }
.search-result-time { font-size: 11px; color: var(--text3); }
.search-result-text { font-size: 13px; color: var(--text2); white-space: pre-wrap; word-break: break-word; }

/* ── Task meta (assignee + due date in sidebar) ── */
.task-item { display: flex; align-items: center; gap: 8px; }
.task-meta { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }
.task-assignee { display: flex; align-items: center; }
.task-due { font-size: 10px; color: var(--text3); white-space: nowrap; }
.task-due.overdue { color: var(--danger); font-weight: 600; }

/* ── Task detail: assignment + due date row ── */
.td-meta-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.td-meta-field { display: flex; flex-direction: column; gap: 4px; position: relative; }
.td-meta-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); font-weight: 600; }
.td-assignee-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  min-width: 120px;
  transition: background 0.1s;
}
.td-assignee-btn:hover { background: var(--surface3); }
.td-assignee-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 180px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.td-assignee-dropdown.hidden { display: none; }
.td-due-input { font-size: 13px; padding: 4px 8px; min-width: 130px; }

/* ── Light theme ── */
[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --surface3: #e2e8f0;
  --border: #cbd5e1;
  --text: #0f172a;
  --text2: #334155;
  --text3: #64748b;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-dim: rgba(124,58,237,0.1);
}

/* ── Online presence dot ── */
.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--surface3);
  border: 2px solid var(--surface);
  position: absolute;
  bottom: 0; right: 0;
  transition: background 0.2s;
}
.online-dot.active { background: var(--success); }

/* ── Notification dropdown ── */
.notif-dropdown {
  position: fixed;
  top: 56px; right: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  min-width: 200px;
}
.notif-dropdown.hidden { display: none; }
.notif-dropdown-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); margin-bottom: 10px; font-weight: 600; }
.notif-option { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; cursor: pointer; }
.notif-option input { accent-color: var(--accent); }

/* ── Compose emoji picker ── */
.compose-emoji-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  width: 220px;
}
.compose-emoji-picker.hidden { display: none; }
.compose-emoji-btn {
  background: none; border: none; font-size: 18px; cursor: pointer;
  padding: 4px; border-radius: 4px; line-height: 1;
  transition: background 0.1s, transform 0.1s;
}
.compose-emoji-btn:hover { background: var(--surface3); transform: scale(1.2); }

/* ── Markdown rendering ── */
.msg-code-block {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12.5px;
  overflow-x: auto;
  margin: 6px 0;
  white-space: pre;
}
.msg-inline-code {
  background: var(--surface3);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12.5px;
}

/* ── Link previews ── */
.link-preview {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  max-width: 380px;
  transition: background 0.1s;
}
.link-preview:hover { background: var(--surface3); }
.link-preview-img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.link-preview-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.link-preview-title { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.link-preview-desc { font-size: 12px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-preview-url { font-size: 11px; color: var(--text3); }

/* ── Polls ── */
.poll-card {
  margin-top: 8px;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 340px;
}
.poll-question { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.poll-options { display: flex; flex-direction: column; gap: 6px; }
.poll-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.1s;
}
.poll-option:hover { border-color: var(--accent); }
.poll-option.voted { border-color: var(--accent); background: var(--accent-dim); }
.poll-option-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent-dim);
  transition: width 0.4s ease;
  z-index: 0;
}
.poll-option-text { flex: 1; font-size: 13px; position: relative; z-index: 1; }
.poll-option-pct { font-size: 11px; color: var(--text3); position: relative; z-index: 1; }
.poll-option-count { font-size: 11px; color: var(--text3); position: relative; z-index: 1; min-width: 20px; text-align: right; }
.poll-footer { font-size: 11px; color: var(--text3); margin-top: 8px; }

/* ── Kanban board ── */
.kanban-board {
  display: flex;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  padding: 4px 0 8px;
}
.kanban-board.hidden { display: none; }
.kanban-col {
  flex: 1;
  min-width: 120px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.kanban-col-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  padding: 8px 8px 4px;
}
.kanban-col-body { flex: 1; overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  transition: background 0.1s;
}
.kanban-card:hover { background: var(--surface3); }
.kanban-card-title { font-size: 12px; font-weight: 500; line-height: 1.4; }
.kanban-card-status-btns { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.kanban-move-btn {
  font-size: 10px; padding: 2px 5px;
  background: none; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; color: var(--text3);
  transition: background 0.1s, color 0.1s;
}
.kanban-move-btn:hover { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ── DM page ── */
.dm-layout {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}
.dm-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dm-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.dm-conv-list { flex: 1; overflow-y: auto; }
.dm-conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.dm-conv-item:hover, .dm-conv-item.active { background: var(--surface2); }
.dm-conv-info { flex: 1; min-width: 0; }
.dm-conv-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dm-conv-last { font-size: 12px; color: var(--text3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-top: 2px; }
.dm-chat { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.dm-empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text3); }
.dm-chat-inner { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.dm-chat-inner.hidden { display: none; }
.dm-chat-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.dm-messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.dm-msg { display: flex; align-items: flex-end; gap: 8px; }
.dm-msg.own { flex-direction: row-reverse; }
.dm-msg-bubble { max-width: 65%; }
.dm-msg.own .dm-msg-bubble { align-items: flex-end; }
.dm-msg-text { padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.5; background: var(--surface2); color: var(--text); word-break: break-word; }
.dm-msg.own .dm-msg-text { background: var(--accent); color: #fff; }
.dm-msg-time { font-size: 10px; color: var(--text3); margin-top: 3px; padding: 0 4px; }
.dm-input-area { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; }
