/* ===== SUBCHANNEL TREE ===== */
.ch-tree { display: flex; flex-direction: column; }

.ch-node {
  display: flex;
  flex-direction: column;
}

/* Indentation per depth */
.ch-item[data-depth="1"] { padding-left: 28px; }
.ch-item[data-depth="2"] { padding-left: 42px; }
.ch-item[data-depth="3"] { padding-left: 56px; }

/* Tree connector lines */
.ch-item[data-depth="1"]::before,
.ch-item[data-depth="2"]::before,
.ch-item[data-depth="3"]::before {
  content: '';
  position: absolute;
  left: calc(var(--depth-left, 14px));
  top: 50%; width: 8px; height: 1px;
  background: var(--sidebar-border);
}
.ch-item[data-depth="1"] { --depth-left: 18px; }
.ch-item[data-depth="2"] { --depth-left: 32px; }
.ch-item[data-depth="3"] { --depth-left: 46px; }

/* Expand/collapse toggle */
.ch-expand {
  width: 14px; height: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--sidebar-text);
  opacity: 0.5; cursor: pointer;
  transition: all 0.15s; border-radius: 3px;
  margin-right: -2px;
  font-family: 'DM Mono', monospace;
}
.ch-expand:hover { opacity: 1; background: var(--sidebar-hover-bg); }
.ch-expand.open { opacity: 0.8; }

/* Subchannel children wrapper */
.ch-children {
  display: flex; flex-direction: column;
  overflow: hidden;
}
.ch-children.collapsed { display: none; }

/* Context menu */
.ctx-menu {
  position: fixed;
  background: var(--paper2);
  border: 1px solid var(--rule);
  border-radius: 9px;
  padding: 4px;
  z-index: 600;
  min-width: 180px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.3);
  animation: ctxIn 0.1s ease;
}
@keyframes ctxIn { from { opacity:0; transform:scale(0.95); } to { opacity:1; transform:scale(1); } }
.ctx-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 12px;
  border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--ink2);
  transition: all 0.1s;
}
.ctx-item:hover { background: var(--paper3); color: var(--ink); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: rgba(217,79,61,0.1); }
.ctx-item .ctx-icon { font-size: 14px; opacity: 0.7; width: 16px; text-align: center; }
.ctx-divider { height: 1px; background: var(--rule); margin: 3px 8px; }

/* ===== REPLY SYSTEM ===== */

/* Quoted reply preview inside a message */
.msg-reply-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 10px;
  margin-bottom: 5px;
  border-left: 2px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--paper2);
  cursor: pointer;
  transition: background 0.12s;
  max-width: 100%;
}
.msg-reply-preview:hover { background: var(--paper3); }
.reply-av {
  width: 16px; height: 16px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 7px; font-weight: 700; color: white;
  flex-shrink: 0; font-family: 'DM Serif Display', serif;
}
.reply-author {
  font-size: 11.5px; font-weight: 700;
  color: var(--accent2); flex-shrink: 0;
}
.reply-text {
  font-size: 11.5px; color: var(--ink3);
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1; min-width: 0;
}

