/* Inter (OFL). Icons in the markup are Lucide (ISC). */

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #101113;
  --sidebar: #16171a;
  --elev: #1c1d21;
  --sunken: #0c0d10;
  --hover: rgba(255, 255, 255, 0.045);
  --active: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #f2f2f3;
  --text-2: #b7b8be;
  --text-3: #8d8e96;
  --accent: #4c89e8;
  --accent-hover: #5c95ee;
  --accent-soft: rgba(76, 137, 232, 0.18);
  --mine: #1c314c;
  --mine-line: rgba(140, 176, 224, 0.28);
  --danger: #e06a6a;
  --danger-soft: rgba(224, 106, 106, 0.12);
  --ok: #6eae8b;
  --warn: #d2a15a;
  --r-sm: 4px;
  --r: 6px;
  --r-md: 8px;
  --r-bubble: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --header: 52px;
  --sidebar-w: 280px;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
html { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--font);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; user-select: none; touch-action: manipulation; }
input, textarea { background: none; border: 0; outline: none; }
ul { list-style: none; }
img, svg { display: block; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, textarea:focus { outline: none; }

.icon { width: 16px; height: 16px; flex: none; }

/* spoke loader */
.spoke { position: relative; display: inline-block; width: 18px; height: 18px; color: var(--text-2); flex: none; }
.spoke i { position: absolute; inset: 0; transform: rotate(calc(var(--i) * 30deg)); }
.spoke i::before {
  content: "";
  display: block;
  width: 2px;
  height: 5px;
  margin: 0 auto;
  border-radius: 1px;
  background: currentColor;
  animation: spoke 0.8s linear infinite;
  animation-delay: calc(var(--i) * -66ms);
}
@keyframes spoke { to { opacity: 0.15; } }
.boot {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 80;
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.primary:disabled { opacity: 0.6; }
.btn.block { width: 100%; height: 36px; }
.btn.ghost { color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--danger); border-color: rgba(224, 106, 106, 0.4); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  color: var(--text-2);
  flex: none;
  transition: background-color 120ms ease, color 120ms ease;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.text-btn { color: var(--text-2); font-size: 12px; font-weight: 500; }
.text-btn:hover { color: var(--text); }
.mark {
  width: 22px;
  height: 22px;
  border-radius: var(--r);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sunken);
  border: 1px solid var(--line);
  color: var(--text-2);
}

/* auth */
#auth-screen {
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(32px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
}
.auth-shell { width: min(360px, 100%); }
.auth-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  font-size: 13px;
  font-weight: 600;
}
#auth-title { font-size: 20px; font-weight: 600; letter-spacing: -0.022em; line-height: 1.2; }
#auth-sub { margin: 6px 0 20px; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.auth-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.auth-tab {
  padding: 8px 0;
  margin-bottom: -1px;
  border-bottom: 1px solid transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
}
.auth-tab:hover { color: var(--text-2); }
.auth-tab.active { color: var(--text); border-bottom-color: var(--text); }
#auth-form, #reset-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.field input, .dialog input, #action-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r);
  border: 1px solid var(--line-strong);
  background: var(--elev);
  color: var(--text);
  font-size: 14px;
}
.field input:focus, .dialog input:focus, #action-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-wrap { position: relative; display: block; }
.input-wrap input { padding-right: 36px; }
.input-wrap .icon-btn { position: absolute; right: 2px; top: 2px; }
.field-hint { font-size: 12px; font-weight: 400; color: var(--text-3); line-height: 1.45; }
.field-hint.warn { color: var(--warn); }
.auth-links { display: flex; justify-content: space-between; gap: 12px; min-height: 16px; }
.form-err { font-size: 13px; color: var(--danger); line-height: 1.4; }
.form-err.ok { color: var(--ok); }

/* app shell */
#chat-screen { height: 100%; }
.app { height: 100%; display: flex; min-width: 0; }
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  position: relative;
  min-width: 0;
}
.sb-head, .thread-head {
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 14px;
  flex: none;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; letter-spacing: -0.02em; min-width: 0; }
