/* ============================================================
   CLANK — a faithful Slack-style workspace. Light "aubergine" theme.
   ============================================================ */
:root {
  --topbar: #350D36;
  --rail: #350D36;
  --sidebar: #3F0E40;
  --sidebar-hover: rgba(255,255,255,.09);
  --sidebar-active: #1164A3;
  --sidebar-text: rgba(255,255,255,.78);
  --sidebar-text-dim: rgba(255,255,255,.5);
  --sidebar-head: #FFFFFF;
  --badge: #E01E5A;
  --green: #007A5A;
  --text: #1D1C1D;
  --text-dim: #616061;
  --text-faint: #9A9A9A;
  --link: #1264A3;
  --border: rgba(29,28,29,.13);
  --border-strong: rgba(29,28,29,.3);
  --hover: #F8F8F8;
  --mention-bg: rgba(29,155,209,.12);
  --mention-you-bg: #F7D773;
  --mention-msg-bg: #FCF4DA;
  --msg-select: #F8F8F8;
  --accent: #1264A3;
  --accent-btn: #007A5A;
  --chip-bg: #F0F0F0;
  --font: "Lato","LatoLatin",-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif;
  --mono: "SF Mono",Monaco,Menlo,Consolas,"Courier New",monospace;
  --rail-w: 66px;
  --sb-w: 260px;
  --topbar-h: 44px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  font-size: 15px;
  line-height: 1.46668;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  background: #fff;
}
button { font-family: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
input, textarea { font-family: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { flex: none; vertical-align: middle; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(29,28,29,.28); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(29,28,29,.45); }
::-webkit-scrollbar-track { background: transparent; }
#sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); }
.hidden { display: none !important; }

/* ============ app frame ============ */
#app { display: flex; flex-direction: column; height: 100vh; }
#main-row { display: flex; flex: 1; min-height: 0; }

/* ============ top bar ============ */
#topbar {
  height: var(--topbar-h);
  background: var(--topbar);
  display: flex; align-items: center;
  padding: 0 12px 0 8px;
  flex: none;
  gap: 4px;
  -webkit-user-select: none; user-select: none;
}
#topbar .tb-btn {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.8);
}
#topbar .tb-btn:hover { background: rgba(255,255,255,.14); }
#topbar .tb-btn:disabled { opacity: .35; cursor: default; }
#tb-search-wrap { flex: 1; display: flex; justify-content: center; min-width: 0; }
#tb-search {
  width: min(680px, 62vw); height: 28px;
  background: rgba(255,255,255,.2);
  border-radius: 6px; border: 1px solid rgba(255,255,255,.24);
  color: #fff; display: flex; align-items: center; gap: 8px;
  padding: 0 10px; font-size: 13px;
}
#tb-search:hover { background: rgba(255,255,255,.3); }
#tb-search .ic { opacity: .85; }
#tb-search span.lbl { flex: 1; text-align: center; opacity: .95; white-space: nowrap; overflow: hidden; }
#tb-search .tb-slash {
  font-size: 11px; border: 1px solid rgba(255,255,255,.35); border-radius: 4px;
  padding: 0 4px; opacity: .8; font-family: var(--mono);
}
#tb-me { width: 28px; height: 28px; border-radius: 5px; overflow: visible; position: relative; margin-left: 4px; }
#tb-me img { width: 28px; height: 28px; border-radius: 5px; }
#tb-me .pres { position: absolute; right: -2px; bottom: -2px; }