/* Reply banner above the input */
.reply-banner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 5px;
  background: var(--paper2);
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--ink3);
}
.reply-banner.visible { display: flex; }
.reply-banner-line {
  width: 2px; height: 28px; flex-shrink: 0;
  border-radius: 2px; background: var(--accent);
}
.reply-banner-body { flex: 1; min-width: 0; }
.reply-banner-who {
  font-size: 11px; font-weight: 700;
  color: var(--accent2); margin-bottom: 1px;
}
.reply-banner-snippet {
  font-size: 11px; color: var(--ink3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reply-cancel-btn {
  background: none; border: none;
  color: var(--ink4); cursor: pointer;
  font-size: 16px; line-height: 1;
  padding: 4px; border-radius: 4px;
  transition: all 0.12s; flex-shrink: 0;
}
.reply-cancel-btn:hover { color: var(--ink); background: var(--paper3); }
.msg-row { position: relative; }
.msg-actions {
  display: none;
  position: absolute;
  top: -2px; right: 8px;
  background: var(--paper2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 3px 4px;
  gap: 2px;
  align-items: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  z-index: 10;
}
.msg-row:hover .msg-actions { display: flex; }
.ma-btn {
  width: 28px; height: 28px;
  background: none; border: none;
  border-radius: 6px; cursor: pointer;
  font-size: 14px; display: flex;
  align-items: center; justify-content: center;
  color: var(--ink3); transition: all 0.13s;
}
.ma-btn:hover { background: var(--paper3); color: var(--ink); }

/* ===== EMOJI REACTIONS ON MESSAGES ===== */
.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 2px 6px;
  background: var(--paper2);
  border: 1.5px solid var(--rule);
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.14s;
  user-select: none;
}
.reaction-pill:hover { border-color: var(--accent); background: var(--paper3); }
.reaction-pill.mine { border-color: var(--accent); background: rgba(124,106,247,0.12); }
.reaction-count { font-size: 11px; color: var(--ink3); font-family: 'DM Mono', monospace; font-weight: 500; }

/* ===== GIF IN MESSAGE ===== */
.msg-gif {
  margin-top: 6px;
  border-radius: 8px;
  overflow: hidden;
  display: inline-block;
  max-width: 280px;
  border: 1px solid var(--rule);
}
.msg-gif img { display: block; width: 100%; max-width: 280px; border-radius: 8px; }

/* ===== EMOJI PICKER POPUP ===== */
.emoji-popup {
  position: fixed;
  background: var(--paper2);
  border: 1.5px solid var(--rule);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  z-index: 500;
  width: 260px;
}
.emoji-popup-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.ep-btn {
  width: 28px; height: 28px;
  background: none; border: none;
  border-radius: 5px; cursor: pointer;
  font-size: 16px; display: flex;
  align-items: center; justify-content: center;
  transition: background 0.1s;
}
.ep-btn:hover { background: var(--paper3); }
.emoji-popup-label {
  font-size: 10px; font-family: 'DM Mono', monospace;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink4); margin: 6px 0 4px;
}

/* ===== GIF PICKER POPUP ===== */
.gif-popup {
  position: fixed;
  background: var(--paper2);
  border: 1.5px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.32);
  z-index: 500;
  width: 340px;
  max-height: 440px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.gif-popup-head {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.gif-popup-head h4 {
  font-size: 12px; font-weight: 700;
  color: var(--ink); margin-bottom: 8px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.gif-search-row {
  display: flex; gap: 6px; align-items: center;
}
.gif-search-input {
  flex: 1;
  background: var(--paper3);
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
}
.gif-search-input:focus { border-color: var(--accent); }
.gif-search-input::placeholder { color: var(--ink4); }
.gif-search-btn {
  padding: 7px 12px;
  background: var(--accent); border: none;
  border-radius: 8px; color: white;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: opacity 0.15s;
}
.gif-search-btn:hover { opacity: 0.85; }

.gif-grid {
  flex: 1; overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  min-height: 0;
}
.gif-grid::-webkit-scrollbar { width: 4px; }
.gif-grid::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

.gif-item {
  border-radius: 8px; overflow: hidden;
  cursor: pointer; position: relative;
  aspect-ratio: 16/10;
  background: var(--paper3);
  border: 2px solid transparent;
  transition: all 0.15s;
}
.gif-item:hover { border-color: var(--accent); transform: scale(1.02); }
.gif-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 24px; color: var(--ink4);
  font-size: 12px; font-family: 'DM Mono', monospace;
  grid-column: 1/-1;
}
.gif-trending-label {
  font-size: 10px; font-family: 'DM Mono', monospace;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink4); padding: 4px 2px 6px;
  grid-column: 1/-1;
}
.gif-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--rule);
  font-size: 10px; color: var(--ink4);
  font-family: 'DM Mono', monospace;
  text-align: right; flex-shrink: 0;
}

/* Input GIF btn */
.gif-input-btn {
  background: none; border: none;
  color: var(--ink4); cursor: pointer;
  font-size: 12px; font-weight: 700;
  font-family: 'DM Mono', monospace;
  padding: 4px 8px; border-radius: 5px;
  border: 1px solid var(--rule);
  transition: all 0.14s; line-height: 1;
  flex-shrink: 0; margin-bottom: 2px;
  letter-spacing: 0.04em;
}
.gif-input-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--paper2); }
