/* ================================================================ Social Hub — styles
 * Themes are just token sets on <html data-theme>. Accent, text size and roundness come from
 * theme.js as CSS variables, so every customization is instant and costs nothing at runtime.
 */
:root {
  --accent: #5b8cff;
  --on-accent: #fff;
  --fs: 14px;
  --radius: 10px;
  --stage-h: 52vh;
  --green: #3ecf8e;
  --red: #f05462;
  --yellow: #f2c14e;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, ui-monospace, monospace;

  --accent-hover: color-mix(in srgb, var(--accent) 84%, white);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 65%, var(--text));
  --r: var(--radius);
  --r-sm: calc(var(--radius) * .6);
  --r-lg: calc(var(--radius) * 1.4);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- themes ---------- */
:root, [data-theme="midnight"] {
  --bg0: #0b0d11; --bg-side: #12141a; --bg-main: #171a21; --bg-elev: #1f232c; --bg-hover: #232835; --bg-active: #2a3040;
  --line: #262b36; --line-2: #313747; --text: #e8eaf0; --text-2: #9aa1b2; --text-3: #6b7285;
  --stage-bg: #0a0b0f; --shadow: 0 10px 40px rgba(0,0,0,.5); --code-bg: #0f1116; color-scheme: dark;
}
[data-theme="graphite"] {
  --bg0: #0c0c0d; --bg-side: #141416; --bg-main: #1a1a1d; --bg-elev: #222226; --bg-hover: #27272c; --bg-active: #303036;
  --line: #2a2a2f; --line-2: #36363c; --text: #ececee; --text-2: #a0a0a8; --text-3: #6e6e77;
  --stage-bg: #0a0a0b; --shadow: 0 10px 40px rgba(0,0,0,.55); --code-bg: #111113; color-scheme: dark;
}
[data-theme="oled"] {
  --bg0: #000; --bg-side: #000; --bg-main: #050505; --bg-elev: #111; --bg-hover: #151515; --bg-active: #1e1e1e;
  --line: #1c1c1c; --line-2: #2a2a2a; --text: #f0f0f0; --text-2: #9a9a9a; --text-3: #666;
  --stage-bg: #000; --shadow: 0 10px 40px rgba(0,0,0,.8); --code-bg: #0b0b0b; color-scheme: dark;
}
[data-theme="dusk"] {
  --bg0: #0d0b13; --bg-side: #15121e; --bg-main: #1a1625; --bg-elev: #231e31; --bg-hover: #2a2439; --bg-active: #332b46;
  --line: #2a2438; --line-2: #3a3150; --text: #ece8f5; --text-2: #a49cb8; --text-3: #73698a;
  --stage-bg: #0a0810; --shadow: 0 10px 40px rgba(0,0,0,.55); --code-bg: #110e18; color-scheme: dark;
}
[data-theme="forest"] {
  --bg0: #090d0c; --bg-side: #101614; --bg-main: #141c19; --bg-elev: #1b2522; --bg-hover: #212d29; --bg-active: #283732;
  --line: #22302b; --line-2: #2e3f39; --text: #e6eeeb; --text-2: #96a8a1; --text-3: #667a73;
  --stage-bg: #070a09; --shadow: 0 10px 40px rgba(0,0,0,.55); --code-bg: #0c1210; color-scheme: dark;
}
[data-theme="light"] {
  --bg0: #e4e7ed; --bg-side: #f1f3f7; --bg-main: #ffffff; --bg-elev: #f1f3f7; --bg-hover: #e9ecf2; --bg-active: #dfe3ec;
  --line: #e1e4ea; --line-2: #cfd4de; --text: #1b1f29; --text-2: #5d6576; --text-3: #8a91a1;
  --stage-bg: #1a1d24; --shadow: 0 10px 40px rgba(20,30,60,.18); --code-bg: #f4f5f8; color-scheme: light;
  --accent-text: color-mix(in srgb, var(--accent) 80%, black);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg0); color: var(--text);
  font: var(--fs)/1.5 var(--font); -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: .86em; }