/* ============ presence dot ============ */
.pres { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.pres.active { background: var(--green); }
.pres.active::after { content: none; }
.pres.away { background: transparent; box-shadow: inset 0 0 0 1.8px var(--sidebar-text-dim); }
.on-light .pres.away { box-shadow: inset 0 0 0 1.8px #9A9A9A; }
.pres.dnd { background: transparent; box-shadow: inset 0 0 0 1.8px var(--sidebar-text-dim); position: relative; }
.pres.dnd::before { content: ""; position: absolute; left: 2.2px; right: 2.2px; top: 4.1px; height: 1.8px; background: var(--sidebar-text-dim); border-radius: 1px; }
.pres.offline { background: transparent; box-shadow: inset 0 0 0 1.8px var(--sidebar-text-dim); }
.pres.big { width: 12px; height: 12px; }
.pres.big::before { top: 5px; }

/* ============ icon rail ============ */
#rail {
  width: var(--rail-w); background: var(--rail);
  display: flex; flex-direction: column; align-items: center;
  padding-top: 8px; flex: none;
  -webkit-user-select: none; user-select: none;
}
#rail-ws {
  width: 38px; height: 38px; border-radius: 9px; margin-bottom: 12px;
  background: rgba(255,255,255,.14); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
#rail-ws:hover { background: rgba(255,255,255,.22); }
#rail-ws .ic { width: 30px; height: 30px; }
.rail-item {
  width: 52px; margin-bottom: 6px; padding: 4px 0 5px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: rgba(255,255,255,.72); font-size: 10.5px; font-weight: 700;
  border-radius: 8px; position: relative;
}
.rail-item .rb { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.rail-item:hover .rb { background: rgba(255,255,255,.13); }
.rail-item.sel .rb { background: rgba(255,255,255,.18); }
.rail-item.sel { color: #fff; }
.rail-item .rail-badge {
  position: absolute; top: 0; right: 4px; min-width: 17px; height: 17px;
  background: var(--badge); border-radius: 9px; color: #fff;
  font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid var(--rail);
}
.rail-dot { position: absolute; top: 4px; right: 8px; width: 9px; height: 9px; background: var(--badge); border-radius: 50%; border: 2px solid var(--rail); }
#rail .spacer { flex: 1; }
#rail-me { width: 36px; height: 36px; border-radius: 8px; position: relative; margin-bottom: 6px; }
#rail-me img { width: 36px; height: 36px; border-radius: 8px; }
#rail-me .pres { position: absolute; right: -3px; bottom: -3px; border: 2px solid var(--rail); }
#rail-plus { margin-bottom: 12px; }

/* ============ sidebar ============ */
#sidebar {
  width: var(--sb-w); background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex; flex-direction: column; flex: none;
  -webkit-user-select: none; user-select: none;
}
#sb-head {
  height: 49px; display: flex; align-items: center;
  padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,.13);
  flex: none; gap: 8px;
}
#sb-ws {
  flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
  color: #fff; font-weight: 900; font-size: 17px;
  padding: 4px 6px 4px 0; border-radius: 6px;
}
#sb-ws:hover { background: rgba(255,255,255,.08); }
#sb-ws .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
#sb-ws .nm .ic { flex: none; }
#sb-compose {
  width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--sidebar);
  display: flex; align-items: center; justify-content: center; flex: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
#sb-compose:hover { transform: scale(1.05); }
#sb-scroll { flex: 1; overflow-y: auto; padding: 10px 0 20px; }
.sb-section { margin-top: 4px; }
.sb-sec-head {
  display: flex; align-items: center; padding: 0 16px 0 14px; height: 28px;
  font-size: 13.5px; color: var(--sidebar-text); border-radius: 6px; margin: 0 8px;
}
.sb-sec-head:hover { background: var(--sidebar-hover); }
.sb-sec-head .lbl { flex: 1; }
.sb-sec-head .ic { opacity: .7; }
.sb-sec-head .sec-add { opacity: 0; width: 22px; height: 22px; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.sb-sec-head:hover .sec-add { opacity: .8; }
.sb-sec-head .sec-add:hover { background: rgba(255,255,255,.15); }
.sb-item {
  display: flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 16px; margin: 0 8px; border-radius: 6px;
  color: var(--sidebar-text); font-size: 15px; cursor: pointer;
  position: relative;
}
.sb-item:hover { background: var(--sidebar-hover); }
.sb-item.sel { background: var(--sidebar-active); color: #fff; }
.sb-item.unread { color: #fff; font-weight: 700; }
.sb-item.muted { opacity: .55; }
.sb-item .ic { opacity: .75; flex: none; }
.sb-item.sel .ic, .sb-item.unread .ic { opacity: 1; }
.sb-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item .nm .draft-tag { color: #E8912D; font-weight: 400; }
.sb-item .cnt {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--badge); color: #fff; font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.sb-item .cnt.quiet { background: rgba(255,255,255,.2); }
.sb-item .presence { display: flex; align-items: center; width: 13px; }
.sb-item .pres { width: 9px; height: 9px; }
.sb-item .pres.dnd::before { top: 3.6px; }
.sb-item img.dm-av { width: 18px; height: 18px; border-radius: 4px; flex: none; }
.sb-item .sb-sub { font-size: 12px; color: var(--sidebar-text-dim); }
.sb-add {
  display: flex; align-items: center; gap: 8px; padding: 0 16px; height: 28px; margin: 0 8px;
  border-radius: 6px; color: var(--sidebar-text); font-size: 15px; cursor: pointer;
}
.sb-add:hover { background: var(--sidebar-hover); }
.sb-add .pl {
  width: 18px; height: 18px; border-radius: 5px; background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center;
}
#sb-foot { flex: none; padding: 8px 16px; font-size: 11.5px; color: var(--sidebar-text-dim); }

/* ============ main column ============ */
#main { flex: 1; display: flex; min-width: 0; background: #fff; }
#convo-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* channel header */
#ch-head {
  height: 49px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 12px 0 16px; gap: 8px;
  flex: none; -webkit-user-select: none; user-select: none;
}
#ch-title {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  font-weight: 900; font-size: 17px; padding: 4px 8px; border-radius: 6px;
}
#ch-title:hover { background: var(--hover); }
#ch-title .ic { color: var(--text-dim); }
#ch-topic {
  flex: 1; color: var(--text-dim); font-size: 13px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 6px; border-radius: 5px;
}
#ch-topic:hover { background: var(--hover); }
#ch-members-btn {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px;
  color: var(--text-dim); font-size: 13px; font-weight: 700;
}
#ch-members-btn:hover { background: var(--hover); }
#ch-members-btn .avstack { display: flex; }
#ch-members-btn .avstack img { width: 22px; height: 22px; border-radius: 4px; border: 2px solid #fff; margin-left: -7px; }
#ch-members-btn .avstack img:first-child { margin-left: 0; }
.ch-head-ic {
  width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.ch-head-ic:hover { background: var(--hover); }

/* pinned bar under channel header */
#pins-bar {
  display: flex; align-items: center; gap: 6px; padding: 3px 16px;
  font-size: 12.5px; color: var(--text-dim); border-bottom: 1px solid var(--border);
  cursor: pointer; flex: none; background: #fff;
}
#pins-bar:hover { background: var(--hover); }
#pins-bar .ic { color: var(--text-dim); }

