/* Rookery: hand-written CSS, custom properties, light + dark (prefers-color-scheme, or the theme pref via
   html[data-theme]). No framework. */
:root {
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --accent-soft: #e3f4f1;
  --accent-fg: #ffffff;
  --bg: #f6f7f7;
  --panel: #ffffff;
  --panel-2: #f1f4f3;
  --text: #13201d;
  --muted: #5b6b67;
  --faint: #5f6e6a;
  --border: #e0e6e4;
  --border-strong: #c9d3d0;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn-soft: #fff6e0;
  --warn: #8a5a00;
  --rail: #0a2523;
  --side: #0f302d;
  --side-text: #d5e6e2;
  --side-muted: #8fb0aa;
  --side-hover: rgba(255, 255, 255, .07);
  --side-active: #1b6f66;
  --focus: 0 0 0 3px rgba(15, 118, 110, .35);
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --accent: #2bb3a3;
    --accent-strong: #3cc8b7;
    --accent-soft: #123a36;
    --accent-fg: #04201d;
    --bg: #0d1413;
    --panel: #121b1a;
    --panel-2: #17221f;
    --text: #e4eeeb;
    --muted: #9db0ab;
    --faint: #8b9e99;
    --border: #22302d;
    --border-strong: #2f403c;
    --danger: #ff8a80;
    --danger-soft: #3a1714;
    --warn-soft: #33270b;
    --warn: #f2c66d;
    --rail: #070f0e;
    --side: #0b1817;
    --side-text: #cfe0dc;
    --side-muted: #7f9893;
    --side-hover: rgba(255, 255, 255, .05);
    --side-active: #17544d;
    --focus: 0 0 0 3px rgba(43, 179, 163, .45);
  }
}
:root[data-theme=dark] {
  --accent: #2bb3a3;
  --accent-strong: #3cc8b7;
  --accent-soft: #123a36;
  --accent-fg: #04201d;
  --bg: #0d1413;
  --panel: #121b1a;
  --panel-2: #17221f;
  --text: #e4eeeb;
  --muted: #9db0ab;
  --faint: #8b9e99;
  --border: #22302d;
  --border-strong: #2f403c;
  --danger: #ff8a80;
  --danger-soft: #3a1714;
  --warn-soft: #33270b;
  --warn: #f2c66d;
  --rail: #070f0e;
  --side: #0b1817;
  --side-text: #cfe0dc;
  --side-muted: #7f9893;
  --side-hover: rgba(255, 255, 255, .05);
  --side-active: #17544d;
  --focus: 0 0 0 3px rgba(43, 179, 163, .45);
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 .6rem; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: 0 16px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--panel-2); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-fg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: .875rem; }
input[type=email], input[type=text], input[type=search], select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
label { font-weight: 600; font-size: .9rem; }
.stack { display: grid; gap: .65rem; margin-top: 1rem; }
.alert { background: var(--danger-soft); color: var(--danger); padding: .6rem .8rem; border-radius: 8px; margin: .8rem 0 0; }

/* server-rendered auth pages */
.page-auth { background: radial-gradient(1200px 500px at 50% -200px, var(--accent-soft), transparent), var(--bg); }
.auth { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(16, 48, 45, .06); }
.card p { margin: .4rem 0; }
.auth-foot { color: var(--faint); font-size: .85rem; }
.auth-foot a { color: var(--faint); }
.noscript { padding: 2rem; text-align: center; }

/* ---------- chat app ---------- */
.page-app { overflow: hidden; }
#app { height: 100%; height: 100dvh; }
.boot-splash { height: 100%; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; color: var(--muted); }
.shell { display: grid; grid-template-columns: 68px 264px minmax(0, 1fr); height: 100%; }

