:root {
  --teal: #159a8a;
  --green: #5bc88a;
  --blue: #2f80ed;
  /* Primary-action / selected-highlight color. Change THIS ONE value to
     restyle every primary button (Join voice, Create channel, Save, etc.) and
     every blue "selected/active" highlight app-wide. */
  --accent: #5db23b;
  --orange: #f2683c;
  --purple: #9b6dff;
  --yellow: #f0b232;

  --bg-0: #0f1216;
  --bg-1: #161a20;
  --bg-2: #1c2128;
  --bg-3: #232a33;
  --hover: #272e38;
  --active: #2e3742;
  --line: #2a313b;
  --text: #e7ebf0;
  --dim: #98a2b0;
  --faint: #6b7480;

  /* Surface gradients (one set per theme; see themes.css for the variants).
     --sidebar-bg: side columns, dark at top → lighter blue at the bottom.
     --panel-bg:   the bottom-left "me" panel, a subtle golden circular glow.
     --main-bg:    the central chat column, a flat darker surface (no gradient). */
  --sidebar-bg: linear-gradient(180deg, #0f131b 0%, #16203a 60%, #1d2c4e 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(241,185,67,0.17), rgba(241,185,67,0.05) 44%, rgba(0,0,0,0) 72%), #0d1117;
  --main-bg: #0e1116;
  /* Full-screen image viewer backdrop — dark by default; each theme tints it
     to match (medium gray on the light theme; see themes.css). */
  --lb-backdrop: rgba(8, 10, 14, 0.95);

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root { height: 100%; }
body { font-family: var(--sans); background: var(--bg-0); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
a { color: var(--blue); cursor: pointer; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #39414c; border-radius: 8px; }

.splash { display: grid; place-items: center; height: 100%; color: var(--dim); }

/* ---------------- auth + setup ---------------- */
.auth-wrap { display: grid; place-items: center; height: 100%; background: radial-gradient(circle at 50% 0%, #16242a, var(--bg-0) 60%); padding: 20px; }
.auth-card { width: 360px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; display: flex; flex-direction: column; }
.auth-card.wide { width: 440px; }
.auth-logo { width: 64px; height: 64px; align-self: center; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 24px; letter-spacing: -0.02em; }
.auth-sub { text-align: center; color: var(--dim); margin-bottom: 20px; }
.auth-card label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); margin: 12px 0 6px; }
.auth-card input, .settings-form input, .settings-form select {
  background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; color: var(--text); font-size: 14px; outline: none;
}
.auth-card input:focus { border-color: var(--accent); }
.auth-error { margin-top: 12px; color: #ff8a8a; font-size: 13px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 8px; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; border-radius: 8px; padding: 10px 16px; font-size: 14px; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-ghost { background: var(--bg-3); color: var(--dim); border-radius: 8px; padding: 10px 16px; font-weight: 600; }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.auth-toggle { text-align: center; margin-top: 16px; color: var(--dim); font-size: 13px; }

.wiz-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.wiz-dot { width: 28px; height: 4px; border-radius: 3px; background: var(--hover); }
.wiz-dot.on { background: var(--accent); }
.wiz-h { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.wiz-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; }
.radio-row { display: flex; gap: 10px; }
.radio-card { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 12px; cursor: pointer; }
.radio-card.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.radio-card .rc-t { font-weight: 700; font-size: 13px; }
.radio-card .rc-d { font-size: 12px; color: var(--dim); margin-top: 3px; }

/* ---------------- app shell (three panes) ---------------- */
.app { display: grid; grid-template-columns: 240px 1fr 220px; height: 100%; }

.sidebar { background: var(--sidebar-bg); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ws-head { height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; }
.ws-head img { width: 26px; height: 26px; }
.ws-head span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-gear { color: var(--dim); font-size: 16px; padding: 4px 6px; border-radius: 6px; }
.ws-gear:hover { background: var(--hover); color: var(--text); }

.chan-section { flex: 1; overflow-y: auto; padding: 10px 8px; min-height: 0; }
.chan-group { margin-bottom: 8px; }
.chan-label { display: flex; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); padding: 6px 8px 3px; }
.chan-label .add { margin-left: auto; font-size: 16px; line-height: 1; color: var(--faint); padding: 0 4px; }
.chan-label .add:hover { color: var(--text); }
.add-cat { width: 100%; text-align: left; font-size: 12px; color: var(--faint); padding: 6px 8px; border-radius: 6px; }
.add-cat:hover { background: var(--hover); color: var(--text); }
.chan { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin: 1px 0; border-radius: 6px; color: var(--dim); cursor: pointer; }
.chan:hover { background: var(--hover); color: var(--text); }
.chan.active { background: var(--active); color: #fff; }
.chan .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hash { color: var(--faint); font-weight: 600; }

.user-panel { border-top: 1px solid var(--line); background: var(--panel-bg); display: flex; align-items: center; gap: 9px; padding: 8px 10px; }
.user-panel .meta { flex: 1; min-width: 0; }
.user-panel .name { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.user-panel .status { font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.on { background: var(--green); } .dot.off { background: var(--orange); }
.logout { color: var(--dim); font-size: 17px; padding: 6px; border-radius: 6px; }
.logout:hover { background: var(--hover); color: var(--text); }

.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; }
.pdot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bg-1); }
.pdot.on { background: var(--green); } .pdot.off { background: #5a6270; }

/* ---------------- main ---------------- */
.main { background: var(--main-bg); display: flex; flex-direction: column; min-width: 0; }
.main-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line); font-size: 15px; }
.main-head .topic { color: var(--dim); font-size: 13px; border-left: 1px solid var(--line); padding-left: 12px; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.head-actions { margin-left: auto; display: flex; gap: 2px; }
.head-actions button { color: var(--dim); padding: 6px 8px; border-radius: 6px; }
.head-actions button:hover { background: var(--hover); color: var(--text); }

.messages { flex: 1; overflow-y: auto; padding: 16px 0; min-height: 0; }
.load-older { display: block; margin: 0 auto 10px; font-size: 12px; color: var(--accent); padding: 6px 12px; border-radius: 6px; }
.load-older:hover { background: var(--hover); }
.welcome { padding: 12px 18px 18px; }
.welcome img { width: 52px; height: 52px; margin-bottom: 8px; }
.welcome h2 { font-size: 22px; }
.welcome p { color: var(--dim); }

.msg { display: flex; gap: 18px; padding: 3px 22px; position: relative; }
.msg:hover { background: #1e242c; }
.msg.grouped { padding-top: 1px; padding-bottom: 1px; }
/* Extra breathing room before a new author's block; consecutive messages from
   the same person (grouped) stay tight. */
.msg:not(.grouped) { margin-top: 20px; }
.msg .gutter { width: 37px; flex-shrink: 0; }
.msg .avatar.sm { width: 37px; height: 37px; font-size: 13px; }
.msg .body { min-width: 0; flex: 1; }
.msg .head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg .author { font-weight: 600; color: #fff; font-size: 16px; }
.msg .time { font-size: 13px; color: var(--faint); }
.msg .time em { font-style: normal; }
.msg .text { color: #dce0e6; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 1.45; }
.edit-input { width: 100%; background: var(--bg-0); border: 1px solid var(--accent); border-radius: 6px; padding: 7px 10px; color: var(--text); font-size: 15px; outline: none; }
.msg-actions { position: absolute; top: -10px; right: 14px; display: none; background: var(--bg-3); border: 1px solid var(--line); border-radius: 7px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions button { padding: 6px 9px; color: var(--dim); font-size: 13px; }
.msg-actions button:hover { color: var(--text); }

.composer { padding: 0 16px 18px; display: flex; gap: 8px; }
.composer input { flex: 1; background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; padding: 13px 20px; color: var(--text); font-size: 15px; outline: none; }
.composer input:focus { border-color: var(--accent); }
.composer .send { background: var(--blue); color: #fff; font-weight: 600; border-radius: 999px; padding: 0 22px; }
.composer .send:disabled { opacity: 0.5; cursor: default; }

.voice-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--dim); }
.voice-placeholder img { width: 56px; height: 56px; opacity: 0.8; }
.voice-placeholder h3 { color: var(--text); }

/* ---------------- right: members ---------------- */
.right { background: var(--sidebar-bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.right-head { height: 52px; display: flex; align-items: center; padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--dim); letter-spacing: 0.02em; }
.right-scroll { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.mgroup { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); padding: 10px 8px 4px; }
.member { display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 6px; }
.member:hover { background: var(--hover); }
.member.off { opacity: 0.5; }
.member .mn { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.role-tag { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; padding: 1px 5px; border-radius: 4px; }
.t-owner { background: rgba(240, 178, 50, 0.18); color: var(--yellow); }
.t-admin { background: rgba(155, 109, 255, 0.18); color: var(--purple); }
.t-member { background: rgba(47, 128, 237, 0.16); color: #8fb4ff; }
.t-guest { background: rgba(120, 130, 145, 0.18); color: #9aa3af; }

/* ---------------- settings modal ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 9, 11, 0.72); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 640px; max-height: 84vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-close { margin-left: auto; width: 30px; height: 30px; border-radius: 7px; color: var(--dim); font-size: 16px; }
.modal-close:hover { background: var(--hover); color: var(--text); }
.tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.tab { padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: #fff; border-color: var(--accent); }
.tab:hover { color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.settings-form { display: flex; flex-direction: column; max-width: 320px; }
.settings-form label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); margin: 14px 0 6px; }
.settings-form .btn-primary { margin-top: 20px; align-self: flex-start; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td select { background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; color: var(--text); }
.muted { color: var(--faint); }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.pill.on { background: rgba(91, 200, 138, 0.16); color: var(--green); }
.pill.off { background: rgba(120, 130, 145, 0.16); color: var(--dim); }
.mini { font-size: 12px; color: var(--dim); padding: 4px 9px; border-radius: 6px; border: 1px solid var(--line); }
.mini:hover { background: var(--hover); color: var(--text); }
.invite-create { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.invite-create select, .invite-create input { background: var(--bg-0); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; color: var(--text); outline: none; }
.code { font-family: var(--mono); background: var(--bg-0); padding: 2px 7px; border-radius: 5px; cursor: pointer; color: #cdd9ff; }

@media (max-width: 1100px) { .app { grid-template-columns: 220px 1fr; } .right { display: none; } }
@media (max-width: 640px) { .app { grid-template-columns: 1fr; } .sidebar { display: none; }  }
/* Attachments + upload UI (M2) */

/* Image/media attachments line up with the message text column — i.e. the
   image's left edge starts exactly where text begins (under the username), with
   no extra indent. align-items: flex-start so the wrappers (and the image
   inside) shrink-wrap to the photo's real width instead of stretching to the
   full message width — otherwise a portrait photo gets letterboxed/centered
   (object-fit: contain) inside an over-wide element and looks indented. */
.attachments { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 4px; }

/* No frame — the photo sits in the message at its true aspect ratio, with just
   softly rounded corners (no border, no background fill). */
.att-image {
  max-width: 420px; max-height: 320px; width: auto; height: auto; border-radius: 8px;
  cursor: pointer; display: block; object-fit: contain; background: transparent;
}
.att-video { max-width: 480px; max-height: 340px; border-radius: 8px; border: 1px solid var(--line); background: #000; }
.att-audio { width: 360px; max-width: 100%; }

.att-file {
  display: flex; align-items: center; gap: 12px; max-width: 360px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 13px; text-decoration: none; color: var(--text);
}
.att-file:hover { border-color: var(--accent); }
.att-file .fi { width: 36px; height: 36px; border-radius: 7px; background: color-mix(in srgb, var(--accent) 18%, transparent); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.att-file .fn { font-weight: 600; font-size: 13px; color: #cdd9ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file .fs { font-size: 11px; color: var(--faint); }

.att-processing {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim);
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.att-processing .spin { width: 12px; height: 12px; border: 2px solid var(--faint); border-top-color: var(--accent); border-radius: 50%; animation: kp-spin 0.8s linear infinite; }
@keyframes kp-spin { to { transform: rotate(360deg); } }

/* composer upload chips */
.upload-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; }
.chip {
  display: flex; align-items: center; gap: 8px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; max-width: 240px; font-size: 12px;
}
.chip .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.chip .bar { width: 60px; height: 4px; background: #3a4049; border-radius: 3px; overflow: hidden; }
.chip .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.15s; }
.chip .x { color: var(--faint); cursor: pointer; font-size: 14px; }
.chip .x:hover { color: var(--text); }
.chip.err { border-color: var(--orange); color: #ffb39a; }
.chip .ok { color: var(--green); }

.composer .attach-btn {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--dim);
  border-radius: 10px; padding: 0 14px; font-size: 18px;
}
.composer .attach-btn:hover { color: var(--text); border-color: var(--accent); }
.messages.drag { outline: 2px dashed var(--accent); outline-offset: -8px; }
/* Voice room (M3) */
.voice-join {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--dim);
}
.voice-join img { width: 56px; height: 56px; }
.voice-join h3 { color: var(--text); }
.voice-join .btn-primary { margin-top: 8px; }

.voice-room { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #14161b; }
.voice-stage {
  flex: 1; overflow: auto; padding: 16px;
  display: grid; gap: 12px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.tile {
  position: relative; background: #0e1013; border: 1px solid #2a2f37; border-radius: 12px;
  aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.tile.speaking { box-shadow: 0 0 0 2px var(--green); border-color: var(--green); }
.tile.screen { grid-column: 1 / -1; aspect-ratio: 16 / 9; background: #000; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile-avatar {
  width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.tile-label {
  position: absolute; bottom: 8px; left: 10px; background: rgba(0, 0, 0, 0.6); color: #eaeef3;
  padding: 2px 9px; border-radius: 6px; font-size: 12px; display: flex; align-items: center; gap: 6px;
}

.voice-bar {
  height: 72px; flex-shrink: 0; background: #1b1e24; border-top: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
.vb-info { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 8px; flex: 1; }
.vb-controls { display: flex; gap: 10px; }
.vb-spacer { flex: 1; }
.q { width: 9px; height: 9px; border-radius: 50%; background: #5a6270; display: inline-block; }
.q-excellent { background: var(--green); } .q-good { background: var(--green); }
.q-poor { background: var(--yellow); } .q-lost { background: var(--orange); }
.vctrl {
  width: 46px; height: 46px; border-radius: 50%; background: var(--bg-3); color: var(--text);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.vctrl:hover { background: var(--hover); }
.vctrl.on { background: #fff; color: #15171b; }
.vctrl.off { background: var(--bg-3); color: var(--orange); }
.vctrl.leave { background: var(--orange); color: #fff; }
.vctrl.leave:hover { background: #d9542c; }

/* sidebar voice participants */
.vc-members { padding: 1px 0 4px 22px; }
.vc-member { display: flex; align-items: center; gap: 7px; padding: 3px 8px; font-size: 13px; color: var(--dim); }
.vc-member .va {
  width: 18px; height: 18px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
/* M4 collaboration polish: reactions, replies, mentions, pins, typing, search, DMs */

.mention { background: rgba(47, 128, 237, 0.22); color: #cdd9ff; border-radius: 4px; padding: 0 3px; font-weight: 600; }
.ch-link { color: #8fb4ff; }

.reply-context {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim);
  margin-bottom: 2px; opacity: 0.9;
}
.reply-context .ra { font-weight: 600; color: #bcc4d0; }
.reply-context .rs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }

.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.rx {
  display: flex; align-items: center; gap: 5px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 11px; padding: 1px 8px; font-size: 13px; cursor: pointer;
}
.rx:hover { border-color: var(--accent-dim, #33508c); }
.rx.mine { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }
.rx .cnt { color: var(--dim); font-weight: 600; font-size: 12px; }
.rx-add { background: var(--bg-3); border: 1px solid var(--line); border-radius: 11px; padding: 1px 7px; font-size: 13px; color: var(--faint); cursor: pointer; }
.rx-add:hover { color: var(--text); }

.emoji-pop {
  position: absolute; z-index: 30; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 9px; padding: 6px; display: flex; gap: 4px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.emoji-pop button { font-size: 18px; padding: 3px 5px; border-radius: 6px; }
.emoji-pop button:hover { background: var(--hover); }

.pin-flag { font-size: 11px; color: var(--yellow); margin-top: 3px; display: inline-flex; gap: 4px; align-items: center; }

.reply-bar, .typing-line {
  padding: 6px 18px; font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 8px;
}
.reply-bar { background: var(--bg-3); border-top: 1px solid var(--line); }
.reply-bar .x { margin-left: auto; cursor: pointer; color: var(--faint); }
.reply-bar .x:hover { color: var(--text); }
.typing-line { height: 20px; }
.typing-line .dots span { animation: kpblink 1.2s infinite; }
.typing-line .dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-line .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes kpblink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

/* unread badges */
.chan .badge, .dm-row .badge {
  margin-left: auto; background: var(--bg-hover, #2c313a); color: var(--text); font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 0 6px; min-width: 18px; text-align: center;
}
.chan .badge.mention, .dm-row .badge.mention { background: var(--red, #ed4245); color: #fff; }
.chan.unread .cn, .dm-row.unread .nm { color: #fff; font-weight: 600; }

/* DM section */
.dm-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 1px 0; border-radius: 6px; color: var(--dim); cursor: pointer; }
.dm-row:hover { background: var(--hover); color: var(--text); }
.dm-row.active { background: var(--active); color: #fff; }
.dm-row .da { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dm-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

/* search + pins panels (reuse .overlay/.modal from styles.css) */
.search-box { display: flex; gap: 8px; margin-bottom: 14px; }
.search-box input { flex: 1; background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; padding: 10px 13px; color: var(--text); outline: none; }
.search-box input:focus { border-color: var(--accent); }
.result { padding: 10px 8px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.result:hover { background: #1e242c; }
.result .rh { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.result .rh b { color: #fff; }
.result .rh .where { color: var(--faint); }
.result .rc { color: #dce0e6; margin-top: 2px; }

.icon-btn { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--dim); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.pins-list .msg { padding: 8px 4px; border-bottom: 1px solid var(--line); }
/* M4b: read-only composer + notification menu */
.composer-readonly {
  margin: 0 16px 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--faint); font-size: 13px; text-align: center; background: var(--bg-3);
}

.notif-wrap { position: relative; }
.notif-menu {
  position: absolute; right: 0; top: 38px; z-index: 30; width: 200px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 9px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.notif-menu .item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; font-size: 13px; cursor: pointer; width: 100%; text-align: left; }
.notif-menu .item:hover { background: var(--hover); }
.notif-menu .item.sel { color: #fff; }
.notif-menu .item.sel::after { content: '✓'; margin-left: auto; color: var(--accent); }
.notif-menu .sep { height: 1px; background: var(--line); margin: 5px 2px; }
.icon-btn.has-menu.on { color: #fff; }
/* Layout robustness: the "chrome" (headers, composer, user panel) must always
   stay visible; only the scroll regions flex. Fixes elements getting clipped
   when the window is resized. The crucial bit is min-height:0 on the flex
   columns so a tall message list scrolls instead of pushing the composer off. */

.app { min-height: 0; }
.sidebar, .main, .right { min-height: 0; min-width: 0; }

.ws-head,
.user-panel,
.main-head,
.composer,
.composer-readonly,
.reply-bar,
.typing-line,
.upload-chips,
.voice-bar {
  flex-shrink: 0;
}

.chan-section,
.messages,
.right-scroll,
.voice-stage {
  min-height: 0;
}

.user-panel .meta { min-width: 0; }
.user-panel .name { text-overflow: ellipsis; }
.composer input { min-width: 0; }

/* Brand: bigger Dogfish Games badge on the login screen. */
.auth-logo { width: 96px; height: 96px; }
/* Avatars as images */
.av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar { overflow: hidden; }
.avatar.xl { width: 96px; height: 96px; font-size: 30px; }

/* Context menu (right-click) */
.ctx-menu {
  position: fixed; z-index: 200; min-width: 210px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.ctx-item {
  position: relative; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--text); cursor: pointer; user-select: none;
}
.ctx-item:hover { background: var(--accent); color: #fff; }
.ctx-item.danger { color: #ff8a8a; }
.ctx-item.danger:hover { background: var(--red, #ed4245); color: #fff; }
.ctx-item.disabled { opacity: 0.4; cursor: default; }
.ctx-item.disabled:hover { background: transparent; color: var(--text); }
.ctx-item .ci { width: 18px; text-align: center; }
.ctx-item .cl { flex: 1; }
.ctx-item .ca { color: var(--dim); }
.ctx-item:hover .ca { color: #fff; }
.ctx-item .ck { color: var(--accent); }
.ctx-item:hover .ck { color: #fff; }
.ctx-item.on { color: #fff; }
.ctx-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.ctx-submenu {
  position: absolute; left: 100%; top: -6px; min-width: 190px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* Create-channel modal */
.create-modal { max-width: 480px; }
.ctype { display: flex; gap: 10px; margin-bottom: 16px; }
.ctype-opt { flex: 1; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--text); }
.ctype-opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.ctype-opt .ct-ic { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-0); display: flex; align-items: center; justify-content: center; font-size: 17px; color: var(--dim); }
.create-modal label, .profile-modal label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); margin: 12px 0 6px; }
.create-modal input, .create-modal select, .profile-modal input, .profile-modal textarea {
  width: 100%; background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px; outline: none; font-family: inherit;
}
.create-modal input:focus, .profile-modal input:focus, .profile-modal textarea:focus { border-color: var(--accent); }
.name-row { display: flex; gap: 8px; }
.emoji-btn { width: 44px; flex-shrink: 0; background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; font-size: 18px; }
.emoji-btn:hover { border-color: var(--accent); }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.emoji-grid .eg { width: 32px; height: 32px; border-radius: 7px; font-size: 17px; }
.emoji-grid .eg:hover { background: var(--hover); }
.emoji-grid .eg.sel { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* Profile modal */
.profile-modal { max-width: 460px; }
.profile-view { text-align: center; }
.profile-view .avatar.xl { margin: 0 auto 12px; }
.profile-view h2 { font-size: 22px; }
.pf-status { margin-top: 8px; font-size: 14px; }
.pf-bio { margin-top: 12px; color: var(--dim); white-space: pre-wrap; }
.pf-row { margin-top: 10px; font-size: 13px; }
.pf-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }

/* drag-reorder */
.chan.drag-over { box-shadow: inset 0 2px 0 var(--accent); }
.chan[draggable='true'] { cursor: grab; }
.user-panel .name { cursor: pointer; }
.user-panel .name:hover { text-decoration: underline; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 250;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
/* Keep logos at their natural aspect ratio inside fixed boxes. */
.ws-head img, .welcome img, .voice-join img, .voice-room img { object-fit: contain; }

/* Unread divider */
.unread-divider {
  display: flex; align-items: center; gap: 10px; margin: 8px 16px;
  color: var(--red, #ed4245); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.unread-divider::before, .unread-divider::after { content: ''; flex: 1; height: 1px; background: var(--red, #ed4245); opacity: 0.45; }

/* @mention autocomplete */
.mention-pop {
  position: absolute; bottom: 100%; left: 16px; margin-bottom: 6px; width: 250px; max-height: 230px; overflow: auto;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45); z-index: 40; padding: 5px;
}
.mention-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.mention-row.sel, .mention-row:hover { background: var(--accent); color: #fff; }
.mention-row .mu { color: var(--dim); font-size: 12px; }
.mention-row.sel .mu, .mention-row:hover .mu { color: #dbe7ff; }

/* Discord-style profile card */
.profile-card { position: fixed; z-index: 240; width: 280px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55); overflow: hidden; }
.pc-banner { height: 56px; background: linear-gradient(135deg, var(--teal), var(--blue)); }
.pc-body { padding: 0 16px 16px; margin-top: -30px; }
.pc-body .avatar { width: 68px; height: 68px; font-size: 24px; border: 4px solid var(--bg-2); }
.pc-name { font-size: 19px; font-weight: 700; margin-top: 8px; }
.pc-sub { color: var(--dim); font-size: 13px; text-transform: capitalize; }
.pc-status { margin-top: 8px; font-size: 13px; }
.pc-bio { margin-top: 10px; font-size: 13px; color: var(--dim); white-space: pre-wrap; }
.pc-row { margin-top: 8px; font-size: 12px; color: var(--dim); }
.pc-actions { margin-top: 14px; display: flex; gap: 8px; }
.pc-actions button { flex: 1; }

/* Notepad button */
.notepad-btn { display: flex; align-items: center; gap: 8px; padding: 7px 8px; margin: 4px 0 2px; border-radius: 6px; color: var(--dim); cursor: pointer; width: 100%; text-align: left; font-size: 14px; }
.notepad-btn:hover { background: var(--hover); color: var(--text); }
.notepad-btn.active { background: var(--active); color: #fff; }
.notepad-btn .npi { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, #5bc88a, #159a8a); display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
/* Color schemes. Dark is the default (defined in styles.css :root). Each theme
   also defines its own surface gradients: --sidebar-bg (side columns, dark top →
   lighter/bluer bottom), --panel-bg (bottom-left "me" panel, a subtle golden
   circular glow) and --main-bg (flat central chat surface). */

[data-theme='light'] {
  --bg-0: #ffffff; --bg-1: #f3f5f8; --bg-2: #ffffff; --bg-3: #eef1f5;
  --hover: #e7edf3; --active: #dbe4ee; --line: #e1e6ec;
  --text: #1b2330; --dim: #5c6573; --faint: #8b94a1;
  --sidebar-bg: linear-gradient(180deg, #eef1f6 0%, #e6edf8 58%, #d9e7fc 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(240,184,64,0.22), rgba(240,184,64,0.06) 45%, rgba(255,255,255,0) 72%), #eef1f5;
  --main-bg: #ffffff;
  /* Light theme keeps the viewer readable with a medium gray (not near-black). */
  --lb-backdrop: rgba(82, 88, 97, 0.96);
}
[data-theme='light'] .msg:hover { background: #f4f7fa; }
[data-theme='light'] .messages { background: #fff; }

[data-theme='gray'] {
  --bg-0: #1f2123; --bg-1: #292c2f; --bg-2: #303336; --bg-3: #393d41;
  --hover: #41464c; --active: #4b5158; --line: #3c4147;
  --text: #e6e8ea; --dim: #a3a8af; --faint: #777d85;
  --sidebar-bg: linear-gradient(180deg, #232527 0%, #29313f 58%, #2e3a52 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(240,184,64,0.16), rgba(240,184,64,0.045) 44%, rgba(0,0,0,0) 72%), #202224;
  --main-bg: #1a1c1e;
}

[data-theme='retro'] {
  --bg-0: #1a1410; --bg-1: #221a13; --bg-2: #2a2017; --bg-3: #34281d;
  --hover: #3d3022; --active: #4a3a28; --line: #3a2d1f;
  --text: #f0d9b5; --dim: #c2a47c; --faint: #8a7050;
  --blue: #e0a13e; --green: #a7c957; --teal: #c98b2e;
  /* Warm variant: top dark amber → lighter toasted amber at the bottom. */
  --sidebar-bg: linear-gradient(180deg, #1c150e 0%, #2a1f14 55%, #3a2c1a 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(224,161,62,0.24), rgba(224,161,62,0.07) 46%, rgba(0,0,0,0) 72%), #1a130c;
  --main-bg: #17110b;
}

[data-theme='sea'] {
  --bg-0: #061a2b; --bg-1: #0b2436; --bg-2: #0e2c42; --bg-3: #123851;
  --hover: #164460; --active: #1c5272; --line: #15415d;
  --text: #e0f3fb; --dim: #8fc1da; --faint: #5e93ad;
  --blue: #22b8c4; --teal: #1fb6a8; --green: #4fd1a6;
  /* Deep navy → brighter teal at the bottom. */
  --sidebar-bg: linear-gradient(180deg, #061a2b 0%, #0b2f48 55%, #114f60 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(240,184,64,0.18), rgba(240,184,64,0.05) 45%, rgba(0,0,0,0) 72%), #07202f;
  --main-bg: #051420;
}

/* Light theme readability: several elements hardcode white text that assumed a
   dark background. On the light theme those backgrounds are pale, so switch the
   text to the theme's dark --text (or accent) to keep them readable. */
[data-theme='light'] .msg .author { color: var(--text); }
[data-theme='light'] .chan.active,
[data-theme='light'] .dm-row.active,
[data-theme='light'] .notepad-btn.active { color: var(--text); }
[data-theme='light'] .chan.unread .cn,
[data-theme='light'] .dm-row.unread .nm { color: var(--text); }
[data-theme='light'] .tab.active,
[data-theme='light'] .icon-btn.has-menu.on,
[data-theme='light'] .ctx-item.on,
[data-theme='light'] .notif-menu .item.sel { color: var(--accent); }
[data-theme='light'] .result .rh b { color: var(--text); }
[data-theme='light'] .welcome p,
[data-theme='light'] .typing-line { color: var(--dim); }

/* The category "+" (create-channel) button sits on a dark-glass chip. On the
   light theme its faint grey "+" disappears against that chip, so force the
   glyph white here only — other themes keep their existing colour. */
[data-theme='light'] .chan-label .add,
[data-theme='light'] .chan-label .add:hover { color: #fff; }
/* Custom tags */
.utag { display: inline-flex; align-items: center; height: 16px; padding: 0 6px; border-radius: 8px; font-size: 10px; font-weight: 700; color: #fff; letter-spacing: .2px; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.mtags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-left: auto; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* ---- Theme-aware text colors (audit). ---- */
.msg .text { color: var(--text); }
.msg .author { color: var(--text); }
.reply-context .ra { color: var(--dim); }
.result .rh b { color: var(--text); }
.result .rc { color: var(--dim); }
.att-file .fn { color: var(--text); }
[data-theme='light'] .mention,
[data-theme='light'] .ch-link,
[data-theme='light'] .code { color: #1d4ed8; }
[data-theme='light'] .chan.active,
[data-theme='light'] .dm-row.active,
[data-theme='light'] .notepad-btn.active,
[data-theme='light'] .chan.unread .cn,
[data-theme='light'] .dm-row.unread .nm { color: var(--text); }
[data-theme='light'] .tab.active,
[data-theme='light'] .ctx-item.on,
[data-theme='light'] .notif-menu .item.sel,
[data-theme='light'] .icon-btn.has-menu.on { color: var(--accent); }

/* Avatar presence dot must not be clipped by the avatar circle. */
.avatar { overflow: visible; }
.pdot.idle, .dot.idle { background: #f0b232 !important; }

/* Suspended members */
.member.suspended .mn { text-decoration: line-through; opacity: .6; }
tr.row-suspended td { opacity: .6; }

/* Attachment expiry note */
.att-wrap { display: inline-flex; flex-direction: column; gap: 3px; max-width: 100%; }
.att-expiry { font-size: 11px; color: var(--faint); display: flex; align-items: center; gap: 4px; }
.avatar.xs { width: 18px; height: 18px; font-size: 8px; }

/* ---- Resizable, wider sidebar (drag the right edge: -10% to +20%). ---- */
.app { grid-template-columns: var(--sidebar-w, 280px) 1fr 220px; }
.sidebar { position: relative; }
.sidebar-grip { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 40; }
.sidebar-grip:hover { background: linear-gradient(90deg, transparent, rgba(59,130,246,.6)); }
@media (max-width: 1100px) { .app { grid-template-columns: var(--sidebar-w, 280px) 1fr; } .app .right { display: none; } }
@media (max-width: 760px) { .sidebar-grip { display: none; } }

/* ---- Sidebar "On Voice" panel (Discord-style); only while in a voice channel. ---- */
.voice-status { margin: 6px 8px 0; padding: 8px 9px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.vs-top { display: flex; align-items: center; gap: 8px; }
.vs-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; background: transparent; border: none; cursor: pointer; padding: 2px 3px; border-radius: 6px; text-align: left; }
.vs-info:hover { background: var(--hover); }
.vs-on { display: flex; align-items: center; gap: 6px; color: #3ba55d; font-weight: 800; font-size: 13px; line-height: 1.2; }
.vs-wave { width: 9px; height: 9px; border-radius: 50%; background: #3ba55d; }
.vs-wave.live { animation: vs-pulse 1.7s ease-out infinite; }
@keyframes vs-pulse { 0% { box-shadow: 0 0 0 0 rgba(59,165,93,.5); } 70% { box-shadow: 0 0 0 6px rgba(59,165,93,0); } 100% { box-shadow: 0 0 0 0 rgba(59,165,93,0); } }
.vs-chan { color: var(--dim); font-size: 12px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs-info:hover .vs-chan { color: var(--text); }
.vs-hang { width: 36px; height: 36px; border-radius: 8px; background: var(--bg-3); color: #ed4245; border: none; cursor: pointer; font-size: 15px; flex-shrink: 0; }
.vs-hang:hover { background: #ed4245; color: #fff; }
.vs-ctrls { display: flex; gap: 6px; }
.vs-btn { flex: 1; height: 32px; border-radius: 8px; background: var(--bg-3); color: var(--text); border: none; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.vs-btn:hover { background: var(--hover); }
.vs-btn.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.vs-btn.off { background: rgba(237,66,69,.18); color: #ed4245; }
.vs-btn:disabled { opacity: .5; cursor: default; }

/* ---- Discord-style video grid ---- */
/* Tiles fill the available stage: rows stretch to share the height (min 150px),
   so a single participant fills the whole frame and the avatar stays centered,
   instead of a fixed aspect-ratio tile overflowing and pushing it to the bottom. */
.voice-stage { display: grid; gap: 10px; padding: 14px; align-content: stretch; justify-content: stretch; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); grid-auto-rows: minmax(150px, 1fr); overflow: auto; }
.tile { position: relative; background: #0b0d10; border-radius: 12px; overflow: hidden; min-height: 0; display: flex; align-items: center; justify-content: center; border: 2px solid transparent; }
.tile.speaking { border-color: #3ba55d; box-shadow: 0 0 0 2px rgba(59,165,93,.35); }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile-avatar { width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tile-label { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-kick { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.5); color: #fff; border: none; border-radius: 6px; width: 24px; height: 24px; cursor: pointer; font-size: 12px; }
.tile-kick:hover { background: var(--red, #ed4245); }

/* Voice-only call (no cameras): centered circular avatars that scale with the
   frame, with a green speaking ring — Discord's voice-call look. Uses container
   query units so avatars grow/shrink as the panel is resized, staying centered. */
.voice-stage.audio-only { display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 30px; padding: 24px; container-type: size; overflow: auto; }
.voice-puck { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.puck-av { position: relative; width: clamp(48px, 22cqmin, 168px); height: clamp(48px, 22cqmin, 168px); border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-weight: 700; font-size: clamp(18px, 8cqmin, 60px); display: flex; align-items: center; justify-content: center; overflow: hidden; box-shadow: 0 0 0 3px transparent; transition: box-shadow .12s ease; }
.puck-av img { width: 100%; height: 100%; object-fit: cover; }
.voice-puck.speaking .puck-av { box-shadow: 0 0 0 3px #3ba55d, 0 0 0 7px rgba(59,165,93,.28); }
.puck-name { color: var(--dim); font-size: 13px; font-weight: 600; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.puck-kick { position: absolute; top: 6%; right: 6%; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 12px; line-height: 1; }
.puck-kick:hover { background: var(--red, #ed4245); }
.voice-stage.audio-only .screen-card { width: clamp(200px, 46cqmin, 380px); aspect-ratio: 16 / 10; }

/* Screen-share "Watch Stream" card */
.tile.screen-card { flex-direction: column; gap: 8px; cursor: pointer; background: linear-gradient(160deg, #1b1e24, #0b0d10); border: 2px dashed rgba(255,255,255,.14); }
.tile.screen-card:hover { border-color: var(--accent); }
.screen-card .sc-icon { font-size: 30px; }
.screen-card .sc-name { color: #cdd3dc; font-size: 13px; }
.screen-card .sc-watch { background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; padding: 7px 16px; border-radius: 999px; }

/* Theater (maximized stream) */
.voice-theater { display: flex; flex-direction: column; height: 100%; background: #000; }
.theater-stage { position: relative; flex: 1; min-height: 0; background: #000; }
.theater-video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.theater-fs { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.55); color: #fff; border: none; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px; pointer-events: auto; }
.theater-fs:hover { background: rgba(0,0,0,.8); }
.theater-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--bg-1); border-top: 1px solid var(--line); }
.theater-bar .tb-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theater-bar .tb-controls { margin-left: auto; display: flex; gap: 8px; }

/* Theater layout: grow the voice panel (resizable), dock the chat. */
body.kp-theater .voice-dock.expanded { max-height: none; height: 60vh; }
body.kp-theater .main-head { display: none; }
body.kp-theater .messages { flex: 1 1 auto; min-height: 60px; transition: height .25s ease; }
body.kp-theater.kp-chat-min .messages { flex: 0 0 0; height: 0; min-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; }

/* Drag-to-resize grip at the bottom of the voice dock. */
.voice-resize { height: 8px; flex: 0 0 8px; cursor: ns-resize; background: transparent; touch-action: none; }
.voice-resize:hover { background: linear-gradient(var(--line), var(--blue)); }

/* Minimized voice room: keep the audio alive but render nothing here — the
   sidebar "On Voice" panel is the control surface. */
.voice-dock.mini { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.voice-bg { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Shared drawing overlay + tools + cursors */
.draw-wrap { position: absolute; inset: 0; pointer-events: none; }
.draw-canvas { position: absolute; inset: 0; pointer-events: none; }
.draw-canvas.active { pointer-events: auto; cursor: crosshair; touch-action: none; }
.draw-cursors { position: absolute; inset: 0; pointer-events: none; }
.draw-cursor { position: absolute; transform: translate(-3px, -3px); display: flex; align-items: center; gap: 4px; }
.dc-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.5); flex-shrink: 0; }
.dc-name { color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.45); }
.draw-tools { position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.55); border-radius: 999px; padding: 5px 8px; pointer-events: auto; }
.draw-tools .dt { background: transparent; color: #fff; font-size: 15px; padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.draw-tools .dt.on { background: var(--accent); }
.draw-tools .dt-color { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); cursor: pointer; }
.draw-tools .dt-color.sel { border-color: #fff; transform: scale(1.12); }
.draw-tools .dt-size { width: 84px; accent-color: var(--accent); cursor: pointer; }

/* Voice channel you're connected to */
.chan.in-voice .cn { color: var(--green, #3ba55d); font-weight: 600; }
.in-voice-dot { color: var(--green, #3ba55d); font-size: 9px; margin-left: auto; }

/* Persistent voice dock */
.voice-dock.expanded { display: flex; flex-direction: column; max-height: 46vh; min-height: 200px; overflow: hidden; border-bottom: 1px solid var(--line); }
.voice-dock.expanded .voice-room { flex: 1; min-height: 0; }
.voice-cta { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--bg-1); }
.voice-cta img { width: 40px; height: 40px; opacity: .9; }
.voice-cta .vcta-text { display: flex; flex-direction: column; min-width: 0; }
.voice-cta .vcta-text b { font-size: 15px; }
.voice-cta .vcta-text span { color: var(--dim); font-size: 13px; }
.voice-cta .btn-primary { margin-left: auto; flex-shrink: 0; }

/* New-DM member picker */
.dm-empty { width: 100%; text-align: left; color: var(--dim); font-size: 13px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.dm-empty:hover { background: var(--hover); color: var(--text); }
.dm-search { width: 100%; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); outline: none; font-size: 14px; }
.dm-search:focus { border-color: var(--accent); }
.dm-pick-list { margin-top: 12px; max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.dm-pick-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.dm-pick-row:hover { background: var(--hover); }
.dpr-meta { min-width: 0; }
.dpr-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dpr-user { font-size: 12px; color: var(--dim); }

/* GIF (Giphy) picker + emoji board */
.gif-btn { background: var(--bg-3); color: var(--dim); border-radius: 999px; padding: 0 12px; font-weight: 800; font-size: 11px; letter-spacing: .6px; }
.gif-btn:hover { color: var(--text); }
.emoji-btn { background: transparent; font-size: 18px; padding: 0 6px; line-height: 1; }
.emoji-backdrop { position: fixed; inset: 0; z-index: 200; }
.emoji-popover { position: absolute; bottom: calc(100% + 10px); right: 8px; z-index: 201; box-shadow: 0 16px 44px rgba(0,0,0,.5); border-radius: 10px; }
.giphy-modal { max-width: 560px; }
.giphy-attr { margin-left: 10px; font-size: 10px; color: var(--faint); letter-spacing: 1.5px; align-self: center; }
.giphy-grid { columns: 3; column-gap: 8px; margin-top: 12px; max-height: 52vh; overflow-y: auto; }
.giphy-cell { display: block; width: 100%; margin: 0 0 8px; padding: 0; border: none; background: var(--bg-1); border-radius: 8px; overflow: hidden; cursor: pointer; break-inside: avoid; }
.giphy-cell img { width: 100%; display: block; }
.giphy-cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.gif-embed { cursor: pointer; max-width: 320px; border-radius: 8px; }

/* Discord-style profile card */
.profile-card.themed { width: 320px; background: linear-gradient(165deg, var(--c1, #14b8a6), var(--c2, #3b82f6)); border: 1px solid rgba(0,0,0,.4); border-radius: 16px; overflow: hidden; box-shadow: 0 20px 55px rgba(0,0,0,.6); }
.profile-card .pc-banner { height: 120px; background-size: cover; background-position: center; }
.profile-card .pc-inner { position: relative; margin: 12px; padding: 66px 16px 16px; background: rgba(14,15,19,.68); border: 1px solid rgba(0,0,0,.45); border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); text-align: center; }
/* Avatar: 25% larger (84 -> 105) and centered to the frame. */
.pc-av { position: absolute; top: -52px; left: 50%; transform: translateX(-50%); width: 105px; height: 105px; }
.pc-av .avatar.xl { width: 105px; height: 105px; font-size: 37px; border: 3px solid var(--c2, #3b82f6); border-radius: 50%; box-sizing: border-box; }
.pc-dot { position: absolute; right: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--c2, #3b82f6); box-sizing: border-box; }
.pc-dot.online { background: #3ba55d; }
.pc-dot.idle { background: #f0b232; }
.pc-dot.offline { background: #80848e; }
.profile-card .pc-name { color: #fff; font-size: 20px; font-weight: 800; line-height: 1.2; }
.profile-card .pc-sub { color: rgba(255,255,255,.66); font-size: 13px; margin-top: 1px; }
.pc-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 8px 0 2px; }
.profile-card .pc-status { color: rgba(255,255,255,.92); font-size: 13px; margin-top: 10px; }
.profile-card .pc-bio { color: rgba(255,255,255,.82); font-size: 13px; margin-top: 8px; white-space: pre-wrap; }
.profile-card .pc-row { color: rgba(255,255,255,.7); font-size: 12px; margin-top: 8px; }
.pc-edit { width: 100%; margin-top: 14px; }
.pc-localtime { color: #fff; font-weight: 600; }
/* DM box: a fully-rounded pill with a leading paper-plane icon that hides once
   you start typing. The input keeps a constant left pad so text doesn't jump. */
.pc-dm { position: relative; margin-top: 14px; text-align: left; }
.pc-dm-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,.5); font-size: 13px; pointer-events: none; }
.pc-dm-input { width: 100%; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 11px 18px 11px 40px; color: #fff; outline: none; font-size: 13px; box-sizing: border-box; }
.pc-dm-input::placeholder { color: rgba(255,255,255,.45); }
.pc-dm-input:focus { border-color: rgba(255,255,255,.32); }

/* Profile banner editor */
.pf-banner-preview { height: 100px; border-radius: 10px; background-size: cover; background-position: center; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 32px; }
.pf-banner-preview .avatar.xl { width: 72px; height: 72px; font-size: 24px; border: 4px solid var(--bg-2); margin-bottom: -28px; }
.banner-tabs { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; flex-wrap: wrap; }
.seg { border: 1px solid var(--line); background: transparent; color: var(--text); padding: 5px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.seg.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.banner-colors { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.bc-row { display: flex; align-items: center; gap: 10px; }
.bc-label { width: 60px; font-size: 12px; color: var(--dim); }
.crop-stage.banner { width: 320px; height: 120px; border-radius: 10px; }

/* Settings */
.row-actions { white-space: nowrap; }
.row-actions .mini { margin-left: 4px; }
.mini.danger { color: var(--red, #ed4245); border-color: var(--red, #ed4245); }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0; }
.tag-toggle { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 12px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.tag-toggle.on { color: #fff; }
.tag-create { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.sel { border-color: var(--text); }
.tag-list { display: flex; flex-direction: column; gap: 8px; }
.tag-row { display: flex; align-items: center; gap: 10px; }
.audit-list { display: flex; flex-direction: column; gap: 6px; }
.audit-row { display: flex; gap: 10px; align-items: baseline; padding: 6px 8px; border-radius: 6px; background: var(--bg-1); font-size: 13px; }
.audit-when { color: var(--faint); font-size: 11px; white-space: nowrap; min-width: 130px; }
.audit-text { color: var(--dim); }
.audit-text b { color: var(--text); }
/* ---- Whiteboards ---- */

/* Sidebar entry (pinned above the channel list). */
.wb-nav-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: transparent; color: var(--text); border: none; cursor: pointer;
  padding: 7px 10px; border-radius: 8px; font-size: 14px; font-weight: 600; margin-bottom: 4px;
}
.wb-nav-btn:hover { background: var(--hover); }
.wb-nav-btn.active { background: var(--active, var(--hover)); color: var(--accent); }
.wb-nav-btn .npi { font-size: 15px; }

/* Launcher */
.wb-launcher { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg-2); }
.wb-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.wb-crumbs { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; flex-wrap: wrap; }
.wb-crumb-wrap { display: inline-flex; align-items: center; gap: 4px; }
.wb-crumb { background: transparent; border: none; color: var(--text); font-size: 15px; font-weight: 700; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.wb-crumb:hover { background: var(--hover); }
.wb-sep { color: var(--faint); }
.wb-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-ghost.sm, .btn-primary.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.wb-grid { flex: 1; overflow: auto; padding: 16px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-content: start; }
.wb-card {
  display: flex; flex-direction: column; padding: 0; border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; background: var(--bg-1); cursor: pointer; text-align: left; transition: border-color .12s, transform .08s;
}
.wb-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.wb-thumb { height: 110px; display: flex; align-items: center; justify-content: center; font-size: 34px; color: rgba(255,255,255,.55); }
.wb-folder-thumb { background: linear-gradient(160deg, #2a2f37, #1b1e24); color: #cdd3dc; }
.wb-card-foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.wb-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-dots { color: var(--dim); padding: 0 4px; border-radius: 6px; font-weight: 700; }
.wb-dots:hover { background: var(--hover); color: var(--text); }

.wb-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--dim); }

/* Board view */
.wb-board { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg-2); }
.wb-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.wb-back { background: var(--bg-3); border: none; color: var(--text); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px; }
.wb-back:hover { background: var(--hover); }
.wb-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.wb-peers { display: flex; gap: -6px; align-items: center; }
.wb-peer { display: inline-flex; margin-left: -6px; border-radius: 50%; outline: 2px solid var(--accent); outline-offset: 0; background: var(--bg-2); }
.wb-peer:first-child { margin-left: 0; }

.wb-canvas { position: relative; flex: 1; min-height: 0; }
.wb-canvas .excalidraw { height: 100%; }
.wb-canvas > div { height: 100%; }
.wb-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--dim); font-size: 14px; }
.wb-overlay { position: absolute; inset: 0; background: var(--bg-2); }

/* Keep the Excalidraw editor below our app modals/menus. */
.excalidraw { --zIndex-layerUI: 4; }

@media (max-width: 760px) {
  .wb-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 12px; }
}
/* "Liquid glass" treatments — frosted blur + a bright top rim + soft shadow,
   PLUS true refraction via the #kp-glass SVG displacement filter (defined in
   index.html), the same technique BYD uses. The plain blur is the fallback;
   the url() line adds the warp on browsers that support SVG filters in
   backdrop-filter (Chromium: Chrome/Edge). Firefox/Safari keep just the blur. */

/* =====================================================================
   Global glass buttons — every chrome button across the app is round and
   glassy. Neutral controls get a dark tint; primary actions get the accent
   color; leave/danger get red; the composer Send stays gold (below). Tiny
   inline controls (reactions, message-hover icons, color swatches, context-menu
   rows, the emoji picker) keep their own styles so menus and pickers stay usable. */
.icon-btn, .members-btn, .hamburger, .ws-gear, .add, .add-cat, .notepad-btn,
.wb-nav-btn, .wb-back, .vctrl, .vs-btn, .modal-close, .seg, .tab, .mini,
.theater-fs, .load-older, .dm-empty, .pc-edit, .sc-watch, .vbtn, .tag-toggle,
.btn-ghost, .btn-primary {
  border-radius: 999px;
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: blur(8px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Neutral dark-tinted glass. */
.icon-btn, .members-btn, .hamburger, .ws-gear, .add, .add-cat, .notepad-btn,
.wb-nav-btn, .wb-back, .vctrl, .vs-btn, .modal-close, .seg, .tab, .mini,
.theater-fs, .load-older, .dm-empty, .pc-edit, .vbtn, .tag-toggle, .btn-ghost {
  background: rgba(14, 18, 24, 0.42);
  color: #e8ebf1;
}
.icon-btn:hover, .members-btn:hover, .hamburger:hover, .ws-gear:hover, .add:hover,
.add-cat:hover, .notepad-btn:hover, .wb-nav-btn:hover, .wb-back:hover, .vctrl:hover,
.vs-btn:hover, .modal-close:hover, .seg:hover, .tab:hover, .mini:hover, .theater-fs:hover,
.load-older:hover, .dm-empty:hover, .pc-edit:hover, .vbtn:hover, .tag-toggle:hover, .btn-ghost:hover {
  background: rgba(30, 36, 46, 0.52);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

/* Primary / selected = accent glass (driven by --accent). */
.btn-primary, .seg.on, .tab.active, .tag-toggle.on, .vctrl.on, .vs-btn.on {
  background: color-mix(in srgb, var(--accent) 74%, transparent);
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, #ffffff);
  border-top-color: color-mix(in srgb, var(--accent) 25%, #ffffff);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 34%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, transparent); color: #fff; }

/* Leave / danger = red glass. */
.vctrl.leave, .vs-hang, .mini.danger, .tile-kick {
  border-radius: 999px;
  background: rgba(220, 60, 62, 0.72);
  color: #fff;
  border: 1px solid rgba(255, 175, 175, 0.5);
  border-top-color: rgba(255, 222, 222, 0.85);
  box-shadow: 0 5px 16px rgba(120, 20, 20, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: blur(8px) saturate(1.4);
}
.vctrl.leave:hover, .vs-hang:hover, .mini.danger:hover { background: rgba(237, 76, 78, 0.9); }

.btn-primary:disabled, .btn-ghost:disabled { opacity: 0.55; }

/* =====================================================================
   Floating top info bar that OVERLAYS the message list, so the chat frosts
   and refracts through it as it scrolls behind. Fully pill-shaped, like the
   message bar. Absolutely positioned inside .chat-pane (which sits BELOW the
   voice panel in flow, so they never collide). */
.chat-pane { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main-head {
  position: absolute; top: 10px; left: 14px; right: 14px; z-index: 7;
  height: 52px; padding: 0 22px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.34);
  background: rgba(14, 18, 24, 0.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  backdrop-filter: blur(12px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(10px) saturate(1.5);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
/* Reserve space so content begins below the floating bar. */
.chat-pane .messages { padding-top: 76px; }
.chat-pane .voice-cta { margin-top: 76px; }
.chat-pane .voice-cta + .messages { padding-top: 14px; }
/* Header buttons stay subtle (no nested glass). */
.main-head .icon-btn,
.main-head .members-btn,
.main-head .hamburger {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.main-head .icon-btn:hover,
.main-head .members-btn:hover,
.main-head .hamburger:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
[data-theme='light'] .main-head { background: rgba(255, 255, 255, 0.5); }
[data-theme='light'] .main-head .icon-btn,
[data-theme='light'] .main-head .members-btn,
[data-theme='light'] .main-head .hamburger { background: rgba(0, 0, 0, 0.05); border-color: rgba(0, 0, 0, 0.1); }
@media (max-width: 760px) {
  .main-head { top: 8px; left: 8px; right: 8px; }
  .chat-pane .messages { padding-top: 72px; }
  .chat-pane .voice-cta { margin-top: 72px; }
}

/* Emoji picker opened from a modal (channel-name editor): centered, so it
   escapes the modal's clipped overflow. */
.emoji-popover.center {
  position: fixed; top: 50%; left: 50%; right: auto; bottom: auto;
  transform: translate(-50%, -50%);
}

/* ---- Message field: a rounded, multi-line box that grows with content
   (auto-sized in JS, capped at 200px). ---- */
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 56px;
  max-height: 200px;
  overflow-y: auto;
  border-radius: 22px;
  padding: 15px 22px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  box-sizing: border-box;
  outline: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(10px) saturate(1.5);
  backdrop-filter: blur(10px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(7px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.composer textarea::placeholder { color: rgba(255, 255, 255, 0.55); }
.composer textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  border-top-color: rgba(255, 255, 255, 0.5);
}

[data-theme='light'] .composer textarea {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-top-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
[data-theme='light'] .composer textarea::placeholder { color: rgba(20, 22, 27, 0.5); }

/* ---- Round, glassy controls around the field; buttons sit at the bottom so
   they stay aligned with the last line as the box grows. ---- */
.composer { align-items: flex-end; }
.composer .send { border-radius: 999px; height: 56px; padding: 0 26px; }
.composer .gif-btn { border-radius: 999px; height: 56px; padding: 0 20px; }
.composer .attach-btn,
.composer .emoji-btn {
  width: 56px; min-width: 56px; height: 56px; flex: 0 0 56px; padding: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.composer .attach-btn,
.composer .emoji-btn,
.composer .gif-btn,
.composer .send {
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: url(#kp-glass) blur(7px) saturate(1.4);
}
.composer .attach-btn,
.composer .emoji-btn,
.composer .gif-btn {
  background: rgba(14, 18, 24, 0.42);
  color: #e8ebf1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.34);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.composer .attach-btn:hover,
.composer .emoji-btn:hover,
.composer .gif-btn:hover {
  background: rgba(30, 36, 46, 0.5);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}
/* Golden glass Send with dark text — no outer glow. */
.composer .send {
  background: rgba(240, 192, 64, 0.74);
  color: #241b00;
  font-weight: 700;
  border: 1px solid rgba(255, 226, 140, 0.6);
  border-top-color: rgba(255, 248, 214, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.composer .send:hover { background: rgba(248, 206, 88, 0.86); color: #241b00; }
.composer .send:disabled { opacity: 0.55; }

@media (max-width: 760px) {
  .composer .send, .composer .gif-btn { height: 48px; }
  .composer textarea { min-height: 48px; padding: 12px 18px; }
  .composer .attach-btn, .composer .emoji-btn { width: 48px; min-width: 48px; height: 48px; flex-basis: 48px; }
}

/* ---- Float the composer over the message list so chat content frosts AND
   refracts through the glass input as it scrolls behind it. ---- */
.main .messages { padding-bottom: 94px; }
.composer-dock { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; pointer-events: none; }
.composer-dock > * { pointer-events: auto; }
@media (max-width: 760px) { .main .messages { padding-bottom: 80px; } }

/* ---- Profile card: frosted glass tinted by the user's own gradient colors
   (--c1/--c2), with the same refraction warping the chat behind it. ---- */
.profile-card.themed {
  background: linear-gradient(165deg,
    color-mix(in srgb, var(--c1, #14b8a6) 58%, transparent),
    color-mix(in srgb, var(--c2, #3b82f6) 58%, transparent));
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(18px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* =====================================================================
   Modal / dialog windows (Create channel, New message, Workspace settings,
   etc.) — dark-tinted liquid glass that frosts and refracts the app behind.
   The scrim is softened so the refraction stays visible. */
.overlay {
  background: rgba(8, 9, 11, 0.5);
}
.modal {
  background: rgba(16, 20, 27, 0.62);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(16px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top-color: rgba(255, 255, 255, 0.26);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
/* The wiz footer sits OUTSIDE the padded .modal-body, so its buttons were
   flush against the modal edges. Inset them to match the body's padding. */
.modal .wiz-foot { padding: 0 22px 22px; }

/* Light theme: a bright frosted panel instead of the dark tint. */
[data-theme='light'] .overlay { background: rgba(18, 22, 30, 0.34); }
[data-theme='light'] .modal {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-top-color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
/* Loaded LAST so these rules win over styles.css and features.css. */

/* Right-aligned modal footer (fixes the odd Cancel/Save spacing). */
.wiz-foot.end { justify-content: flex-end; gap: 10px; }

/* Mobile nav toggles — hidden on desktop. */
.hamburger { display: none; width: 32px; height: 32px; border-radius: 6px; align-items: center; justify-content: center; font-size: 18px; color: var(--dim); margin-right: 4px; flex-shrink: 0; }
.hamburger:hover { background: var(--hover); color: var(--text); }
.members-btn { display: none; width: 32px; height: 32px; border-radius: 6px; align-items: center; justify-content: center; font-size: 15px; color: var(--dim); flex-shrink: 0; }
.members-btn:hover { background: var(--hover); color: var(--text); }
.nav-backdrop, .right-backdrop { display: none; }

/* Emoji board container hugs the picker (emoji-mart renders a fixed width), and
   never overflows a narrow viewport. */
.emoji-popover { width: max-content; max-width: min(360px, calc(100vw - 16px)); }

/* Floating "jump to newest" button (Slack/Discord style). */
.main { position: relative; }
.jump-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 80px; z-index: 50; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.4); cursor: pointer; }
.jump-bottom:hover { filter: brightness(1.08); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr !important; }

  /* Left channel sidebar slides in. The `display:flex !important` overrides the
     old `.sidebar { display:none }` mobile rule in styles.css that was hiding it. */
  .sidebar {
    display: flex !important;
    position: fixed; left: 0; top: 0; bottom: 0; width: 84vw; max-width: 300px; z-index: 120;
    transform: translateX(-102%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 50px rgba(0,0,0,.6); }

  /* Right members panel slides in from the right (toggled by the 👥 button). */
  .right {
    display: flex !important;
    position: fixed; right: 0; top: 0; bottom: 0; width: 78vw; max-width: 280px; z-index: 120;
    transform: translateX(102%); transition: transform .2s ease;
  }
  .right.open { transform: translateX(0); box-shadow: 0 0 50px rgba(0,0,0,.6); }

  .hamburger, .members-btn { display: flex; }
  .nav-backdrop, .right-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 110; }

  .modal { max-width: 100% !important; max-height: 92vh; }
  .att-image, .att-video, .gif-embed { max-width: 100%; }
  .messages { padding: 12px 0; }
  .composer, .composer-readonly { margin: 0; }
  .composer { padding: 0 10px 12px; gap: 6px; }
  .composer .send { padding: 0 14px; }
  .gif-btn { padding: 0 9px; }

  .main-head { padding: 0 10px; }
  .main-head .topic { display: none; }
  .main-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .head-actions { gap: 0; }

  .giphy-grid { columns: 2; }
  .emoji-popover { left: 8px; right: auto; }

  .voice-cta { flex-wrap: wrap; }
  .voice-cta .btn-primary { margin-left: 0; }
  .voice-dock.expanded { max-height: 52vh; }

  /* Profile card fits narrow screens. */
  .profile-card { width: calc(100vw - 24px) !important; max-width: 340px; }
}

/* Avatar crop */
.crop-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.crop-stage { width: 280px; height: 280px; border-radius: 50%; overflow: hidden; background: #000; cursor: grab; touch-action: none; box-shadow: 0 0 0 4px var(--bg-3); }
.crop-stage:active { cursor: grabbing; }
.crop-stage canvas { display: block; }
.crop-controls { width: 280px; max-width: 100%; }

.theme-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
/* Font Awesome icon alignment. Icons are rendered as <i class="fa-solid fa-…">
   inside buttons and inline labels that previously held emoji. These rules keep
   them centered, inheriting the button's color, and sized consistently. */
.fa-solid, .fa-regular, .fa-brands, i.fa, i[class*="fa-"] {
  line-height: 1;
  vertical-align: -0.05em;
}

/* Inline icons that sit before a text label (sidebar buttons, menu rows, voice
   strip, chips) get a touch of trailing space. */
.npi.fa-solid, .vs-chan .fa-solid, .ctx-ic { margin-right: 2px; }

/* Context-menu leading icon: fixed-width so labels line up. */
.ctx-ic { display: inline-block; width: 18px; text-align: center; font-size: 13px; opacity: 0.92; }

/* Channel-list and header type glyphs render at a comfortable size. */
.hash .fa-solid { font-size: 0.82em; }
/* Full-screen image viewer (Discord-style). The photo is centered and scaled to
   fit the window with ~130px of breathing room on every side; the glass control
   pill floats 50px below the picture. The backdrop tints to the active theme
   (--lb-backdrop): dark on dark themes, medium gray on the light theme. */
.lb-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--lb-backdrop, rgba(8, 10, 14, 0.95));
  display: flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* Shrink-wraps the image so the toolbar can anchor to the picture's edges. */
.lb-stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
}

/* Scaled to fit inside the viewport minus 130px on each side, aspect preserved
   (never upscaled past natural size). */
.lb-img {
  display: block;
  max-width: calc(100vw - 260px);
  max-height: calc(100vh - 260px);
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.55);
  transform-origin: center center;
  transition: transform 0.18s ease;
  user-select: none;
}

/* Toolbar — a big pill of liquid glass, centered 50px under the photo. */
.lb-bar {
  position: absolute; z-index: 2;
  top: calc(100% + 50px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(14, 18, 24, 0.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(14px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255, 255, 255, 0.36);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.lb-btn {
  width: 50px; height: 50px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #e8ebf1; font-size: 20px; background: transparent; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.lb-more-wrap { position: relative; display: inline-flex; }

/* "More" menu pops up above the ⋯ button. */
.lb-menu {
  position: absolute; bottom: calc(100% + 14px); right: 0; min-width: 196px;
  background: #1c2027; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px;
  padding: 6px; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55); z-index: 3;
}
.lb-mi {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 11px; border-radius: 8px; color: #e8ebf1; font-size: 13.5px; cursor: pointer;
}
.lb-mi:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.lb-mi i { width: 16px; text-align: center; opacity: 0.9; }
.lb-sep { height: 1px; background: rgba(255, 255, 255, 0.1); margin: 5px 4px; }

/* Details card floats above the toolbar. */
.lb-details {
  position: absolute; bottom: calc(100% + 14px); left: 50%; transform: translateX(-50%);
  width: 290px; max-width: 86vw;
  background: #1c2027; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px;
  padding: 11px 13px; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55); z-index: 3;
}
.lb-d-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: #fff; font-size: 13px; }
.lb-d-head button { color: var(--faint, #9aa3af); width: 22px; height: 22px; border-radius: 6px; }
.lb-d-head button:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.lb-d-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 12px; color: #9aa3af; }
.lb-d-row b { color: #e8ebf1; font-weight: 600; max-width: 175px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tiny confirmation toast (e.g. "Image copied"). */
.lb-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 310;
  background: #1c2027; border: 1px solid rgba(255, 255, 255, 0.14); color: #fff;
  padding: 9px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Tighter on small screens — 130px padding would leave no photo. */
@media (max-width: 760px) {
  .lb-img { max-width: calc(100vw - 32px); max-height: calc(100vh - 180px); }
  .lb-bar { top: calc(100% + 28px); gap: 4px; padding: 7px 9px; }
  .lb-btn { width: 44px; height: 44px; font-size: 18px; }
}