/* message list */
#msg-scroll { flex: 1; overflow-y: auto; position: relative; }
#msg-list { padding: 8px 0 16px; }
.day-div {
  display: flex; align-items: center; margin: 12px 0 4px; padding: 0 20px;
  position: sticky; top: 0; z-index: 5; background: #fff;
}
.day-div::before { content: ""; flex: 1; height: 1px; background: var(--border); }
.day-div .day-lbl {
  border: 1px solid var(--border); border-radius: 24px; padding: 2px 12px;
  font-size: 13px; font-weight: 700; color: var(--text); background: #fff;
}
.day-div::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.unread-div {
  display: flex; align-items: center; margin: 8px 0; padding: 0 20px;
}
.unread-div::before { content: ""; flex: 1; height: 1px; background: var(--badge); opacity: .8; }
.unread-div .un-lbl {
  color: var(--badge); font-size: 12.5px; font-weight: 700; padding: 0 8px;
  display: flex; align-items: center; gap: 4px;
}
.unread-div::after { content: ""; width: 8px; }
.msg {
  display: flex; gap: 9px; padding: 4px 20px; position: relative;
  line-height: 1.46668;
}
.msg:hover { background: var(--hover); }
.msg.mention-hit { background: var(--mention-msg-bg); }
.msg.mention-hit:hover { background: #F9EFCB; }
.msg.flash { animation: msgflash 1.6s ease; }
@keyframes msgflash { 0% { background: #F2C74480; } 100% { background: transparent; } }
.msg .avw { flex: none; }
.msg .av { width: 36px; height: 36px; border-radius: 6px; flex: none; margin-top: 1px; cursor: pointer; }
.msg .gutter { width: 36px; flex: none; text-align: right; }
.msg .gutter .gtime {
  font-size: 11px; color: var(--text-faint); opacity: 0; line-height: 22px; display: inline-block;
}
.msg:hover .gutter .gtime { opacity: 1; }
.msg .body { flex: 1; min-width: 0; }
.msg .mhead { display: flex; align-items: baseline; gap: 7px; }
.msg .mname { font-weight: 900; font-size: 15px; cursor: pointer; }
.msg .mname:hover { text-decoration: underline; }
.msg .bot-tag {
  font-size: 10px; color: #fff; background: #616061; border-radius: 3px;
  padding: 0 3px; font-weight: 700; transform: translateY(-1px); display: inline-block;
}
.msg .mtime { font-size: 12px; color: var(--text-dim); }
.msg .mtime:hover { text-decoration: underline; }
.msg .mtext { word-wrap: break-word; overflow-wrap: anywhere; }
.msg .mtext b { font-weight: 800; }
.msg .mtext blockquote {
  border-left: 4px solid #DDDDDD; padding: 0 0 0 12px; margin: 4px 0; color: var(--text);
}
.msg .mtext code.ic {
  font-family: var(--mono); font-size: 12.5px; background: #F8F8F8;
  border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; color: #E01E5A;
}
.msg .mtext pre.codeblock {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  background: #F8F8F8; border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px; margin: 6px 0; overflow-x: auto; position: relative;
  white-space: pre; color: var(--text);
}
.msg .mtext pre.codeblock .cb-copy {
  position: absolute; top: 6px; right: 6px; font-size: 11px; font-weight: 700;
  color: var(--text-dim); background: #fff; border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 8px; opacity: 0;
}
.msg .mtext pre.codeblock:hover .cb-copy { opacity: 1; }
.msg .mtext pre.codeblock .cb-copy:hover { color: var(--text); }
.msg .mtext ul, .msg .mtext ol { margin: 2px 0 2px 24px; }
.msg .mtext ul { list-style: disc; }
.msg .mtext ol { list-style: decimal; }
.msg .edited-tag { font-size: 12px; color: var(--text-dim); }
.msg .sys { color: var(--text-dim); font-size: 14px; }
.msg.sys-line { padding-top: 6px; padding-bottom: 6px; }
.msg .emj { font-size: 21px; line-height: 1; vertical-align: -4px; font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif; }
.msg .emj-custom { display: inline-block; width: 21px; height: 21px; vertical-align: -4px; }
.msg .emj-custom svg { width: 21px; height: 21px; display: block; }
.msg.system-join { color: var(--text-dim); }
.mtext.clamped { max-height: 300px; overflow: hidden; position: relative; }
.mtext.clamped::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60px;
  background: linear-gradient(transparent, #fff);
}
.msg .truncate-btn {
  color: var(--link); font-size: 13.5px; font-weight: 700; margin-top: 2px;
  display: inline-flex; align-items: center; gap: 4px;
}
.msg .truncate-btn:hover { text-decoration: underline; }

/* mention chips inside text */
.mention {
  background: var(--mention-bg); color: var(--link); border-radius: 3px;
  padding: 0 3px; font-weight: 700; cursor: pointer;
}
.mention:hover { background: rgba(29,155,209,.25); }
.mention-you { background: var(--mention-you-bg); color: var(--text); }
.mention-you:hover { background: #F0C945; }
.chan-link { background: var(--mention-bg); color: var(--link); border-radius: 3px; padding: 0 3px; font-weight: 700; cursor: pointer; }
.chan-link:hover { background: rgba(29,155,209,.25); }
.msg-link { word-break: break-all; }

/* reactions */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.react-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px;
  border-radius: 12px; padding: 0 7px; font-size: 12px; font-weight: 700;
  background: #fff; border: 1px solid var(--border); color: var(--text-dim);
}
.react-chip:hover { border-color: rgba(29,28,29,.4); }
.react-chip.me { background: #E8F5FB; border-color: #1D9BD1; color: #1264A3; }
.react-chip .emj { font-size: 15px; }
.react-chip .emj-custom { width: 15px; height: 15px; }
.react-chip .emj-custom svg { width: 15px; height: 15px; }
.react-add {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 24px;
  border-radius: 12px; border: 1px solid var(--border); color: var(--text-dim);
  opacity: 0;
}
.msg:hover .react-add, .rply:hover .react-add { opacity: 1; }
.react-add:hover { border-color: rgba(29,28,29,.4); }

/* thread bar under messages */
.thread-bar {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  font-size: 13px; color: var(--link); cursor: pointer;
  padding: 3px 8px; border-radius: 6px; max-width: 480px;
}
.thread-bar:hover { background: #fff; box-shadow: 0 0 0 1px var(--border), 0 1px 3px rgba(0,0,0,.08); }
.msg:hover .thread-bar { background: #fff; }
.thread-bar .tavs { display: flex; }
.thread-bar .tavs img { width: 20px; height: 20px; border-radius: 4px; margin-right: 2px; }
.thread-bar .tcount { font-weight: 700; }
.thread-bar .tlast { color: var(--text-dim); font-weight: 400; font-size: 12.5px; }
.thread-bar .tview { margin-left: auto; font-weight: 700; opacity: 0; }
.thread-bar:hover .tview { opacity: 1; }
.thread-bar.unread .tcount { color: var(--link); }

/* hover action bar */
.hovbar {
  position: absolute; top: -14px; right: 16px; z-index: 10;
  display: none; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.1); padding: 2px;
}
.msg:hover .hovbar, .rply:hover .hovbar { display: flex; }
.hovbar button {
  width: 32px; height: 32px; border-radius: 6px; display: flex;
  align-items: center; justify-content: center; color: var(--text-dim);
}
.hovbar button:hover { background: var(--hover); color: var(--text); }
.hovbar .sep { width: 1px; background: var(--border); margin: 4px 2px; }

/* typing indicator */
#typing-row { padding: 2px 20px 6px; font-size: 13px; color: var(--text-dim); min-height: 22px; flex: none; }
#typing-row .tname { font-weight: 700; }
.typing-dots i {
  display: inline-block; width: 4px; height: 4px; border-radius: 50%;
  background: var(--text-dim); margin-right: 2px; animation: tdots 1.2s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes tdots { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

/* new messages pill */
#new-pill {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 20;
  background: #fff; border: 1px solid var(--border); border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,.18); padding: 6px 14px;
  font-size: 13px; font-weight: 700; color: var(--link);
  display: none; align-items: center; gap: 6px;
}
#new-pill.show { display: flex; }
#new-pill:hover { box-shadow: 0 4px 16px rgba(0,0,0,.25); }

/* ============ composer ============ */
#composer-wrap { padding: 0 20px 18px; flex: none; position: relative; }
.composer {
  border: 1px solid var(--border-strong); border-radius: 8px;
}
.composer:focus-within { border-color: rgba(29,28,29,.6); box-shadow: 0 0 0 1px rgba(29,28,29,.25); }
.comp-ta {
  width: 100%; border: 0; outline: none; resize: none;
  font-size: 15px; line-height: 1.46668; padding: 9px 12px 5px;
  max-height: 40vh; min-height: 22px; background: transparent; color: var(--text);
}
.comp-ta::placeholder { color: var(--text-faint); }
.comp-bar { display: flex; align-items: center; padding: 2px 6px 6px; gap: 1px; }
.cbtn {
  width: 30px; height: 28px; border-radius: 5px; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); position: relative;
}
.cbtn:hover { background: var(--hover); color: var(--text); }
.cbtn:active { background: #E8E8E8; }
.cbtn.on { background: #E8E8E8; color: var(--text); }
.cbtn .kbd-hint {}
.comp-bar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.comp-send {
  margin-left: auto; width: 32px; height: 28px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; background: var(--accent-btn);
}
.comp-send:disabled { background: #F0F0F0; color: #9A9A9A; cursor: default; }
.comp-send .ic { transform: rotate(0deg); }
.comp-hint { font-size: 11px; color: var(--text-faint); padding: 4px 4px 0; display: flex; gap: 12px; }
.comp-hint b { font-weight: 700; }
.comp-autocomplete {
  position: absolute; bottom: 100%; left: 20px; right: 20px; margin-bottom: 6px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.16); max-height: 280px; overflow-y: auto; z-index: 40;
}
.comp-autocomplete .ac-head { padding: 8px 14px 4px; font-size: 12px; color: var(--text-dim); font-weight: 700; }
.ac-item { display: flex; align-items: center; gap: 9px; padding: 6px 14px; cursor: pointer; font-size: 14px; }
.ac-item.sel { background: #1264A3; color: #fff; }
.ac-item.sel .ac-sub { color: rgba(255,255,255,.75); }
.ac-item img { width: 20px; height: 20px; border-radius: 4px; }
.ac-item .ac-nm { font-weight: 700; }
.ac-item .ac-sub { color: var(--text-dim); font-size: 12.5px; }
.ac-item .ac-cmd { font-family: var(--mono); font-size: 13px; font-weight: 700; }

/* join bar / read-only composer replacement */
#join-bar {
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 13.5px;
  background: #FBFAF7;
}
#join-bar .jb-btn {
  background: #fff; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 14px; font-weight: 700; font-size: 14px; color: var(--text);
}
#join-bar .jb-btn:hover { box-shadow: 0 1px 4px rgba(0,0,0,.15); }
#join-bar .jb-btn.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; }
#readonly-bar { color: var(--text-dim); }

/* ============ thread panel ============ */
#thread-panel {
  width: 400px; flex: none; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; background: #fff;
}
#th-head {
  height: 49px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  padding: 0 8px 0 16px; flex: none;
}
#th-head .ttl { font-weight: 900; font-size: 17px; flex: 1; }
#th-head .sub { font-size: 13px; color: var(--text-dim); font-weight: 400; margin-left: 8px; }
#th-scroll { flex: 1; overflow-y: auto; }
#th-scroll .msg { padding: 8px 16px; }
#th-count { padding: 4px 16px 8px; font-size: 13px; color: var(--text-dim); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
#th-composer-wrap { padding: 0 16px 14px; flex: none; position: relative; }
#also-send { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); padding: 2px 2px 6px; }
#also-send input { accent-color: var(--accent-btn); }

/* ============ views: activity / later / dms ============ */
.view-page { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.view-head {
  height: 49px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  padding: 0 20px; gap: 10px; flex: none;
}
.view-head .ttl { font-weight: 900; font-size: 17px; flex: 1; }
.view-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 20px; flex: none; }
.view-tabs button {
  padding: 8px 4px; margin-right: 16px; font-size: 13.5px; font-weight: 700; color: var(--text-dim);
  border-bottom: 2px solid transparent;
}
.view-tabs button.sel { color: var(--text); border-bottom-color: var(--text); }
.view-body { flex: 1; overflow-y: auto; padding: 12px 0 30px; }
.view-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 70%; color: var(--text-dim); gap: 10px; }
.view-empty .big { font-size: 40px; }
.view-empty .e-ttl { font-weight: 900; font-size: 17px; color: var(--text); }
.act-item {
  display: flex; gap: 10px; padding: 10px 24px; cursor: pointer;
}
.act-item:hover { background: var(--hover); }
.act-item .av { width: 36px; height: 36px; border-radius: 6px; }
.act-item .a-body { flex: 1; min-width: 0; font-size: 14px; }
.act-item .a-top { color: var(--text-dim); font-size: 13px; }
.act-item .a-top b { color: var(--text); }
.act-item .a-where { font-size: 12px; color: var(--text-dim); margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.act-item .a-time { font-size: 12px; color: var(--text-dim); flex: none; }
.act-item .snippet {
  border-left: 3px solid var(--border); padding: 2px 0 2px 10px; margin-top: 4px;
  color: var(--text-dim); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 640px;
}
.dm-row { display: flex; align-items: center; gap: 10px; padding: 8px 24px; cursor: pointer; }
.dm-row:hover { background: var(--hover); }
.dm-row .av { width: 28px; height: 28px; border-radius: 6px; }
.dm-row .nm { font-weight: 700; }
.dm-row .prev { color: var(--text-dim); font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-row .tm { color: var(--text-dim); font-size: 12px; }
.browse-row { display: flex; align-items: center; gap: 10px; padding: 9px 24px; }
.browse-row:hover { background: var(--hover); }
.browse-row .bi { flex: 1; min-width: 0; }
.browse-row .bn { font-weight: 900; font-size: 15px; display: flex; gap: 6px; align-items: center; }
.browse-row .bd { color: var(--text-dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browse-row .bj {
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 5px 14px; font-weight: 700;
}
.browse-row .bj:hover { box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.browse-row .bj.joined { color: var(--text-dim); border-color: var(--border); }
.view-head .vsearch {
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 5px 10px;
  font-size: 13.5px; width: 260px; outline: none;
}
.view-head .vsearch:focus { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }

/* ============ channel empty state ============ */
.chan-empty { padding: 30px 24px; color: var(--text-dim); }
.chan-empty .ce-ttl { font-size: 24px; font-weight: 900; color: var(--text); margin-bottom: 8px; }
.chan-empty p { max-width: 560px; font-size: 14.5px; }

/* ============ modals ============ */
#modal-veil {
  position: fixed; inset: 0; background: rgba(29,28,29,.7); z-index: 200;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 9vh;
}
.modal {
  background: #fff; border-radius: 10px; box-shadow: 0 8px 40px rgba(0,0,0,.35);
  width: 580px; max-width: 92vw; max-height: 80vh; display: flex; flex-direction: column;
  overflow: hidden; animation: modalin .18s ease;
}
@keyframes modalin { from { transform: scale(.97) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .m-head {
  padding: 18px 24px 0; display: flex; align-items: center; gap: 10px; flex: none;
}
.modal .m-head .t { font-size: 20px; font-weight: 900; flex: 1; }
.modal .m-head .x { width: 34px; height: 34px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--text-dim); }
.modal .m-head .x:hover { background: var(--hover); }
.modal .m-sub { padding: 4px 24px 0; color: var(--text-dim); font-size: 13.5px; }
.modal .m-body { padding: 14px 24px 20px; overflow-y: auto; flex: 1; }
.modal .m-foot { padding: 0 24px 18px; display: flex; justify-content: flex-end; gap: 8px; flex: none; }
.btn {
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 8px 16px;
  font-weight: 700; font-size: 14px; background: #fff;
}
.btn:hover { box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.btn.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; }
.btn.danger { color: var(--badge); }
.fld { margin-bottom: 14px; }
.fld label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 5px; }
.fld input[type=text], .fld textarea, .fld select {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 6px; padding: 8px 10px;
  font-size: 14.5px; outline: none; font-family: inherit;
}
.fld input:focus, .fld textarea:focus { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
.fld .hint { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }

/* search modal */
#search-modal { width: 720px; }
#search-modal .m-body { padding-top: 8px; }
#search-input-wrap { display: flex; align-items: center; gap: 8px; padding: 14px 24px 8px; }
#search-input-wrap input { flex: 1; font-size: 20px; border: 0; outline: none; }
#search-input-wrap .ic { color: var(--text-dim); }
.search-tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.search-tabs button { padding: 8px 10px; font-size: 13.5px; font-weight: 700; color: var(--text-dim); border-bottom: 2px solid transparent; }
.search-tabs button.sel { color: var(--text); border-bottom-color: var(--text); }
.search-hints { padding: 10px 24px; color: var(--text-dim); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; }
.search-hints .sh { border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.search-hints .sh:hover { background: var(--hover); }
.sr-item { display: flex; gap: 10px; padding: 10px 24px; cursor: pointer; }
.sr-item:hover { background: var(--hover); }
.sr-item .av { width: 36px; height: 36px; border-radius: 6px; flex: none; }
.sr-item .s-body { flex: 1; min-width: 0; }
.sr-item .s-top { display: flex; gap: 8px; align-items: baseline; }
.sr-item .s-who { font-weight: 900; }
.sr-item .s-when { font-size: 12px; color: var(--text-dim); }
.sr-item .s-chan { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
.sr-item .s-text { font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sr-item mark { background: #F2C744; padding: 0 1px; border-radius: 2px; }
.search-count { padding: 8px 24px; font-size: 12.5px; color: var(--text-dim); }

/* quick switcher */
#switch-modal { width: 580px; }
#switch-modal input { font-size: 18px; }
.sw-item { display: flex; align-items: center; gap: 10px; padding: 7px 24px; cursor: pointer; font-size: 15px; }
.sw-item.sel { background: #1264A3; color: #fff; }
.sw-item.sel .sw-sub { color: rgba(255,255,255,.7); }
.sw-item .nm { font-weight: 700; }
.sw-item .sw-sub { color: var(--text-dim); font-size: 12.5px; }
.sw-item img { width: 20px; height: 20px; border-radius: 4px; }
.sw-item .recent { margin-left: auto; font-size: 11px; color: var(--text-dim); }
.sw-item.sel .recent { color: rgba(255,255,255,.7); }
.sw-group { padding: 10px 24px 2px; font-size: 11.5px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }

/* channel details modal */
#chand-modal { width: 640px; }
.chand-tabs { display: flex; gap: 4px; padding: 8px 24px 0; border-bottom: 1px solid var(--border); }
.chand-tabs button { padding: 8px 10px; font-size: 13.5px; font-weight: 700; color: var(--text-dim); border-bottom: 2px solid transparent; }
.chand-tabs button.sel { color: var(--text); border-bottom-color: var(--text); }
.chand-row { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.chand-row .lbl { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.chand-row .val { color: var(--text-dim); margin-top: 3px; }
.chand-row .edit { color: var(--link); font-size: 12.5px; margin-left: auto; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.member-row .av { width: 32px; height: 32px; border-radius: 6px; }
.member-row .mn { font-weight: 700; flex: 1; }
.member-row .mt { color: var(--text-dim); font-size: 12.5px; }
.member-row .msg-btn { border: 1px solid var(--border-strong); border-radius: 6px; padding: 4px 12px; font-weight: 700; font-size: 13px; }
.pin-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.pin-item .p-who { font-weight: 700; font-size: 12.5px; }

/* profile card (popover) */
.pop {
  position: fixed; z-index: 300; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,.2); animation: modalin .14s ease;
}
#profile-pop { width: 300px; }
#profile-pop .pp-head { padding: 16px 16px 10px; display: flex; gap: 12px; }
#profile-pop .pp-av img { width: 56px; height: 56px; border-radius: 8px; }
#profile-pop .pp-nm { font-weight: 900; font-size: 17px; display: flex; align-items: center; gap: 6px; }
#profile-pop .pp-title { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
#profile-pop .pp-status { display: flex; align-items: center; gap: 6px; font-size: 13.5px; margin-top: 6px; }
#profile-pop .pp-body { padding: 0 16px 14px; font-size: 13px; color: var(--text-dim); }
#profile-pop .pp-body .prow { padding: 6px 0; border-top: 1px solid var(--border); display: flex; gap: 8px; }
#profile-pop .pp-body .prow .k { color: var(--text-dim); width: 84px; flex: none; }
#profile-pop .pp-body .prow .v { color: var(--text); }
#profile-pop .pp-acts { padding: 0 16px 14px; display: flex; gap: 8px; }
#profile-pop .pp-acts .btn { flex: 1; text-align: center; padding: 7px 0; }

/* generic dropdown menu */
.menu {
  position: fixed; z-index: 320; min-width: 220px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,.2);
  padding: 6px 0; animation: modalin .12s ease; max-height: 80vh; overflow-y: auto;
}
.menu .mi {
  display: flex; align-items: center; gap: 10px; padding: 6px 20px; font-size: 14px;
  cursor: pointer; color: var(--text);
}
.menu .mi:hover { background: #1264A3; color: #fff; }
.menu .mi:hover .mi-sub { color: rgba(255,255,255,.75); }
.menu .mi .mi-sub { margin-left: auto; color: var(--text-dim); font-size: 12px; }
.menu .mi.danger { color: var(--badge); }
.menu .mi.danger:hover { background: var(--badge); color: #fff; }
.menu .mi.disabled { color: var(--text-faint); cursor: default; }
.menu .mi.disabled:hover { background: none; }
.menu .msep { height: 1px; background: var(--border); margin: 6px 0; }
.menu .mhead { padding: 6px 20px; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.menu .mi .tick { width: 18px; }
.menu .mi img.mi-av { width: 20px; height: 20px; border-radius: 4px; }

/* emoji picker */
#emoji-pop { width: 368px; height: 400px; display: flex; flex-direction: column; }
#emoji-pop .ep-search { padding: 10px 12px 6px; }
#emoji-pop .ep-search input {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 6px; padding: 7px 10px;
  font-size: 14px; outline: none;
}
#emoji-pop .ep-cats { display: flex; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--border); }
#emoji-pop .ep-cats button { padding: 5px 7px; border-radius: 5px; font-size: 16px; opacity: .65; }
#emoji-pop .ep-cats button:hover, #emoji-pop .ep-cats button.sel { opacity: 1; background: var(--hover); }
#emoji-pop .ep-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
#emoji-pop .ep-sec { font-size: 12px; font-weight: 700; color: var(--text-dim); padding: 8px 2px 4px; }
#emoji-pop .ep-grid { display: grid; grid-template-columns: repeat(9, 1fr); }
#emoji-pop .ep-e {
  font-size: 21px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
}
#emoji-pop .ep-e:hover { background: var(--hover); transform: scale(1.15); }
#emoji-pop .ep-e svg { width: 21px; height: 21px; }
#emoji-pop .ep-foot { padding: 6px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; min-height: 34px; }
#emoji-pop .ep-foot .fp { font-size: 18px; }

/* toasts */
#toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 400; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1D1C1D; color: #fff; border-radius: 8px; padding: 10px 16px;
  font-size: 13.5px; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 340px;
  transform: translateY(12px); opacity: 0; transition: all .3s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.in { transform: none; opacity: 1; }
.toast img { width: 24px; height: 24px; border-radius: 5px; }
.toast .t-dim { color: rgba(255,255,255,.65); }

/* in-app banner notification */
#banner-veil { position: fixed; top: 52px; right: 16px; z-index: 350; display: flex; flex-direction: column; gap: 8px; }
.banner {
  width: 340px; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.22); padding: 12px 14px; display: flex; gap: 10px;
  cursor: pointer; animation: bannerin .25s ease;
}
@keyframes bannerin { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.banner.out { transition: all .3s; transform: translateX(60px); opacity: 0; }
.banner img { width: 36px; height: 36px; border-radius: 7px; flex: none; }
.banner .b-who { font-weight: 900; font-size: 13.5px; }
.banner .b-where { font-size: 12px; color: var(--text-dim); }
.banner .b-text { font-size: 13.5px; margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.banner .b-acts { display: flex; gap: 6px; margin-top: 8px; }
.banner .b-acts button { border: 1px solid var(--border-strong); border-radius: 5px; padding: 3px 10px; font-size: 12px; font-weight: 700; }

/* message edit inline */
.msg-edit-box { margin-top: 4px; }
.msg-edit-box textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px;
  font-size: 15px; font-family: inherit; resize: none; outline: none;
}
.msg-edit-box textarea:focus { border-color: var(--link); }
.msg-edit-acts { display: flex; gap: 8px; margin-top: 6px; font-size: 12.5px; align-items: center; }
.msg-edit-acts .me-hint { color: var(--text-dim); flex: 1; }
.msg-edit-acts .btn { padding: 5px 12px; font-size: 13px; }

/* status editor */
.status-emoji-row { display: flex; gap: 8px; align-items: center; }
.status-emoji-row .se-btn {
  width: 44px; height: 40px; border: 1px solid var(--border-strong); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.status-emoji-row input { flex: 1; }
.status-sugs { display: flex; flex-direction: column; margin-top: 8px; }
.status-sugs .ss { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.status-sugs .ss:hover { background: var(--hover); }
.status-sugs .ss .emj { font-size: 18px; }
.status-sugs .ss .clr { margin-left: auto; color: var(--text-dim); font-size: 12px; }

/* prefs */
.pref-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.pref-row .pl { font-weight: 700; font-size: 14.5px; }
.pref-row .pd { color: var(--text-dim); font-size: 13px; margin-top: 2px; max-width: 380px; }
.switch { width: 44px; height: 24px; border-radius: 12px; background: #DDDDDD; position: relative; cursor: pointer; flex: none; }
.switch.on { background: var(--accent-btn); }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: left .15s ease; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch.on::after { left: 22px; }
.theme-swatches { display: flex; gap: 10px; padding: 8px 0; }
.theme-sw { width: 84px; cursor: pointer; }
.theme-sw .ts-sb { height: 46px; border-radius: 6px; border: 2px solid transparent; display: flex; align-items: flex-end; padding: 4px; }
.theme-sw .ts-sb span { display: block; height: 6px; border-radius: 3px; background: rgba(255,255,255,.7); width: 70%; }
.theme-sw.sel .ts-sb { border-color: var(--link); }
.theme-sw .ts-nm { font-size: 12px; text-align: center; margin-top: 4px; color: var(--text-dim); }

/* loading shimmer */
.shimmer { padding: 12px 20px; }
.shimmer .sh-row { display: flex; gap: 10px; margin-bottom: 14px; }
.shimmer .sh-av { width: 36px; height: 36px; border-radius: 6px; background: #F0F0F0; }
.shimmer .sh-lines { flex: 1; }
.shimmer .sh-l { height: 10px; border-radius: 5px; background: #F0F0F0; margin-bottom: 7px; }
@keyframes shpulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.shimmer .sh-av, .shimmer .sh-l { animation: shpulse 1.4s infinite; }

/* ============ mobile ============ */
#mobile-scrim { display: none; }
@media (max-width: 860px) {
  #rail { display: none; }
  #sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; z-index: 150;
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.25);
  }
  body.sb-open #sidebar { transform: none; }
  #mobile-scrim {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 140;
    background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .22s;
  }
  body.sb-open #mobile-scrim { opacity: 1; pointer-events: auto; }
  #tb-search { width: 100%; }
  #tb-search span.lbl { text-align: left; }
  #thread-panel {
    position: fixed; inset: var(--topbar-h) 0 0 0; width: auto; z-index: 160;
  }
  #tb-back { display: flex !important; }
  #ch-topic { display: none; }
  .hovbar { display: none !important; }
  #composer-wrap { padding: 0 10px 10px; }
}
#tb-back { display: none; }

/* craft details */
::selection { background: rgba(29,155,209,.28); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
#sidebar :focus-visible, #rail :focus-visible, #topbar :focus-visible { outline-color: #fff; }
.day-div { position: sticky; top: 0; z-index: 3; }
.day-lbl { background: #fff; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