.sb-head { justify-content: space-between; }
.sb-search { padding: 0 12px 8px; }
.sb-search label {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--sunken);
  color: var(--text-3);
}
.sb-search label:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sb-search input { flex: 1; min-width: 0; font-size: 13px; color: var(--text); }
.sb-search input::-webkit-search-cancel-button,
.sb-search input::-webkit-search-decoration { display: none; }
.sb-search input::placeholder, textarea::placeholder, .field input::placeholder { color: var(--text-3); }
.sb-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 8px 8px; }
.list-empty { padding: 8px 6px; color: var(--text-3); font-size: 13px; }

.room {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r);
  text-align: left;
  color: inherit;
  transition: background-color 120ms ease;
}
.room:hover { background: var(--hover); }
.room.active { background: var(--active); }
.room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.room-top, .room-sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.room-name, .room-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-name { font-size: 13.5px; font-weight: 500; }
.room.unread .room-name { font-weight: 600; }
.room-time { flex: none; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.room.unread .room-time { color: var(--accent); }
.room-preview { font-size: 12.5px; color: var(--text-3); }
.room.unread .room-preview { color: var(--text-2); }
.unread-mark {
  flex: none;
  min-width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 99px;
  background: var(--accent);
}
.unread-mark.count {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sb-foot { border-top: 1px solid var(--line); position: relative; }
.me-bar {
  width: calc(100% - 16px);
  margin: 8px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--r);
  text-align: left;
  color: inherit;
}
.me-bar:hover, .me-bar[aria-expanded="true"] { background: var(--hover); }
.me-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#me-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#me-badge { font-size: 11px; color: var(--text-3); font-weight: 400; }
.me-bar .chevron { color: var(--text-3); transition: transform 120ms ease; }
.me-bar[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.menu {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 64px;
  z-index: 8;
  padding: 4px;
  background: var(--elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.menu:not([hidden]) { animation: menu-in 120ms ease-out; }
@keyframes menu-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text);
  text-align: left;
}
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu.floating { position: fixed; left: auto; right: auto; bottom: auto; min-width: 188px; z-index: 70; }

/* thread */
.thread-pane {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}
.thread-head { border-bottom: 1px solid var(--line); padding-right: 8px; }
#sb-toggle { display: none; }
.thread-who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.thread-titles { min-width: 0; }
#room-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#room-topic {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#room-topic.is-typing { color: var(--text-2); }
.facepile {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 8px 0 4px;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.facepile:hover { background: var(--hover); color: var(--text); }
.pile { display: inline-flex; align-items: center; }
.pile .avatar { width: 22px; height: 22px; font-size: 10px; margin-left: -6px; box-shadow: 0 0 0 2px var(--bg); }
.pile .avatar:first-child { margin-left: 0; }

.thread-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.thread-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  padding: 8px 0 12px;
  overscroll-behavior: contain;
}
.thread-scroll::before { content: ""; flex: 1 1 auto; }
.thread-scroll:has(.thread-empty)::before { display: none; }
.thread-empty {
  margin: auto;
  padding: 24px 20px;
  text-align: center;
  max-width: 280px;
}
.thread-empty strong { display: block; font-size: 14px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.thread-empty p { font-size: 13px; color: var(--text-3); }

.day {
  text-align: center;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  margin: 14px 0 8px;
}
.system-msg {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  margin: 10px 20px;
}

.msg { display: flex; gap: 8px; padding: 1px 16px; align-items: flex-end; }
.msg.head { margin-top: 10px; align-items: flex-start; }
.msg.mine { flex-direction: row-reverse; justify-content: flex-start; }
.msg.enter { animation: msg-in 140ms ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.follow.theirs { padding-left: 52px; }

.stack { display: flex; flex-direction: column; align-items: flex-start; max-width: min(520px, 82%); min-width: 0; }
.msg.mine .stack { align-items: flex-end; }
.msg-name { font-size: 12px; font-weight: 500; color: var(--text-2); margin: 0 0 3px 2px; }
.role-tag { margin-left: 6px; color: var(--text-3); font-weight: 400; font-size: 11px; }
.bubble {
  display: inline-grid;
  grid-template-columns: minmax(0, max-content) auto;
  align-items: end;
  gap: 2px 8px;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  padding: 6px 10px 5px;
  border-radius: var(--r-bubble);
  background: var(--elev);
  border: 1px solid var(--line);
}
.msg.mine .bubble { background: var(--mine); border-color: var(--mine-line); }
.msg.deleted .bubble { background: transparent; border-style: dashed; }
.bubble-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.msg-photo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  max-width: min(280px, 70vw);
  border-radius: 8px;
  overflow: hidden;
}
.msg-photo.is-loading {
  width: min(220px, 70vw);
  height: 148px;
  background: rgba(255, 255, 255, 0.04);
}
.msg-photo.is-loading .msg-img {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.msg-photo .photo-spoke { width: 22px; height: 22px; color: var(--text-2); }
.msg-img {
  display: block;
  max-width: min(280px, 70vw);
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: 8px;
  cursor: zoom-in;
}
.msg-body {
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}
.msg.deleted .msg-body { color: var(--text-3); font-style: italic; }
.msg-time {
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: text;
  position: relative;
  top: 1px;
}
.msg.mine .msg-time { color: #a9bdd4; }
.del-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  align-self: center;
}
.del-btn:hover { color: var(--danger); background: var(--danger-soft); }
@media (hover: hover) and (pointer: fine) {
  .del-btn { opacity: 0; }
  .msg:hover .del-btn, .del-btn:focus-visible { opacity: 1; }
}

.skeleton { margin-top: auto; padding: 8px 0 4px; }
.sk-row { display: flex; padding: 6px 16px; }
.sk-row.mine { justify-content: flex-end; }
.sk-bar {
  height: 34px;
  border-radius: var(--r-bubble);
  background: var(--elev);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

.jump {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r);
  border: 1px solid var(--line-strong);
  background: var(--elev);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow);
}
.thread-body:has(.typing-bar:not([hidden])) .jump { bottom: 36px; }

.typing-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 16px 4px;
  color: var(--text-2);
  font-size: 12px;
  flex: none;
}
.dots { display: inline-flex; gap: 3px; align-items: center; }
.dots i, .mini-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: blink 1.15s infinite ease-in-out;
}
.dots i:nth-child(2), .mini-dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3), .mini-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 70%, 100% { opacity: 0.3; }
  35% { opacity: 1; }
}
.mini-dots { display: inline-flex; gap: 2px; color: var(--text-2); }