.spacer { flex: 1; }
.error { color: var(--red); min-height: 1.3em; font-size: .93em; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-btn svg, .ctl svg, .send-btn svg { pointer-events: none; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { transition: none !important; animation: none !important; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--bg-elev); border-radius: var(--r-sm);
  padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: .93em;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.danger-soft { background: color-mix(in srgb, var(--red) 14%, transparent); border-color: transparent; color: var(--red); }
.btn.danger-soft:hover { background: color-mix(in srgb, var(--red) 24%, transparent); }
.btn.lg { padding: 11px 16px; font-size: 1em; }
.btn:disabled { opacity: .6; cursor: default; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0;
  border-radius: var(--r-sm); background: transparent; color: var(--text-2); cursor: pointer; flex: none;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.off, .icon-btn.danger { color: var(--red); }
.icon-btn.active { color: var(--accent-text); background: var(--accent-soft); }

input, select, textarea {
  background: var(--bg-main); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
[data-theme="light"] input, [data-theme="light"] select { background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=range] { padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--accent); height: 22px; }
.field { display: grid; gap: 6px; font-size: .86em; font-weight: 600; color: var(--text-2); }
.field input, .field select { font-weight: 400; font-size: 1.08em; color: var(--text); }
.field-row { display: flex; justify-content: space-between; }
.field .val { font-weight: 500; color: var(--text-3); }
.field-label { font-size: .78em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-top: 6px; }

/* switch: <label class="switch"><input type=checkbox><span></span> Text <small>hint</small></label> */
.switch { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; cursor: pointer; padding: 6px 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { grid-row: span 2; width: 38px; height: 22px; border-radius: 11px; background: var(--bg-active); position: relative; transition: background .18s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .18s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch small { grid-column: 2; color: var(--text-3); font-size: .86em; }

.seg { display: inline-flex; background: var(--bg-main); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 3px; gap: 3px; justify-self: start; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: calc(var(--r-sm) - 2px); cursor: pointer; color: var(--text-2); font-weight: 600; font-size: .93em; }
.seg button.on { background: var(--accent); color: var(--on-accent); }

/* ---------- login ---------- */
.login { position: relative; height: 100%; display: grid; place-items: safe center; padding: 16px; overflow-x: hidden; overflow-y: auto; background: var(--bg0); }
.login-glow {
  position: fixed; inset: -30%; pointer-events: none;
  background:
    radial-gradient(40% 35% at 30% 30%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%),
    radial-gradient(35% 30% at 75% 70%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%);
  filter: blur(20px); animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(4%, -3%) scale(1.05); } }
.login-card {
  position: relative; width: min(400px, 100%); background: color-mix(in srgb, var(--bg-main) 88%, transparent);
  backdrop-filter: blur(14px); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); padding: 32px; display: grid; gap: 14px; box-shadow: var(--shadow);
  animation: rise .35s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.login-logo { width: 60px; height: 60px; filter: drop-shadow(0 6px 18px var(--accent-soft)); }
.login-card h1 { margin: 0; font-size: 1.75em; letter-spacing: -.01em; }
.login-card p { margin: -6px 0 6px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr) 236px; height: 100%; }
.app.no-members { grid-template-columns: 252px minmax(0, 1fr); }
.app.no-members .members { display: none; }
.scrim { display: none; }

.sidebar { background: var(--bg-side); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.hub-head { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 10px 0 14px; border-bottom: 1px solid var(--line); flex: none; }
.hub-logo { width: 26px; height: 26px; }
.hub-name { flex: 1; font-weight: 700; font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.005em; }
.side-scroll { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.section-label { text-transform: uppercase; font-size: .76em; font-weight: 700; letter-spacing: .07em; color: var(--text-3); padding: 14px 8px 6px; }
.chan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.chan {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer; user-select: none; position: relative;
  transition: background .12s, color .12s;
}
.chan:hover { background: var(--bg-hover); color: var(--text); }
.chan.active { background: var(--bg-active); color: var(--text); }
.chan.unread { color: var(--text); font-weight: 650; }
.chan.unread::before { content: ""; position: absolute; left: -8px; top: 50%; width: 4px; height: 8px; margin-top: -4px; border-radius: 0 4px 4px 0; background: var(--text); }
.chan svg { width: 18px; height: 18px; opacity: .8; }
.chan .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan .count { font-size: .78em; color: var(--text-3); font-weight: 600; }
.badge { background: var(--red); color: #fff; font-size: .76em; font-weight: 700; border-radius: 9px; padding: 0 6px; min-width: 18px; line-height: 18px; text-align: center; }
.voice-members { list-style: none; margin: 2px 0 6px; padding: 0 0 0 22px; display: grid; gap: 1px; }
.vm { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: .93em; color: var(--text-2); border-radius: var(--r-sm); }
.vm:hover { background: var(--bg-hover); }
.vm .avatar { width: 22px; height: 22px; font-size: .72em; }
.vm .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm svg { width: 14px; height: 14px; }
.vm .ico-off { color: var(--red); display: inline-flex; }
.live { background: var(--red); color: #fff; font-size: .68em; font-weight: 800; letter-spacing: .04em; border-radius: 4px; padding: 0 5px; line-height: 16px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; color: #fff; text-transform: uppercase; user-select: none;
  box-shadow: 0 0 0 2px transparent; transition: box-shadow .12s;
}
.avatar.xl { width: 64px; height: 64px; font-size: 1.7em; }
.speaking .avatar, .avatar.speaking { box-shadow: 0 0 0 2px var(--bg-side), 0 0 0 4px var(--green); }

.voice-status {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 8px 8px; padding: 10px 12px; border-radius: var(--r);
  background: color-mix(in srgb, var(--green) 9%, var(--bg-elev)); border: 1px solid color-mix(in srgb, var(--green) 22%, transparent);
}
.vs-info { min-width: 0; }
.vs-title { color: var(--green); font-weight: 700; font-size: .93em; display: flex; align-items: center; gap: 7px; }
.vs-room { font-size: .86em; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; box-shadow: 0 0 0 0 var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
.me-panel { display: flex; align-items: center; gap: 2px; padding: 8px; background: var(--bg0); border-top: 1px solid var(--line); flex: none; }
[data-theme="light"] .me-panel { background: var(--bg-active); }
.me-panel .avatar { width: 34px; height: 34px; font-size: .93em; margin-right: 6px; position: relative; }
.me-panel .avatar::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 2.5px solid var(--bg0); }
.me-text { flex: 1; min-width: 0; line-height: 1.2; }
.me-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { font-size: .8em; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-main); }
.topbar { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); flex: none; box-shadow: 0 1px 0 rgba(0,0,0,.05); }
.chan-title { font-weight: 700; font-size: 1.05em; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.chan-title svg { color: var(--text-3); }
.chan-sub { color: var(--text-3); font-size: .9em; padding-left: 10px; margin-left: 4px; border-left: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-only { display: none; }

/* ---------- call stage ---------- */
.stage { height: var(--stage-h); min-height: 180px; display: flex; flex-direction: column; background: var(--stage-bg); flex: none; position: relative; }
.stage.expanded { flex: 1; height: auto; }
.stage.expanded ~ .resizer, .stage.expanded ~ .chat { display: none; }
.tiles {
  flex: 1; min-height: 0; display: grid; gap: 10px; padding: 12px 12px 0;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}
.tiles.has-focus { grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.tiles.has-focus .tile:not(.focus) { display: none; }
.tile {
  position: relative; background: #1b1e26; border-radius: var(--r); overflow: hidden;
  display: grid; place-items: center; min-height: 0; cursor: pointer;
  box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .12s;
  animation: pop .25s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .12s; pointer-events: none; }
.tile.speaking::after { box-shadow: inset 0 0 0 3px var(--green); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: none; }
.tile.cam video { object-fit: cover; }
.tile.mirror video { transform: scaleX(-1); }
.tile.has-video video { display: block; }
.tile.has-video .tile-avatar { display: none; }
.tile-avatar.avatar { width: 84px; height: 84px; font-size: 2.2em; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.tile.speaking .tile-avatar { box-shadow: 0 0 0 3px #1b1e26, 0 0 0 6px var(--green); }
.tile-label {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 5px; color: #fff;
  background: rgba(10,12,16,.65); backdrop-filter: blur(6px); padding: 3px 9px; border-radius: var(--r-sm); font-size: .86em; font-weight: 600; max-width: calc(100% - 20px);
}
.tile-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-label svg { width: 14px; height: 14px; color: var(--red); }
.tile-tools {
  position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; align-items: center; color: #fff;
  background: rgba(10,12,16,.65); backdrop-filter: blur(6px); border-radius: var(--r-sm); padding: 4px 6px; opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-tools { opacity: 1; }
.tile-tools input[type=range] { width: 90px; }
.tile-tools .icon-btn { width: 26px; height: 26px; color: #fff; }
.tile-tools .icon-btn:hover { background: rgba(255,255,255,.12); }
.tile-tools svg { width: 16px; height: 16px; }
.tile-state { position: absolute; top: 10px; left: 10px; font-size: .78em; font-weight: 600; color: var(--yellow); background: rgba(10,12,16,.7); padding: 2px 8px; border-radius: 5px; }
.tile:fullscreen { border-radius: 0; }

.call-bar { display: flex; justify-content: center; padding: 10px; flex: none; }
.call-pill { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 999px; background: rgba(28,31,40,.85); border: 1px solid rgba(255,255,255,.06); backdrop-filter: blur(8px); flex-wrap: wrap; justify-content: center; }
.ctl {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: #2b303c; color: #e8eaf0;
  display: grid; place-items: center; cursor: pointer; transition: background .15s, transform .08s;
}
.ctl:hover { background: #363c4b; }
.ctl:active { transform: scale(.95); }
.ctl.on { background: var(--accent); color: var(--on-accent); }
.ctl.off { background: color-mix(in srgb, var(--red) 22%, #2b303c); color: #ff8a94; }
.ctl.danger { background: var(--red); color: #fff; width: 56px; border-radius: 22px; }
.ctl.danger:hover { background: color-mix(in srgb, var(--red) 85%, white); }
.quality { padding: 7px 10px; font-size: .86em; border-radius: 999px; background: #2b303c; border-color: transparent; color: #e8eaf0; }
.resizer { height: 5px; cursor: row-resize; background: var(--line); flex: none; transition: background .15s; }
.resizer:hover { background: var(--accent); }

/* ---------- chat ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat.drag::after {
  content: "Drop to upload"; position: absolute; inset: 10px; border: 2px dashed var(--accent);
  border-radius: var(--r-lg); display: grid; place-items: center; background: color-mix(in srgb, var(--bg-main) 88%, transparent);
  font-size: 1.3em; font-weight: 700; color: var(--accent-text); z-index: 5;
}
.messages { flex: 1; overflow-y: auto; padding: 8px 0 6px; overflow-anchor: none; }
.msg { display: flex; gap: 14px; padding: 6px 18px 4px; margin-top: 10px; position: relative; transition: background .08s; }
.msg:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.msg.cont { margin-top: 0; padding-top: 1px; padding-bottom: 1px; }
.msg .gutter { width: 40px; flex: none; display: flex; justify-content: center; }
.msg .gutter .avatar { width: 40px; height: 40px; }
.msg.cont .gutter .avatar { display: none; }
.hover-time { display: none; font-size: .72em; color: var(--text-3); line-height: 1.9; white-space: nowrap; }
.msg.cont:hover .hover-time { display: block; }
.msg.mentioned { background: color-mix(in srgb, var(--yellow) 8%, transparent); }
.msg.mentioned::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--yellow); }
.msg .body { min-width: 0; flex: 1; }
.meta { display: flex; align-items: baseline; gap: 8px; }
.msg.cont .meta { display: none; }
.author { font-weight: 700; }
.time { font-size: .78em; color: var(--text-3); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.text a { color: var(--accent-text); text-decoration: none; }
.text a:hover { text-decoration: underline; }
.text code { background: var(--code-bg); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; font: .9em/1.4 var(--mono); }
.text pre { background: var(--code-bg); border: 1px solid var(--line); padding: 10px 12px; border-radius: var(--r-sm); overflow-x: auto; font: .9em/1.5 var(--mono); margin: 6px 0; white-space: pre; }
.mention { background: var(--accent-soft); color: var(--accent-text); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.mention.me { background: color-mix(in srgb, var(--yellow) 22%, transparent); color: color-mix(in srgb, var(--yellow) 70%, var(--text)); }
.attach { margin-top: 6px; }
.attach img, .attach video { max-width: min(440px, 100%); max-height: 340px; border-radius: var(--r-sm); display: block; cursor: zoom-in; background: var(--bg-elev); border: 1px solid var(--line); }
.attach video { cursor: auto; }
.file-chip { display: inline-flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-elev); border: 1px solid var(--line-2); border-radius: var(--r); color: var(--text); text-decoration: none; max-width: min(420px, 100%); transition: border-color .15s; }
.file-chip:hover { border-color: var(--accent); }
.file-chip > svg { width: 28px; height: 28px; color: var(--accent-text); }
.file-chip .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-actions {
  position: absolute; right: 16px; top: -14px; display: flex; gap: 2px; padding: 2px;
  background: var(--bg-elev); border: 1px solid var(--line-2); border-radius: var(--r-sm); box-shadow: 0 4px 14px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .1s; z-index: 2;
}
.msg.cont .msg-actions { top: -16px; }
.msg:hover .msg-actions { opacity: 1; pointer-events: auto; }
.msg-actions .icon-btn { width: 28px; height: 28px; }
.msg-actions svg { width: 16px; height: 16px; }
.msg-actions .armed { color: #fff; background: var(--red); }
.day { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: .78em; font-weight: 700; margin: 18px 18px 4px; }
.day::before, .day::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.load-more { text-align: center; color: var(--text-3); font-size: .86em; padding: 8px; }
.empty { padding: 40px 18px 12px; }
.empty .empty-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-elev); color: var(--text-2); margin-bottom: 14px; }
.empty .empty-icon svg { width: 30px; height: 30px; }
.empty h3 { margin: 0 0 4px; font-size: 1.6em; letter-spacing: -.01em; }
.empty p { margin: 0; color: var(--text-2); }
.typing { height: 22px; padding: 0 18px; font-size: .82em; color: var(--text-2); flex: none; display: flex; align-items: center; gap: 6px; }
.typing:not(:empty)::before { content: ""; width: 22px; height: 6px; background: radial-gradient(circle 3px, var(--text-2) 95%, transparent) 0 50% / 8px 6px repeat-x; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.composer {
  display: flex; align-items: flex-end; gap: 6px; margin: 0 16px 16px; padding: 6px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-lg); flex: none;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { flex: 1; resize: none; border: 0; background: transparent; padding: 7px 4px; max-height: 200px; box-shadow: none !important; line-height: 1.45; outline: none; }
.composer textarea:focus, .composer textarea:focus-visible { border: 0; outline: none; }
.composer .icon-btn { width: 36px; height: 36px; }
.send-btn { width: 36px; height: 36px; border-radius: var(--r-sm); border: 0; display: grid; place-items: center; cursor: pointer; background: var(--accent); color: var(--on-accent); transition: background .15s, opacity .15s, transform .08s; }
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: scale(.94); }
.send-btn svg { width: 18px; height: 18px; }
.composer.empty-input .send-btn { opacity: .45; }

/* ---------- members ---------- */
.members { background: var(--bg-side); border-left: 1px solid var(--line); overflow-y: auto; padding: 8px 8px 16px; }
.member-group { margin-bottom: 4px; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); transition: background .12s; }
.member:hover { background: var(--bg-hover); }
.member .avatar { width: 32px; height: 32px; font-size: .93em; position: relative; }
.member .avatar::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); border: 2.5px solid var(--bg-side); }
.member .info { min-width: 0; line-height: 1.25; }
.member .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.member .sub { font-size: .8em; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.member .sub svg { width: 12px; height: 12px; }
.member .you { color: var(--text-3); font-weight: 500; }

/* ---------- modals ---------- */
.modal {
  background: var(--bg-main); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  padding: 0; box-shadow: var(--shadow); max-height: calc(100% - 32px);
}
.modal[open] { animation: rise .22s var(--ease); }
.modal::backdrop { background: rgba(5,6,10,.62); backdrop-filter: blur(3px); }
.modal h2 { margin: 0 0 4px; font-size: 1.3em; letter-spacing: -.01em; }
.modal .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.modal-x { position: absolute; right: 12px; top: 12px; }

.settings { width: min(780px, calc(100% - 32px)); height: min(600px, calc(100% - 32px)); }
.settings-wrap { display: grid; grid-template-columns: 200px 1fr; height: 100%; position: relative; }
.tabs { background: var(--bg-side); padding: 20px 10px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); }
.tabs-title { font-size: .76em; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); padding: 0 10px 8px; }
.tab { text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; color: var(--text-2); font-weight: 600; }
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.active { background: var(--bg-active); color: var(--text); }
.panes { overflow-y: auto; padding: 24px 28px; }
.pane { display: grid; gap: 14px; align-content: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.theme-card { border: 2px solid var(--line-2); border-radius: var(--r); padding: 0; overflow: hidden; cursor: pointer; background: none; text-align: left; transition: border-color .15s, transform .1s; }
.theme-card:hover { transform: translateY(-1px); }
.theme-card.on { border-color: var(--accent); }
.theme-card .prev { height: 56px; display: grid; grid-template-columns: 26% 1fr; }
.theme-card .prev i { display: block; }
.theme-card .prev b { display: block; position: relative; }
.theme-card .prev b::before, .theme-card .prev b::after { content: ""; position: absolute; left: 10%; height: 6px; border-radius: 3px; background: currentColor; opacity: .35; }
.theme-card .prev b::before { top: 16px; width: 60%; }
.theme-card .prev b::after { top: 30px; width: 40%; background: var(--accent); opacity: 1; }
.theme-card .tname { display: block; padding: 6px 9px; font-size: .86em; font-weight: 600; background: var(--bg-elev); color: var(--text); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer; position: relative; transition: transform .1s; }
.swatch:hover { transform: scale(1.08); }
.swatch.on { box-shadow: 0 0 0 2px var(--bg-main), 0 0 0 4px var(--text); }
.swatch.custom { background: conic-gradient(#f43f5e, #f97316, #eab308, #22c55e, #06b6d4, #5b8cff, #8b5cf6, #d946ef, #f43f5e); overflow: hidden; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; border: 0; }
.account-card { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--bg-elev); border-radius: var(--r); border: 1px solid var(--line); }
.acc-name { font-size: 1.2em; font-weight: 700; }
.kbd-list { display: grid; gap: 8px; color: var(--text-2); }
kbd { display: inline-block; min-width: 22px; text-align: center; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--bg-elev); font: .82em var(--font); font-weight: 700; color: var(--text); }

.invite { width: min(500px, calc(100% - 32px)); }
.invite-wrap { padding: 24px; display: grid; gap: 12px; }
.invite-wrap p { margin: 0 0 4px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: .93em; }

/* ---------- misc ---------- */
.banner { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: var(--yellow); color: #1d1a10; font-weight: 700; padding: 7px 16px; border-radius: 999px; z-index: 50; box-shadow: var(--shadow); font-size: .93em; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--bg-elev); border: 1px solid var(--line-2); padding: 11px 15px; border-radius: var(--r); max-width: 360px; box-shadow: var(--shadow); animation: slide .25s var(--ease); font-size: .93em; }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(4,5,8,.88); display: grid; place-items: center; padding: 40px; cursor: zoom-out; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.lightbox img { max-width: 100%; max-height: calc(100vh - 120px); border-radius: var(--r-sm); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lightbox .btn { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--line-2); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- compact density ---------- */
[data-density="compact"] .msg { margin-top: 0; padding: 2px 18px; gap: 8px; }
[data-density="compact"] .msg .gutter { width: auto; min-width: 58px; justify-content: flex-start; }
[data-density="compact"] .msg .gutter .avatar { display: none; }
[data-density="compact"] .hover-time, [data-density="compact"] .msg.cont:hover .hover-time { display: block; }
[data-density="compact"] .msg .meta .time { display: none; }
[data-density="compact"] .msg.cont .meta, [data-density="compact"] .msg .meta { display: inline; margin-right: 6px; }
[data-density="compact"] .msg .text { display: inline; }
[data-density="compact"] .msg-actions { top: -12px; }
[data-density="compact"] .day { margin-top: 10px; }

/* ---------- small screens ---------- */
@media (max-width: 1000px) {
  .app, .app.no-members { grid-template-columns: 236px minmax(0, 1fr); }
  .members { display: none; }
  .app.show-members .members { display: block; position: fixed; right: 0; top: 52px; bottom: 0; width: 250px; z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 720px) {
  .app, .app.no-members { grid-template-columns: minmax(0, 1fr); }
  .mobile-only { display: inline-grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 40; transform: translateX(-100%); transition: transform .22s var(--ease); }
  .app.show-side .sidebar { transform: none; box-shadow: var(--shadow); }
  .app.show-side .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .chan-sub { display: none; }
  .msg { padding-left: 12px; padding-right: 12px; }
  .composer { margin: 0 8px 8px; }
  .tile-tools { opacity: 1; }
  .settings-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .tabs { flex-direction: row; overflow-x: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .tabs-title { display: none; }
  .tab { white-space: nowrap; }
  .panes { padding: 18px 16px; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- onboarding, approvals, devices (v2) ---------- */
.ob { gap: 12px; }
.ob-choice {
  display: grid; gap: 2px; text-align: left; width: 100%; padding: 13px 15px; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--line-2); border-radius: var(--r); color: var(--text);
  transition: border-color .15s, background .15s, transform .08s;
}
.ob-choice:hover { border-color: var(--accent); background: var(--bg-hover); }
.ob-choice:active { transform: translateY(1px); }
.ob-choice b { font-size: 1.02em; }
.ob-choice span { color: var(--text-2); font-size: .88em; }
.ob-link, .ob-back { background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 4px 0; font-size: .9em; justify-self: start; }
.ob-link { justify-self: center; text-decoration: underline; text-underline-offset: 3px; }
.ob-link:hover, .ob-back:hover { color: var(--text); }
.sas { background: var(--bg-elev); border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px; text-align: center; }
.sas-label { font-size: .78em; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); }
.sas-code { font: 700 2.4em/1.2 var(--mono); letter-spacing: .08em; color: var(--accent-text); margin-top: 4px; }
.sas-code.small-code { font-size: 1.25em; letter-spacing: .04em; word-break: break-all; }
.warn { color: color-mix(in srgb, var(--yellow) 80%, var(--text)); margin: 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .9s linear infinite; justify-self: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.mono { font-family: var(--mono); }
.text.locked { color: var(--text-3); font-style: italic; }
.media-wait { display: inline-grid; place-items: center; width: 220px; height: 120px; border-radius: var(--r-sm); background: var(--bg-elev); border: 1px dashed var(--line-2); color: var(--text-3); font-size: .86em; }
button.file-chip { font: inherit; cursor: pointer; text-align: left; }
.member.offline { opacity: .45; }
.member.offline .avatar::after { background: var(--text-3); }
.sec-card { display: grid; gap: 10px; padding: 14px; border-radius: var(--r); background: color-mix(in srgb, var(--green) 7%, var(--bg-elev)); border: 1px solid color-mix(in srgb, var(--green) 20%, transparent); }
.sec-row { display: flex; gap: 10px; align-items: flex-start; }
.sec-ok { color: var(--green); font-weight: 800; line-height: 1.5; }
.dev-list { display: grid; gap: 10px; }
.dev-user { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 6px; background: var(--bg-elev); }
.dev-head { display: flex; align-items: center; gap: 10px; }
.dev-head .avatar { width: 28px; height: 28px; font-size: .8em; }
.dev-row { display: flex; align-items: center; gap: 10px; padding: 6px 0 6px 38px; border-top: 1px solid var(--line); }
.dev-list > .dev-row { padding-left: 0; }
.dev-info { flex: 1; min-width: 0; }
.tag { font-size: .72em; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); }
.tag.soft { background: var(--bg-active); color: var(--text-2); }
.small-btn { padding: 5px 10px; font-size: .85em; }
.icon-btn.alert { color: var(--yellow); position: relative; }
.icon-btn.alert::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }

/* ---------- PIN + security questions ---------- */
.pin-input { letter-spacing: .35em; font-variant-numeric: tabular-nums; }
.pin-input::placeholder { letter-spacing: normal; }
.acct-fields { display: grid; gap: 12px; }
.acct-fields .acct-row { display: grid; gap: 8px; }
.acct-fields .hint { margin: -4px 0 0; }
.acct-fields select, .acct-fields input { width: 100%; }
.pin-change { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .pin-change { grid-template-columns: 1fr; }
}
#forgotStep2 { display: grid; gap: 14px; }
