/* Theme: original Halloween palette (docs/ui.md). Orange for primary actions only; green only for speaking and online. */
:root {
  color-scheme: dark;
  --bg-deep: #120c18;   /* midnight: rail, page */
  --bg: #1d1428;        /* dark plum: chat */
  --panel: #171020;     /* sidebar, member list */
  --raised: #2a1c3a;    /* inputs, hovers, cards */
  --line: #33244a;
  --pumpkin: #ff7518;
  --purple: #8a4fd6;
  --slime: #7ed957;
  --blood: #d7263d;
  --text: #f1e6d0;      /* bone */
  --muted: #a894b8;
  --on-pumpkin: #1a0f06;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; background: var(--bg-deep); color: var(--text);
  font: 15px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
select, input[type=password], input:not([type]) {
  font: inherit; font-size: 16px; /* 16px stops iOS zooming into fields */
  color: var(--text); background: var(--bg-deep); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
input[type=range] { accent-color: var(--pumpkin); }
input[type=checkbox] { accent-color: var(--pumpkin); width: 16px; height: 16px; }
.sprite { display: none; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- shell grid ---- */
#app {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: 72px 240px minmax(0, 1fr) 240px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "rail side main members" "rail user main members";
}
#app.nomembers { grid-template-columns: 72px 240px minmax(0, 1fr) 0; }
#app.nomembers #members { display: none; }
#rail { grid-area: rail; background: var(--bg-deep); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; }
#sidebar { grid-area: side; background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#userpanel { grid-area: user; background: #110b19; }
#main { grid-area: main; background: var(--bg); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#members { grid-area: members; background: var(--panel); overflow-y: auto; padding: 8px 8px 16px; }

/* ---- rail ---- */
.space {
  width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--raised); display: grid; place-items: center;
  transition: border-radius .15s ease, background .15s ease; position: relative;
}
.space:hover, .space.active { border-radius: 16px; background: #3a2650; }
.space.active::before { content: ""; position: absolute; left: -12px; width: 4px; height: 36px; border-radius: 0 4px 4px 0; background: var(--text); }
.rail-sep { width: 32px; height: 2px; border-radius: 1px; background: var(--line); }
.pumpkin { width: 30px; height: 30px; --pk1: #e8640f; --pk2: var(--pumpkin); --stem: #5d8f3a; }
html:not(.spooky) .pumpkin { --pk1: #6c3fb0; --pk2: var(--purple); --stem: var(--muted); }
/* Rules on the symbol's own elements reach the <use> copies; the colors come in through inherited variables. */
#i-pumpkin .pk { fill: var(--pk1); }
#i-pumpkin .pk2 { fill: var(--pk2); }
#i-pumpkin .stem { fill: none; stroke: var(--stem); stroke-width: 2.4; stroke-linecap: round; }

/* ---- sidebar ---- */
.side-head { height: 48px; flex: none; display: flex; align-items: center; padding: 0 16px; font-weight: 700; border-bottom: 1px solid #0c0811; box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.side-scroll { flex: 1; overflow-y: auto; padding: 8px; }
.cat { margin: 16px 8px 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.cat:first-child { margin-top: 8px; }
.chan {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 1px 0; border: 0; border-radius: 6px;
  background: none; color: var(--muted); text-align: left; font-weight: 500;
}
.chan:hover { background: var(--raised); color: var(--text); }
.chan.active { background: #33224a; color: var(--text); }
.chan .hash, #chanhead .hash { font-size: 20px; line-height: 1; color: var(--muted); width: 20px; text-align: center; }

/* ---- avatars and presence ---- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 14px; color: #fff; background: var(--purple); box-shadow: 0 0 0 2px transparent; transition: box-shadow .12s;
}
.avatar.c1 { background: #b8530f; }
.avatar.c2 { background: #6c3fb0; }
.avatar.speaking { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--slime); }
.avatar-wrap { position: relative; flex: none; }
.avatar-wrap .dot { position: absolute; right: -2px; bottom: -2px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #5b4a6b; border: 3px solid var(--panel); display: inline-block; flex: none; }
.dot.on { background: var(--slime); }

/* ---- user panel ---- */
#userpanel { display: flex; align-items: center; gap: 6px; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); min-height: 56px; }
#userpanel .dot { border-color: #110b19; }
.me-text { flex: 1; min-width: 0; margin-left: 4px; }
#mename { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  width: 34px; height: 34px; flex: none; border: 0; border-radius: 6px; background: none; color: var(--muted);
  display: grid; place-items: center; position: relative;
}
.iconbtn > * { grid-area: 1 / 1; }
.iconbtn:hover:not(:disabled) { background: var(--raised); color: var(--text); }
.iconbtn .slash { display: none; color: var(--blood); stroke-width: 2.4; }
.iconbtn.on { color: var(--blood); }
.iconbtn.on .slash { display: block; }

/* ---- channel header ---- */
#chanhead {
  height: 48px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px;
  border-bottom: 1px solid #120c18; box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.chan-name { font-weight: 700; }
#peerchip { display: flex; align-items: center; gap: 6px; margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); font-size: 13px; }
#peerchip .dot { width: 10px; height: 10px; border: 0; }
.grow { flex: 1; }
#drawerbtn { display: none; }
#callbtn:not(:disabled):hover { color: var(--slime); }
#membersbtn[aria-pressed=true] { color: var(--text); }

/* ---- call area ---- */
#callarea { flex: none; background: #0d0912; border-bottom: 1px solid var(--line); padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
#calltiles { display: flex; gap: 24px; justify-content: center; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tile .avatar { width: 72px; height: 72px; font-size: 28px; }
.tile .avatar.speaking { box-shadow: 0 0 0 3px #0d0912, 0 0 0 6px var(--slime); }
.tile.away .avatar { opacity: .4; }
.tile.ringing .avatar { animation: ring 1.6s ease-in-out infinite; }
@keyframes ring { 0%, 100% { box-shadow: 0 0 0 3px #0d0912, 0 0 0 5px rgba(255,117,24,.0); } 50% { box-shadow: 0 0 0 3px #0d0912, 0 0 0 7px rgba(255,117,24,.7); } }
@media (prefers-reduced-motion: reduce) { .tile.ringing .avatar { animation: none; box-shadow: 0 0 0 3px #0d0912, 0 0 0 6px var(--pumpkin); } }
#stage { position: relative; width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; display: flex; justify-content: center; }
#remote { max-width: 100%; max-height: 50vh; display: block; }
/* While a share is on screen the avatars shrink so the chat keeps some room. */
#callarea:has(#stage:not([hidden])) { padding-top: 10px; gap: 8px; }
#callarea:has(#stage:not([hidden])) .tile { flex-direction: row; }
#callarea:has(#stage:not([hidden])) .tile .avatar { width: 32px; height: 32px; font-size: 14px; }
#vstats { position: absolute; left: 8px; top: 8px; padding: 2px 6px; border-radius: 4px; background: rgba(0,0,0,.65); font: 11px ui-monospace, monospace; color: var(--text); }
#vstats:empty { display: none; }
#callbar { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
#callstate { color: var(--muted); font-size: 13px; margin-right: 4px; }
#shareaudiolbl { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 0; border-radius: 18px;
  background: var(--raised); color: var(--text); font-weight: 600; font-size: 14px;
}
.pill .ic { width: 18px; height: 18px; }
.pill:hover:not(:disabled) { background: #3a2650; }
.pill.go { background: var(--pumpkin); color: var(--on-pumpkin); }
.pill.go:hover:not(:disabled) { background: #ff8a3d; }
.pill.danger { background: var(--blood); color: #fff; }
.pill.danger:hover:not(:disabled) { background: #e43c52; }

/* ---- messages ---- */
#messages { flex: 1; min-height: 120px; overflow-y: auto; padding: 16px 0 8px; display: flex; flex-direction: column; }
#welcome { margin-top: auto; padding: 16px 16px 12px; position: relative; }
#welcome .welcome-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--raised); display: grid; place-items: center; font-size: 36px; color: var(--text); }
#welcome h2 { margin: 12px 0 4px; font-size: 26px; }
#welcome p { margin: 0; color: var(--muted); }
#welcome .web { position: absolute; right: 8px; top: -8px; width: 96px; height: 96px; transform: scaleX(-1); fill: none; stroke: #3d2c55; stroke-width: 1.2; }
html:not(.spooky) #welcome .web { display: none; }

/* ---- member list ---- */

/* ---- channel list (M5b) ---- */
.cat-row { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 4px; }
.cat-row:first-child { margin-top: 8px; }
.cat-row .cat { margin: 0 8px; }
.mini { width: 22px; height: 22px; border: 0; border-radius: 4px; background: none; color: var(--muted); display: grid; place-items: center; padding: 0; }
.mini:hover { color: var(--text); background: var(--raised); }
.mini .ic { width: 16px; height: 16px; }
.chan-row { position: relative; }
.chan-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan.unread { color: var(--text); font-weight: 700; }
.chan.unread::before { content: ""; position: absolute; left: -8px; width: 4px; height: 8px; border-radius: 0 4px 4px 0; background: var(--text); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--blood); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.chan-edit { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border: 0; border-radius: 4px; background: none; color: var(--muted); display: none; place-items: center; padding: 0; }
.chan-edit .ic { width: 15px; height: 15px; }
.chan-row:hover .chan-edit, .chan-edit:focus-visible { display: grid; }
.chan-row:hover .badge { visibility: hidden; }
.chan-edit:hover { color: var(--text); }
.chan.voice.active { color: var(--slime); }
.vpeople { padding: 0 0 4px 30px; }
.vperson { display: flex; align-items: center; gap: 8px; padding: 3px 8px; color: var(--muted); font-size: 14px; border-radius: 6px; }
.vperson:hover { background: var(--raised); color: var(--text); }
.vperson .avatar { width: 24px; height: 24px; font-size: 11px; }

/* avatars with pictures, sizes */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.tiny { width: 16px; height: 16px; font-size: 9px; }
.avatar.big { width: 64px; height: 64px; font-size: 26px; }

/* ---- messages ---- */
.msg {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); grid-template-areas: "reply reply" "av head" "av body";
  column-gap: 14px; padding: 2px 16px; margin-top: 14px; position: relative;
}
.msg:hover, .msg.editing { background: rgba(255,255,255,.03); }
.msg > .avatar { grid-area: av; width: 40px; height: 40px; font-size: 16px; margin-top: 2px; cursor: pointer; }
.msg .head { grid-area: head; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg .body { grid-area: body; min-width: 0; }
.author { font-weight: 600; }
.author.c1, .reply-name.c1 { color: #ffb27a; }
.author.c2, .reply-name.c2 { color: #c7a4f5; }
.msg .head .author { cursor: pointer; }
.msg .head .author:hover { text-decoration: underline; }
.msg .time { font-size: 12px; color: var(--muted); }
.pinmark { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .text.jumbo { font-size: 40px; line-height: 1.2; }
.edited { font-size: 11px; color: var(--muted); }
.msg.cont { margin-top: 0; grid-template-areas: "av body"; }
.msg.cont > .avatar, .msg.cont .head { display: none; }
.msg.cont::before { content: attr(data-hm); position: absolute; left: 16px; top: 4px; width: 40px; text-align: right; font-size: 11px; color: var(--muted); opacity: 0; }
.msg.cont:hover::before { opacity: 1; }
.msg.sending .text { opacity: .55; }
.msg.failed .text { color: #ff6b7d; }
.retry { border: 0; background: none; color: #ff6b7d; font-size: 12px; padding: 2px 0; text-decoration: underline; }
.msg.mentioned { background: rgba(255,117,24,.07); box-shadow: inset 3px 0 0 var(--pumpkin); }
.msg.mentioned:hover { background: rgba(255,117,24,.11); }
.msg.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: rgba(138,79,214,.3); } 100% { background: transparent; } }
.mention { background: rgba(138,79,214,.25); color: #dcc7ff; border-radius: 4px; padding: 0 2px; font-weight: 500; }
.mention.me { background: rgba(255,117,24,.22); color: #ffc79a; }
.link { color: #ffa25c; text-decoration: none; }
.link:hover { text-decoration: underline; }
.replyline { grid-area: reply; display: flex; align-items: center; gap: 6px; margin: 0 0 2px 20px; font-size: 13px; color: var(--muted); cursor: pointer; min-width: 0; position: relative; }
.replyline::before { content: ""; position: absolute; left: -2px; top: 9px; width: 30px; height: 10px; border-left: 2px solid var(--line); border-top: 2px solid var(--line); border-top-left-radius: 6px; transform: translateX(-100%); }
.replyline .reply-name { font-weight: 600; flex: none; }
.reply-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.replyline:hover .reply-text { color: var(--text); }
.muted { color: var(--muted); font-style: italic; }
.newline { display: flex; align-items: center; gap: 8px; margin: 14px 16px 0; color: var(--blood); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.newline::before { content: ""; flex: 1; height: 1px; background: var(--blood); }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.attach-img { max-width: min(400px, 100%); max-height: 300px; min-width: 60px; min-height: 40px; border-radius: var(--radius); cursor: zoom-in; display: block; background: var(--raised); }
.attach-file { display: flex; align-items: center; gap: 10px; max-width: 360px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); text-align: left; }
.attach-file:hover { border-color: var(--purple); }
.attach-icon { font-size: 22px; }
.attach-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #ffa25c; }
.attach-size { color: var(--muted); font-size: 12px; }
.attach-missing { color: var(--muted); font-size: 13px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.reactions:not(:empty) { margin-top: 4px; }
.react { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: var(--raised); color: var(--text); font-size: 14px; }
.react:hover { border-color: var(--line); }
.react.mine { background: rgba(138,79,214,.25); border-color: var(--purple); }
.react-n { font-size: 13px; font-weight: 600; }
.react-add { opacity: 0; }
.msg:hover .react-add, .react-add:focus-visible { opacity: 1; }
.tools {
  position: absolute; right: 16px; top: -14px; display: none; gap: 2px; padding: 2px; z-index: 2;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.msg:hover .tools, .tools:focus-within { display: flex; }
.msg.editing .tools { display: none; }
.tool { width: 30px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--muted); display: grid; place-items: center; padding: 0; }
.tool .ic { width: 18px; height: 18px; }
.tool:hover { background: var(--raised); color: var(--text); }
.tool.danger:hover { color: #ff6b7d; }
.react-add.tool { width: 26px; height: 26px; }
.edit-box { width: 100%; resize: vertical; font: inherit; color: var(--text); background: var(--raised); border: 1px solid var(--purple); border-radius: var(--radius); padding: 8px 10px; }
.edit-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- jump bar, typing, composer ---- */
#jumpbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 16px; padding: 6px 10px; border-radius: var(--radius) var(--radius) 0 0; background: #33224a; color: var(--text); font-size: 13px; }
#typing { height: 22px; flex: none; padding: 2px 16px 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#typing .dots { letter-spacing: 2px; color: var(--text); animation: dots 1.2s ease-in-out infinite; }
@keyframes dots { 50% { opacity: .35; } }
#composerwrap { flex: none; position: relative; padding: 0 16px 20px; }
#replybar, #attachbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); border-radius: var(--radius) var(--radius) 0 0; font-size: 13px; color: var(--muted); }
#replybar { justify-content: space-between; }
#replybar .reply-name { font-weight: 600; }
#attachbar { flex-wrap: wrap; }
#replybar + #attachbar { border-radius: 0; }
.iconbtn.small { width: 24px; height: 24px; }
.chip { display: flex; align-items: center; gap: 6px; max-width: 220px; padding: 4px 6px; border-radius: 6px; background: var(--raised); color: var(--text); }
.chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; }
.chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.chip-x { border: 0; background: none; color: var(--muted); padding: 0 2px; }
.chip-x:hover { color: #ff6b7d; }
#composer { display: flex; align-items: flex-end; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--raised); }
#replybar:not([hidden]) ~ #composer, #attachbar:not([hidden]) ~ #composer { border-top-left-radius: 0; border-top-right-radius: 0; }
#composer .iconbtn { width: 38px; height: 38px; }
#input { flex: 1; min-width: 0; padding: 9px 6px; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; line-height: 1.35; resize: none; max-height: 200px; outline: none; }
#input::placeholder { color: #85729a; }
.send { border: 0; border-radius: 6px; height: 38px; padding: 0 14px; background: none; color: var(--muted); font-weight: 600; }
.send:hover { color: var(--text); background: rgba(255,255,255,.05); }
#main.dropping::after { content: "Drop files to attach"; position: absolute; inset: 8px; z-index: 15; display: grid; place-items: center; border: 2px dashed var(--pumpkin); border-radius: 12px; background: rgba(18,12,24,.85); color: var(--text); font-size: 18px; font-weight: 600; }
#main { position: relative; }
#mentionpop { position: absolute; left: 16px; right: 16px; bottom: calc(100% - 14px); z-index: 5; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); box-shadow: 0 -6px 20px rgba(0,0,0,.35); }
#mentionpop button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; }
#mentionpop button.sel, #mentionpop button:hover { background: var(--raised); }

/* ---- pins and search panel ---- */
#panel {
  position: absolute; right: 12px; top: 54px; z-index: 12; width: min(400px, calc(100% - 24px)); max-height: calc(100% - 140px);
  display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 6px 16px; }
.panel-head h2 { margin: 0; font-size: 16px; }
#searchrow { display: flex; align-items: center; gap: 10px; padding: 0 16px 8px; }
#searchrow input[type=search] { flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text); background: var(--bg-deep); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
#searchrow .check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
#panelbody { overflow-y: auto; padding: 0 10px 10px; }
#panelbody > .hint { padding: 12px 6px; }
.result { padding: 10px; margin-top: 6px; border-radius: var(--radius); background: var(--panel); }
.result-head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.result-head .time { color: var(--muted); font-size: 12px; margin-left: auto; }
.result-chan { color: var(--muted); }
.result-text { margin: 4px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.result-text mark { background: rgba(255,117,24,.35); color: var(--text); border-radius: 2px; }
.result-actions { display: flex; gap: 6px; }
.mini-pill { border: 0; border-radius: 12px; padding: 3px 10px; background: var(--raised); color: var(--text); font-size: 12px; font-weight: 600; }
.mini-pill:hover { background: #3a2650; }

/* ---- member list ---- */
.member { width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; }
.member:hover { background: var(--raised); }
.member.off { opacity: .45; }
.member-text { display: flex; flex-direction: column; min-width: 0; }
.member .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .you { color: var(--muted); font-size: 12px; margin-left: 4px; }
.member-sub { font-size: 12px; color: var(--slime); }

/* ---- popovers: emoji picker, person card ---- */
.popover { position: fixed; z-index: 50; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.55); }
.emoji-picker { width: 318px; max-width: calc(100vw - 16px); padding: 8px; }
.emoji-search { width: 100%; margin-bottom: 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 260px; overflow-y: auto; }
.emoji-cat { grid-column: 1 / -1; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 2px 2px; }
.emoji-btn { height: 36px; border: 0; border-radius: 6px; background: none; font-size: 22px; line-height: 1; padding: 0; }
.emoji-btn:hover { background: var(--raised); }
.usercard { width: 280px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.usercard-top { display: flex; align-items: center; gap: 12px; }
.usercard-name { font-size: 18px; font-weight: 700; }
.usercard .hint { margin: 0; }
.slider { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 13px; }
.slider span:nth-child(2) { color: var(--muted); }
.slider input { width: 100%; }
.toast { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px); padding: 8px 14px; border-radius: 8px; background: #33224a; color: var(--text); font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.45); transition: opacity .4s; }
.toast.out { opacity: 0; }
.lightbox { position: fixed; inset: 0; z-index: 45; background: rgba(6,3,10,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: calc(100% - 60px); object-fit: contain; border-radius: 6px; }
.lightbox-bar { display: flex; align-items: center; gap: 12px; color: var(--muted); cursor: default; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-actions .left { margin-right: auto; }
.modal-box .field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.modal-box h2 { margin: 0; font-size: 20px; }
#profilerow { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.prof-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
#profcolor { width: 44px; height: 28px; padding: 0; border: 0; background: none; }
#settings label.check .mini-pill { margin-left: 4px; }
#profsave { margin-top: 2px; }

/* ---- modals ---- */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(6,3,10,.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { width: min(460px, 100%); max-height: 85vh; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-box.wide { width: min(780px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-box h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
#settings label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 14px; }
#settings label span { color: var(--muted); }
#settings label.check { flex-direction: row; align-items: center; gap: 8px; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
#pickeropts { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
#pickeropts label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.source { background: var(--raised); border: 2px solid transparent; border-radius: var(--radius); padding: 6px; font-size: 12px; text-align: center; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source:hover { border-color: var(--pumpkin); }
.source img { width: 100%; display: block; margin-bottom: 6px; border-radius: 4px; }

/* ---- sign-in ---- */
#login { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 120%, #2a1540 0%, var(--bg-deep) 60%); }
#loginform { display: flex; flex-direction: column; gap: 12px; width: min(380px, 100%); padding: 28px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
#loginform .pumpkin.big { width: 56px; height: 56px; align-self: center; }
#loginform h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
#loginform label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
#loginform input { padding: 10px; }
#loginform .pill { min-height: 42px; border-radius: var(--radius); }
#loginerror { min-height: 18px; color: #ff6b7d; font-size: 13px; }

/* ---- narrow screens: channel list becomes a drawer, member list hides, user panel sits under the composer ---- */
#scrim { position: fixed; inset: 0; z-index: 19; background: rgba(6,3,10,.6); }
@media (max-width: 1000px) {
  #app, #app.nomembers { grid-template-columns: 72px 240px minmax(0, 1fr); grid-template-areas: "rail side main" "rail user main"; }
  #members, #membersbtn { display: none; }
}
@media (max-width: 700px) {
  #app, #app.nomembers { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "user"; }
  #rail, #sidebar { position: fixed; top: 0; bottom: 0; z-index: 20; transform: translateX(-100vw); transition: transform .2s ease; }
  #rail { left: 0; width: 72px; padding-top: max(12px, env(safe-area-inset-top)); }
  #sidebar { left: 72px; width: min(260px, calc(100vw - 72px)); padding-top: env(safe-area-inset-top); }
  body.drawer #rail, body.drawer #sidebar { transform: none; }
  #drawerbtn { display: grid; margin-left: -6px; }
  #chanhead { padding-top: env(safe-area-inset-top); height: calc(48px + env(safe-area-inset-top)); }
  #peerchip { margin-left: 4px; padding-left: 8px; }
  #composerwrap { padding: 0 10px 10px; }
  #jumpbar { margin: 0 10px; }
  #panel { right: 6px; left: 6px; width: auto; }
  .tools { right: 8px; }
  #mentionpop { left: 10px; right: 10px; }
  .msg { padding: 2px 10px; column-gap: 10px; }
  .tile .avatar { width: 56px; height: 56px; font-size: 22px; }
  #callarea { padding: 12px 10px 10px; }
}
@media (prefers-reduced-motion: reduce) { #rail, #sidebar, .space { transition: none; } }

/* Touch screens: tools show on tap (chat.ts), the add-reaction button is always visible. */
.msg.show-tools .tools { display: flex; }
@media (hover: none) {
  .react-add { opacity: 1; }
  .chan-edit { display: grid; }
  .chan-row .badge { margin-right: 26px; }
  .chan-row:hover .badge { visibility: visible; }
}
#chanhead .chan-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#peerchip { min-width: 0; white-space: nowrap; }
#peerchiptext { overflow: hidden; text-overflow: ellipsis; }