.storage { padding: 4px 14px 8px; }
.auth-shell .storage { padding: 18px 0 0; }
.storage-top { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.storage-text { font-variant-numeric: tabular-nums; }
.storage-track { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.storage-fill { display: block; height: 100%; width: 0; background: var(--accent); }
.storage-fill.warn { background: var(--warn); }
.storage-fill.full { background: var(--danger); }

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.attach {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.attach img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--sunken);
}
#attach-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-2);
}
#image-btn.is-disabled { color: var(--text-3); pointer-events: none; }
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction {
  height: 24px;
  padding: 0 7px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text-2);
  font-size: 12px;
}
.reaction.mine { border-color: rgba(76, 137, 232, 0.7); color: var(--text); background: var(--accent-soft); }
.edited { margin-left: 4px; color: var(--text-3); }
.emoji-row { display: flex; flex-wrap: wrap; gap: 2px; padding: 2px; }
.emoji-row button {
  width: 32px;
  height: 32px;
  border-radius: var(--r);
  font-size: 16px;
  line-height: 1;
}
.emoji-row button:hover, .emoji-row button.mine { background: var(--hover); }
.emoji-row button.mine { background: var(--accent-soft); }
#mail-notice .field-hint { margin-top: 8px; color: var(--text-2); font-size: 13px; }
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  min-height: 36px;
  max-height: 120px;
  padding: 8px 10px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--elev);
  line-height: 1.4;
  font-size: 14px;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea:disabled { color: var(--text-3); }