/* org rail */
.rail { background: var(--rail); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; overflow-y: auto; }
.rail-org { position: relative; width: 44px; height: 44px; border-radius: 12px; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center;
  font: 700 1rem var(--font); color: #fff; transition: border-radius .15s ease; }
.rail-org:hover { border-radius: 10px; }
.rail-org[aria-current=true]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: #fff; }
.rail-org .dot { position: absolute; right: -3px; top: -3px; width: 12px; height: 12px; border-radius: 50%; background: #f5b83d; border: 2px solid var(--rail); }

/* sidebar */
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 12px 16px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.side-head h2 { margin: 0; font-size: 1.02rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-scroll { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.side-section { margin-top: 6px; }
.side-label { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; font-size: .78rem; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--side-muted); }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.icon-btn:hover { background: var(--side-hover); }
.chan { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 4px 10px; border: 0; border-radius: 7px; background: transparent;
  color: var(--side-text); font: inherit; text-align: left; cursor: pointer; }
.chan:hover { background: var(--side-hover); }
.chan[aria-current=page] { background: var(--side-active); color: #fff; }
.chan .hash { color: var(--side-muted); width: 14px; text-align: center; font-weight: 600; }
.chan[aria-current=page] .hash { color: #cfeee9; }
.chan .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan.unread .name { color: #fff; font-weight: 700; }
.chan .badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #d6e8e4; color: #0b2c29; font-size: .75rem; font-weight: 700;
  display: inline-grid; place-items: center; line-height: 1; }
.chan .badge.mention { background: #f5b83d; color: #2b1d00; }
.chan .draft-mark { color: var(--side-muted); font-size: .85rem; }
.chan.browse { color: var(--side-muted); }
.side-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid rgba(255, 255, 255, .06); }
.side-foot .who { flex: 1; min-width: 0; line-height: 1.2; }
.side-foot .who b { display: block; color: #fff; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { font-size: .78rem; color: var(--side-muted); display: inline-flex; align-items: center; gap: 5px; }
.side-foot form { margin: 0; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa7a4; display: inline-block; }
.conn-dot.live { background: #3ddc97; }
.conn-dot.wait { background: #f5b83d; }
.conn-dot.down { background: #ff7a6e; }
.side-foot .icon-btn { color: var(--side-muted); }

/* main pane */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.main-head { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 18px; border-bottom: 1px solid var(--border); }
.main-head .back { display: none; color: var(--text); }
.main-head h1 { margin: 0; font-size: 1.08rem; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.main-head h1 .hash { color: var(--faint); }
.main-head .topic { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.main-head .members { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.banner { display: flex; align-items: center; gap: 8px; padding: 7px 18px; font-size: .88rem; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--border); }
.banner.down { background: var(--danger-soft); color: var(--danger); }

.log { flex: 1; overflow-y: auto; padding: 8px 0 12px; overscroll-behavior: contain; }
.log-empty { max-width: 460px; margin: 12vh auto 0; text-align: center; color: var(--muted); padding: 0 24px; }
.log-empty .big { font-size: 2.2rem; color: var(--accent); font-weight: 700; display: block; margin-bottom: 8px; }
.log-empty h2 { color: var(--text); margin: 0 0 6px; font-size: 1.2rem; }
.day { display: flex; align-items: center; gap: 12px; margin: 14px 18px 4px; color: var(--muted); font-size: .8rem; font-weight: 600; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.load-older { display: flex; justify-content: center; padding: 8px 0; }

.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0 12px; padding: 3px 18px; position: relative; }
.msg:hover, .msg:focus-within { background: var(--panel-2); }
.msg.first { margin-top: 10px; }
.msg .avatar { grid-row: span 2; }
.msg > :not(.avatar):not(.side-time):not(.toolbar) { grid-column: 2; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; line-height: 1.3; }
.msg .author { font-weight: 700; }
.msg time { color: var(--faint); font-size: .78rem; }
.msg.cont .meta { display: none; }
.msg .side-time { position: absolute; left: 12px; width: 52px; text-align: center; top: 6px; font-size: .68rem; white-space: nowrap; color: var(--faint); opacity: 0; }
.msg.cont:hover .side-time, .msg.cont:focus-within .side-time { opacity: 1; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.body.md, .md { white-space: normal; }
.md p { margin: 0; }
.md p + p, .md p + ul, .md p + ol, .md ul + p, .md ol + p, .md pre, .md blockquote, .md table { margin-top: .35rem; }
.md ul, .md ol { margin: .2rem 0 0; padding-left: 1.4rem; }
.md li > input[type=checkbox] { margin: 0 .35rem 0 -1.1rem; vertical-align: -1px; }
.md li:has(> input[type=checkbox]) { list-style: none; }
.md code { font: .88em/1.4 var(--mono); background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; padding: .05em .3em; }
.msg:hover .md code, .msg:focus-within .md code { background: var(--panel); }
.md pre { tab-size: 4; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; overflow-x: auto; white-space: pre; margin-bottom: 0; }
.md pre code { background: none; border: 0; padding: 0; font-size: .85rem; }
.md blockquote { margin-left: 0; margin-right: 0; padding: .1rem 0 .1rem .75rem; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md table { border-collapse: collapse; font-size: .92rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: .25rem .6rem; text-align: left; }
.md th { background: var(--panel-2); }
.md del { color: var(--muted); }
.md a { overflow-wrap: anywhere; }
.mention { background: var(--accent-soft); color: var(--accent-strong); border-radius: 4px; padding: 0 .2em; font-weight: 600; }
span.mention[data-channel] { cursor: pointer; }
.mention[data-user] { white-space: nowrap; }
.msg .deleted-note, .msg .e2ee { color: var(--muted); font-style: italic; }
.msg .edited, .msg .offline-label { font-size: .75rem; color: var(--faint); }
.msg .offline-label { background: var(--warn-soft); color: var(--warn); border-radius: 5px; padding: 0 6px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 8px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--panel); color: var(--text); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.reaction[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.reaction:hover { border-color: var(--accent); }
.toolbar { position: absolute; right: 14px; top: -14px; display: none; gap: 2px; padding: 2px; background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 9px; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); z-index: 2; }
.msg:hover .toolbar, .msg:focus-within .toolbar { display: flex; }
.tool { width: 32px; height: 30px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: .95rem; color: var(--text); }
.tool:hover { background: var(--panel-2); }
.msg .state { font-size: .78rem; color: var(--faint); margin: 1px 0 0; }
.msg.failed { background: var(--danger-soft); }
.msg.failed .body { color: var(--muted); }
.failed-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--danger) !important; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.edit-form { margin: 4px 0; }
.edit-form textarea { resize: vertical; min-height: 64px; }
.edit-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; font-size: .78rem; }
.edit-actions .muted { margin-right: auto; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.quote-preview { margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--border-strong); background: var(--panel-2); border-radius: 0 8px 8px 0; max-height: 160px; overflow: hidden; }
.msg.pending .body { color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .95rem; user-select: none; }
.avatar.sm { width: 32px; height: 32px; border-radius: 8px; font-size: .8rem; }

/* composer */
.composer { padding: 0 18px 16px; position: relative; }
.composer-tabs { display: flex; gap: 2px; margin: 0 0 -1px 8px; position: relative; z-index: 1; }
.ctab { border: 1px solid transparent; border-bottom: 0; background: none; color: var(--muted); font: inherit; font-size: .8rem; font-weight: 600;
  padding: 3px 10px; border-radius: 7px 7px 0 0; cursor: pointer; }
.ctab[aria-selected=true] { color: var(--text); border-color: var(--border-strong); background: var(--panel); }
.ctab:disabled { opacity: .5; cursor: default; }
.composer .preview { flex: 1; min-height: 40px; max-height: 40vh; overflow-y: auto; padding: 8px 0; }
.suggest { position: absolute; bottom: calc(100% - 22px); left: 18px; right: 18px; max-width: 360px; list-style: none; margin: 0; padding: 4px; background: var(--panel);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); z-index: 5; }
.suggest li { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.suggest li.on { background: var(--accent-soft); }
.suggest li span { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-head .edit-topic { color: var(--faint); font-size: .95rem; }
.main-head .edit-topic:hover { background: var(--panel-2); }
.composer form { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border-strong); border-radius: 12px; padding: 6px 6px 6px 12px; background: var(--panel); }
.composer form:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.composer textarea { border: 0; box-shadow: none !important; padding: 8px 0; resize: none; max-height: 40vh; min-height: 40px; line-height: 1.45; background: transparent; }
.composer .send { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 9px; border: 0; background: var(--accent); color: var(--accent-fg); cursor: pointer; display: grid; place-items: center; }
.composer .send:disabled { background: var(--border-strong); color: var(--muted); cursor: default; }
.composer .hint { margin: 6px 4px 0; font-size: .75rem; color: var(--faint); }
.composer .hint code { font: .72rem var(--mono); }
.join-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 16px 18px 20px; border-top: 1px solid var(--border); color: var(--muted); }

/* dialogs */
.overlay { position: fixed; inset: 0; background: rgba(5, 15, 14, .45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.dialog { width: 100%; max-width: 460px; background: var(--panel); color: var(--text); border-radius: 14px; border: 1px solid var(--border); padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: 85vh; overflow-y: auto; }
.dialog h2 { margin: 0 0 4px; font-size: 1.2rem; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog .field-hint { font-size: .8rem; color: var(--muted); margin-top: -4px; }
.browse-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; }
.browse-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; }
.browse-list .info { flex: 1; min-width: 0; }
.browse-list .info b { display: block; }
.browse-list .info span { color: var(--muted); font-size: .85rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* mobile: single column with a back stack (sidebar -> channel) */
@media (max-width: 640px) {
  .shell { grid-template-columns: 64px minmax(0, 1fr); }
  .shell.show-main { grid-template-columns: minmax(0, 1fr); }
  .shell.show-main .rail, .shell.show-main .side { display: none; }
  .shell:not(.show-main) .main { display: none; }
  .main-head { padding: 6px 10px; min-height: 54px; }
  .main-head .back { display: inline-grid; width: 44px; height: 44px; }
  .main-head .back:hover { background: var(--panel-2); }
  .main-head .members { display: none; }
  .chan { min-height: 44px; font-size: 1rem; }
  .msg { padding: 3px 12px; }
  .toolbar { right: 8px; }
  .composer { padding: 0 10px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .composer .hint { display: none; }
  .composer textarea { font-size: 16px; } /* no zoom on focus in iOS Safari */
  .banner { padding: 7px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- C3: private channels, DMs, people ---------- */
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; text-transform: lowercase; }
.pill.role-owner, .pill.role-admin { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.pill.role-manager { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.role-guest, .pill.guest { background: #fdeee0; color: #8a3b00; border-color: transparent; }
.pill.private { background: var(--panel-2); }
.side-head .pill.guest { background: rgba(245, 184, 61, .18); color: #f5c76d; }
.side-head h2 { flex: 1; }
.side-head .icon-btn { color: var(--side-muted); }
.side-label .icon-btn.add { width: 24px; height: 24px; font-size: .95rem; color: var(--side-muted); }
.side-label .icon-btn.add:hover { color: #fff; }
.side-section + .side-section { margin-top: 14px; }
.side-empty { margin: 2px 10px; font-size: .8rem; color: var(--side-muted); }
.chan.private .hash { font-size: .72rem; }
.chan .dm-dot { width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center; color: #fff; font-size: .6rem; font-weight: 700; flex: 0 0 auto; margin-left: -3px; }
.chan.dm .hash { font-size: .72rem; border: 1.5px solid var(--side-muted); border-radius: 6px; width: 20px; height: 20px; display: inline-grid; place-items: center; margin-left: -3px; }
.avatar.xs { width: 22px; height: 22px; border-radius: 6px; font-size: .62rem; }
.avatar-pair { position: relative; width: 34px; height: 30px; display: inline-block; flex: 0 0 auto; }
.avatar-pair .avatar:first-child { position: absolute; left: 0; top: 0; }
.avatar-pair .avatar:last-child { position: absolute; right: 0; bottom: 0; box-shadow: 0 0 0 2px var(--panel); }
.main-head .avatar.sm { width: 30px; height: 30px; }
.main-head .pill { flex: 0 0 auto; }
.members-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--muted); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.members-btn:hover { color: var(--text); background: var(--panel-2); }
.log-empty .big-avatars { display: inline-flex; gap: 6px; margin-bottom: 10px; }
.log-empty .continued { margin-top: 10px; font-size: .9rem; }
.archived-bar { background: var(--panel-2); }

.dialog.wide { max-width: 600px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.dialog-head h2 { margin: 0; }
.dialog .icon-btn.close { color: var(--muted); font-size: 1.4rem; }
.dialog .icon-btn.close:hover { background: var(--panel-2); color: var(--text); }
.dialog h3 { margin: 22px 0 6px; font-size: .95rem; }
.dialog .actions.spread { justify-content: space-between; flex-wrap: wrap; }
.dialog .actions .row { display: flex; gap: 8px; flex-wrap: wrap; }
.dialog .ok { background: var(--accent-soft); color: var(--accent-strong); padding: .55rem .8rem; border-radius: 8px; margin: 0; }
.btn.danger-ghost { color: var(--danger); border-color: var(--border-strong); background: transparent; }
.btn.danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 10px 0 12px; }
.tab { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; }
.tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }
.search { margin: 8px 0; }

.member-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; max-height: 46vh; overflow-y: auto; }
.member-list li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; }
.member-list li:hover { background: var(--panel-2); }
.member-list li.inactive { opacity: .6; }
.member-list .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.member-list .sub, .report-list .sub { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.member-list select { width: auto; min-height: 32px; padding: 0 28px 0 10px; font-size: .85rem; border-radius: 8px; }
.report-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 10px; }
.report-list li { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.report-list li.resolved { opacity: .65; }
.report-list p { margin: 6px 0; }

.picker { display: grid; gap: .4rem; position: relative; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px 8px; min-height: 42px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--panel); }
.chips:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.chips input { flex: 1; min-width: 120px; border: 0 !important; box-shadow: none !important; padding: 4px 2px; min-height: 0; background: transparent; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 9px; border-radius: 13px; background: var(--accent-soft); color: var(--accent-strong); font-size: .85rem; font-weight: 600; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; width: 20px; height: 20px; border-radius: 10px; }
.chip button:hover { background: rgba(0, 0, 0, .08); }
.picker-list { list-style: none; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: 10px; max-height: 220px; overflow-y: auto; }
.picker-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.picker-list button:hover, .picker-list button:focus-visible { background: var(--accent-soft); }
.picker-list .avatar.sm { width: 26px; height: 26px; font-size: .7rem; border-radius: 7px; }

.seg { display: flex; gap: 6px; border: 0; padding: 0; margin: 0; }
.seg label { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 9px; cursor: pointer; font-weight: 600; text-align: center; }
.seg.two label { text-align: left; }
.seg label span { font-weight: 400; font-size: .8rem; color: var(--muted); }
.seg label.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:focus-within { box-shadow: var(--focus); }
.check-list { display: flex; flex-wrap: wrap; gap: 6px 14px; max-height: 120px; overflow-y: auto; }
.check-list label { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; }
.check-list input { width: auto; min-height: 0; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { flex: 1; font: .82rem var(--mono); }
.card .small { font-size: .82rem; }
@media (max-width: 640px) {
  .main-head .members-btn { padding: 0 8px; }
  .main-head .pill { display: none; }
  .member-list li { flex-wrap: wrap; }
}

/* E1: security (safety numbers), devices, sign-out choices, key lines */
.sec-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--muted); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.sec-btn:hover { color: var(--text); background: var(--panel-2); }
.sec-btn.on { color: var(--accent-strong); border-color: var(--accent); }
.e2ee-copy p { margin: 0 0 10px; }
.e2ee-copy { border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.e2ee-warn { padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.sec-list, .dev-list, .dev-mini { list-style: none; margin: 0; padding: 0; }
.sec-row { padding: 12px 0; border-top: 1px solid var(--border); }
.sec-row:first-child { border-top: 0; }
.sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sec-sub { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 6px; }
.safety { display: grid; grid-template-columns: repeat(4, max-content); gap: 6px 18px; font-family: var(--mono); font-size: 1.15rem; letter-spacing: .06em;
  padding: 12px 16px; margin: 6px 0 10px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--border); width: max-content; max-width: 100%; }
.sec-actions { display: flex; gap: 8px; }
.pill.verified { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.current { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.dev-mini li { padding: 3px 0; font-size: .9rem; }
.dev-ok { color: var(--accent); margin-right: 6px; font-size: .7rem; }
.dev-bad { color: var(--danger); }
.dev-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.dev-row:first-child { border-top: 0; }
.dev-row.current .dev-icon { background: var(--accent-soft); }
.dev-icon { width: 40px; height: 40px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); font-size: 1.2rem; }
.dev-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; flex: 1; min-width: 0; }
.dev-info .muted, .dev-info .dev-ok-text { flex-basis: 100%; font-size: .85rem; }
.dev-ok-text { color: var(--accent-strong); }
.e2ee-state { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; background: var(--panel-2); border: 1px solid var(--border); line-height: 1.45; }
.e2ee-state.ready { background: var(--accent-soft); border-color: transparent; }
.e2ee-state.needs-approval, .e2ee-state.needs-recovery, .e2ee-state.error, .e2ee-state.unsupported { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.confirm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); margin-bottom: 12px; }
.confirm-bar span { flex: 1 1 240px; }
/* E3a: recovery key */
.rk-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 16px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; border-bottom: 1px solid var(--border); }
.rk-banner .btn { margin-left: auto; }
.rk-setup p { line-height: 1.5; }
.rk-key { display: grid; grid-template-columns: repeat(3, max-content); justify-content: center; gap: 10px 22px; margin: 18px auto; padding: 16px 20px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px dashed var(--border); font: 600 1.35rem var(--mono); letter-spacing: .12em; user-select: all; }
.rk-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rk-setup .actions .spacer, .rk-actions .spacer { flex: 1; }
.rk-check { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0 4px; }
.rk-check label, .rk-input { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.rk-check input { width: 9ch; font: 600 1.1rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.rk-input input { font: 600 1.05rem var(--mono); letter-spacing: .08em; text-transform: uppercase; width: 100%; }
.rk-state { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; background: var(--warn-soft); color: var(--warn); line-height: 1.45; }
.rk-state.ok { background: var(--panel-2); color: inherit; border: 1px solid var(--border); }
.rk-reset { display: block; margin-top: 12px; }
.rk-reset p { margin: 0 0 8px; line-height: 1.45; }
.rk-reset .actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn.link { background: none; border: 0; color: var(--accent-strong); text-decoration: underline; padding-left: 0; }
@media (max-width: 520px) { .rk-key { grid-template-columns: repeat(2, max-content); font-size: 1.15rem; } }
.muted.small, p.small { font-size: .82rem; }
.signout-choices { display: grid; gap: 4px; }
.signout-choices .btn { justify-self: start; }
.signout-choices p { margin: 0 0 12px; }
.sysline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 18px; padding: 7px 12px; border-radius: 8px; font-size: .88rem;
  background: var(--warn-soft); color: var(--warn); }
.sysline.ignored, .sysline.reverify { background: var(--danger-soft); color: var(--danger); }
.linkish { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: inherit; text-decoration: underline; cursor: pointer; }
@media (max-width: 640px) { .safety { grid-template-columns: repeat(3, max-content); font-size: 1rem; gap: 6px 12px; } .sec-btn span { display: none; } }

/* E2a: encrypted conversations */
.sec-btn.off { color: var(--muted); }
.sec-btn .beta { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px; background: var(--accent-soft, var(--panel-2)); color: var(--accent-strong); }
.group-bar { padding: 8px 16px; font-size: .875rem; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--border); }
.group-bar.problem { background: var(--danger-soft); color: var(--danger); }
.body.e2ee.pending { color: var(--muted); font-style: italic; }
.body.e2ee.unverified, .body.e2ee.failed { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: .9rem; }
.body.e2ee.unverified { background: var(--danger-soft); color: var(--danger); font-weight: 500; }
.body.e2ee.failed { background: var(--panel-2); color: var(--muted); }

/* E3a: help page */
.page-help .card { max-width: 46rem; }
.help h2 { font-size: 1.05rem; margin: 1.4rem 0 .4rem; }
.help p, .help li { line-height: 1.55; }
.help ul { padding-left: 1.2rem; }
.help .lede { font-size: 1.05rem; }
