/* ===== 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: 10px; 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: 9500;
  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: 15px; color: var(--ink3);
  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: 16px; opacity: 0.7; width: 16px; text-align: center; }
.ctx-divider { height: 1px; background: var(--rule); margin: 3px 8px; }

/* channel name color swatches */
.ctx-item[data-action="set-color"] { flex-wrap: wrap; gap: 6px; cursor: default; }
.ctx-item[data-action="set-color"]:hover { background: none; color: var(--ink3); }
.ctx-color-swatches {
  display: flex; gap: 5px; flex-wrap: wrap;
  padding: 4px 0 2px; width: 110px;
}
.ctx-swatch {
  width: 18px; height: 18px; border-radius: 50%;
  cursor: pointer; flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.12s;
  outline-offset: 2px;
}
.ctx-swatch:hover { transform: scale(1.25); box-shadow: 0 0 0 2px var(--accent2); }

/* ===== 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: 8px; 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: 14px;
  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: 13px; font-weight: 700;
  color: var(--accent2); margin-bottom: 1px;
}
.reply-banner-snippet {
  font-size: 13px; color: var(--ink3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reply-cancel-btn {
  background: none; border: none;
  color: var(--ink3); cursor: pointer;
  font-size: 18px; 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: 16px; display: flex;
  align-items: center; justify-content: center;
  color: var(--ink3); transition: all 0.13s;
}
.ma-btn:hover { background: var(--paper3); color: var(--ink); }

/* individual button colors */
.ma-btn[title="Reply"]    { color: #378ADD; }
.ma-btn[title="Reply"]:hover { color: #185FA5; background: rgba(55,138,221,0.1); }

.ma-btn[title="React"]    { color: #EF9F27; }
.ma-btn[title="React"]:hover { color: #BA7517; background: rgba(239,159,39,0.1); }

.ma-btn[title="GIF"]      { color: #7F77DD; }
.ma-btn[title="GIF"]:hover { color: #534AB7; background: rgba(127,119,221,0.1); }

.ma-btn[title="Edit"]     { color: var(--ink3); }
.ma-btn[title="Edit"]:hover { color: var(--ink); background: var(--paper3); }

.ma-btn-del               { color: var(--ink3); }
.ma-btn-del:hover         { color: var(--red) !important; background: rgba(226,75,74,0.1) !important; }

/* ===== 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: 15px;
  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: 13px; 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: 18px; display: flex;
  align-items: center; justify-content: center;
  transition: background 0.1s;
}
.ep-btn:hover { background: var(--paper3); }
.emoji-popup-label {
  font-size: 12px; font-family: 'DM Mono', monospace;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink3); 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: 14px; 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: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
}
.gif-search-input:focus { border-color: var(--accent); }
.gif-search-input::placeholder { color: var(--ink3); }
.gif-search-btn {
  padding: 7px 12px;
  background: var(--accent); border: none;
  border-radius: 8px; color: white;
  font-size: 15px; 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;
  column-count: 2;
  column-gap: 6px;
  min-height: 0;
}
.gif-grid .gif-item {
  margin-bottom: 6px;
  display: inline-block;
  width: 100%;
}
.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;
  background: var(--paper3);
  border: 2px solid transparent;
  transition: all 0.15s;
  break-inside: avoid;
}
.gif-item:hover { border-color: var(--accent); transform: scale(1.02); }
.gif-item img { width: 100%; height: auto; display: block; }
.gif-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 24px; color: var(--ink3);
  font-size: 14px; font-family: 'DM Mono', monospace;
  grid-column: 1/-1;
}
.gif-trending-label {
  font-size: 12px; font-family: 'DM Mono', monospace;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink3); padding: 4px 2px 6px;
  grid-column: 1/-1;
}
.gif-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--rule);
  text-align: center;
  flex-shrink: 0;
}

/* Input GIF btn */
.gif-input-btn {
  background: var(--paper2); border: none;
  color: var(--ink3); cursor: pointer;
  font-size: 11px; font-weight: 800;
  font-family: 'DM Mono', monospace;
  padding: 0 7px; border-radius: 5px;
  transition: all 0.14s; line-height: 1;
  flex-shrink: 0; margin-bottom: 2px;
  letter-spacing: 0.05em;
  height: 30px; display: flex; align-items: center;
}
.gif-input-btn:hover { color: var(--accent); background: var(--paper3); }

/* ── Image messages ──────────────────────────────────────────────────────────*/
.msg-image {
  margin-top: 4px;
  max-width: 320px;
}
.msg-image img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.msg-image img:hover { opacity: 0.92; }

/* ── Image input preview bar ─────────────────────────────────────────────────*/
.img-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 2px;
  flex-wrap: wrap;
}
.img-preview-wrap {
  position: relative;
  display: inline-flex;
}
.img-preview-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 7px;
  border: 1.5px solid var(--rule);
}
.img-preview-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--red);
  border: none; color: white;
  font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ── Image upload button ─────────────────────────────────────────────────────*/
.img-input-btn {
  background: var(--paper2); border: none;
  color: var(--ink3); cursor: pointer;
  padding: 0; border-radius: 5px;
  transition: all 0.14s; line-height: 1;
  flex-shrink: 0; margin-bottom: 2px;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
}
.img-input-btn:hover { color: var(--accent); background: var(--paper3); }

/* ── Grabby button ───────────────────────────────────────────────────────────*/
.grabby-btn { display: none; } /* legacy — hidden, replaced by grabby-standalone */

.grabby-standalone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--paper2);
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--ink3);
  transition: all 0.15s;
  flex-shrink: 0;
  min-width: 60px;
  min-height: 52px;
  user-select: none;
}
.grabby-standalone:hover {
  background: var(--paper3);
  border-color: var(--accent2);
  color: var(--accent2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.grabby-standalone:active { transform: scale(0.96); }
.grabby-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: 'DM Mono', monospace;
  opacity: 0.7;
}

/* ── Grabby context menu ─────────────────────────────────────────────────────*/
.grabby-menu {
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  padding: 6px 0;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.grabby-menu-title {
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink3);
  padding: 4px 14px 8px;
}
.grabby-menu-item {
  font-size: 13px;
  color: var(--ink3);
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.grabby-menu-item:hover { background: var(--paper2); }
.grabby-menu-item.selected { color: var(--accent2); }
.grabby-menu-sep {
  height: 1px;
  background: var(--rule);
  margin: 6px 0;
}
.grabby-menu-hint {
  font-size: 11px;
  color: var(--ink3);
  padding: 4px 14px;
}

/* ── Image lightbox ──────────────────────────────────────────────────────────*/
.img-lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
.img-lightbox.show { display: flex; }
.img-lightbox img {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}
.img-lightbox-close {
  position: fixed;
  top: 16px; right: 20px;
  background: rgba(255,255,255,0.1);
  border: none; color: white;
  font-size: 20px; width: 36px; height: 36px;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.img-lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ── Edit / delete message ───────────────────────────────────────────────────*/
.msg-edited {
  font-size: 10px;
  color: var(--ink3);
  font-style: italic;
  margin-left: 5px;
  opacity: 0.7;
}

.msg-edit-shell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}
.msg-edit-input {
  width: 100%;
  background: var(--paper2);
  border: 1.5px solid var(--accent);
  border-radius: 7px;
  padding: 7px 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
  resize: none;
  line-height: 1.5;
  min-height: 36px;
  box-sizing: border-box;
}
.msg-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-edit-hint {
  font-size: 11px;
  color: var(--ink3);
  flex: 1;
}
.msg-edit-btn {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid var(--rule);
  background: var(--paper2);
  color: var(--ink3);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.13s;
}
.msg-edit-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.msg-edit-cancel:hover { background: var(--paper3); color: var(--ink); border-color: var(--rule); }

/* ── Channel icon picker ─────────────────────────────────────────────────────*/
.ctx-item[data-action="set-icon"] { flex-wrap: wrap; cursor: default; gap: 6px; }
.ctx-item[data-action="set-icon"]:hover { background: none; color: var(--ink3); }
.ctx-icon-row {
  width: 100%; padding: 4px 0 2px;
}
.ch-icon-grid {
  display: flex; flex-wrap: wrap; gap: 3px;
  max-height: 110px; overflow-y: auto;
  padding: 2px;
}
.ch-icon-swatch {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px; cursor: pointer; font-size: 16px;
  transition: background 0.1s, transform 0.1s;
  border: 1.5px solid transparent;
}
.ch-icon-swatch--hash {
  font-size: 13px; font-weight: 700;
  color: var(--ink3); opacity: 0.8;
}
.ch-icon-swatch:hover { background: var(--paper3); transform: scale(1.15); }
.ch-icon-swatch--active { border-color: var(--accent2); background: var(--paper3); }

/* modal icon/color pickers */
.modal-picker-row {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 10px;
}
.modal-picker-label {
  font-size: 12px; color: var(--ink3); padding-top: 6px;
  min-width: 36px; text-align: right;
}
.modal-icon-grid {
  flex: 1;
  display: flex; flex-wrap: wrap; gap: 3px;
  max-height: 90px; overflow-y: auto;
}
.modal-color-swatches {
  display: flex; flex-wrap: wrap; gap: 5px; padding-top: 4px; margin-bottom: 8px;
}

/* ── Input emoji picker ───────────────────────────────────────────────────────*/
.emoji-picker-btn {
  background: var(--paper2); border: none;
  font-size: 16px; cursor: pointer;
  width: 30px; height: 30px;
  padding: 0; border-radius: 5px;
  transition: all 0.14s; line-height: 1;
  flex-shrink: 0; margin-bottom: 2px;
  display: flex; align-items: center; justify-content: center;
}
.emoji-picker-btn:hover { background: var(--paper3); transform: scale(1.1); }

.input-emoji-picker {
  position: fixed;
  width: 320px;
  background: var(--paper2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  z-index: 500;
  overflow: hidden;
  animation: ctxIn 0.1s ease;
}
.iep-search-wrap {
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.iep-search {
  width: 100%; box-sizing: border-box;
  background: var(--paper2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  outline: none;
}
.iep-search:focus { border-color: var(--accent); }
.iep-cats {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  overflow-x: hidden;
}
.iep-cat {
  background: none; border: none;
  font-size: 18px; cursor: pointer;
  padding: 4px 6px; border-radius: 6px;
  transition: background 0.1s;
  flex: 1; text-align: center;
  line-height: 1;
}
.iep-cat:last-child { font-size: 14px; font-family: 'DM Mono', monospace; font-weight: 700; }
.iep-cat:hover { background: var(--paper2); }
.iep-cat.active { background: var(--paper3); }
.iep-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
}
.iep-emoji {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  padding: 4px; border-radius: 5px;
  transition: background 0.1s, transform 0.1s;
  text-align: center; line-height: 1;
}
.iep-emoji:hover { background: var(--paper3); transform: scale(1.2); }
.iep-emoji.text-char {
  font-size: 15px;
  font-family: 'DM Mono', monospace;
  font-weight: 600;
}