#send-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r);
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background-color 120ms ease;
}
#send-btn:hover:not(:disabled) { background: var(--accent-hover); }
#send-btn:disabled { background: var(--elev); color: var(--text-3); }
#send-btn.is-busy,
#send-btn.is-busy:disabled { background: var(--accent); color: #fff; }
#send-btn .spoke, .btn.primary .spoke { width: 14px; height: 14px; color: #fff; }

/* people */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #32343a;
  color: #e4e5e8;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex: none;
  position: relative;
  user-select: none;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar .status {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 2px var(--sidebar);
}
.members { position: absolute; inset: 0; z-index: 6; }
.members-scrim { position: absolute; inset: 0; background: transparent; }
.members-card {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 280px;
  max-height: min(440px, calc(100% - 16px));
  overflow: auto;
  background: var(--sidebar);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.members-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 4px 12px;
  background: var(--sidebar);
}
.members-head h3 { font-size: 13px; font-weight: 600; }
#online-list { padding: 0 6px 8px; }
.member-label { padding: 8px 8px 2px; font-size: 11px; font-weight: 500; color: var(--text-3); }
.member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r);
}
.member-name { font-size: 13px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-sub { margin-left: auto; color: var(--text-3); font-size: 11px; display: inline-flex; align-items: center; gap: 5px; flex: none; }
.member-empty { padding: 8px; color: var(--text-3); font-size: 13px; }

/* dialogs */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}
.dialog {
  width: min(400px, 100%);
  background: var(--sidebar);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--shadow);
}
.dialog.wide { width: min(720px, 100%); max-height: min(80vh, 760px); display: flex; flex-direction: column; }
.dialog.narrow { width: min(380px, 100%); }
.dialog h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.dialog .field { margin-top: 12px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-head-actions { display: flex; align-items: center; gap: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#admin-status { margin: 8px 0; color: var(--text-3); font-size: 12px; }
#admin-body { overflow: auto; min-height: 0; }
#action-field { margin-top: 12px; }
#action-copy { margin-top: 6px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.admin-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-banned { color: var(--danger); }
.status-muted { color: var(--warn); }
.status-active { color: var(--text-3); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }
.lightbox img {
  position: relative;
  max-width: min(1100px, 100%);
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-md);
}
.lightbox.is-loading img { opacity: 0; }
.lightbox .photo-spoke { position: relative; z-index: 1; width: 28px; height: 28px; color: #fff; }
.lightbox:not(.is-loading) .photo-spoke { display: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(360px, calc(100% - 24px));
  pointer-events: none;
}
.toast-msg {
  background: var(--elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
}
.toast-msg.err { border-color: rgba(224, 106, 106, 0.45); }
.toast-msg.ok { border-color: rgba(110, 174, 139, 0.45); }

.sb-scroll, .thread-scroll, #admin-body, .members-card {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

@media (max-width: 760px) {
  .sidebar { width: 100%; border-right: 0; }
  .thread-pane {
    position: fixed;
    inset: 0;
    z-index: 5;
    background: var(--bg);
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 180ms ease;
  }
  body.in-thread .thread-pane {
    transform: none;
    visibility: visible;
    pointer-events: auto;
  }
  #sb-toggle { display: inline-flex; }
  .members { position: fixed; z-index: 30; }
  .members-scrim { background: rgba(0, 0, 0, 0.45); }
  .members-card {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: min(72vh, 560px);
    border-radius: 10px 10px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .overlay { padding: 0; align-items: stretch; }
  .dialog, .dialog.wide, .dialog.narrow {
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  #toast { top: 12px; bottom: auto; }
  .field input, .dialog input, #action-input, .composer textarea, .sb-search input { font-size: 16px; }
  #image-btn { width: 44px; height: 44px; }
  #send-btn { width: 44px; height: 44px; }
  .sb-foot { padding-bottom: env(safe-area-inset-bottom); }
  .msg-body { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .msg.enter, .menu, .thread-pane, .sk-bar, .dots i, .mini-dots i, .me-bar .chevron {
    animation: none !important;
    transition: none !important;
  }
}
