/* SPDX-License-Identifier: MPL-2.0 */
/* Clamor web prototype. System fonts and local assets only. */

:root {
  color-scheme: dark;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #15171d;
  --bg-rail: #0f1116;
  --bg-side: #1b1d25;
  --bg-raise: #23262f;
  --bg-card: #1f222b;
  --bg-hover: #2b2e3a;
  --bg-input: #111319;
  --line: #2b2f3b;
  --line-strong: #444a5c;
  --text: #ececf3;
  --text-dim: #b6bacb;
  --text-faint: #9095a8;
  --accent: #c6b8ff;
  --accent-hover: #dbd0ff;
  --accent-ink: #22183d;
  --accent-soft: rgba(198, 184, 255, 0.14);
  --accent-line: rgba(198, 184, 255, 0.55);
  --danger: #ffb3bf;
  --danger-bg: #331f26;
  --danger-line: #8f4c5b;
  --warn: #f2cd86;
  --warn-bg: #2f2a1d;
  --warn-line: #84693a;
  --ok: #86dca6;
  --focus: #e0d7ff;
  --radius: 8px;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
.rich-text { white-space: normal; overflow-wrap: anywhere; }
.rich-text p { white-space: pre-wrap; margin: .2rem 0; min-height: .3rem; }
.rich-text blockquote { border-left: 3px solid var(--accent); padding-left: .7rem; margin: .4rem 0; color: var(--text-dim); }
.rich-text a { color: var(--accent-hover); text-decoration: underline; }
.rich-text a, .rich-text bdi, .rich-text .link-dest { unicode-bidi: isolate; }
.rich-text .link-dest { direction: ltr; }
.rich-text code { font-family: ui-monospace, monospace; background: var(--bg-input); padding: .1rem .25rem; border-radius: 3px; }
.code-block { max-width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; margin: .4rem 0; overflow: hidden; }
.code-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .25rem .5rem; background: var(--bg-side); font-size: .8rem; }
.code-block pre { padding: .7rem; overflow-x: auto; white-space: pre; margin: 0; }
.spoiler-toggle { color: var(--accent-hover); background: var(--bg-input); padding: .1rem .4rem; }
.spoiler-content { padding: 0 .35rem; border-bottom: 1px dotted var(--accent); }
.mention { background: var(--accent-soft); color: var(--accent-hover); padding: .05rem .2rem; border-radius: 3px; }
.mention.notifying { border-bottom: 1px solid var(--accent); }
.expressive-tools { position: relative; padding: .15rem .5rem; font-size: .8rem; }
.emoji-picker > summary { cursor: pointer; color: var(--accent-hover); padding: .15rem; }
.expression-popover { position: absolute; bottom: 100%; right: .5rem; z-index: 20; width: min(420px, calc(100vw - 3rem)); max-height: min(65vh, 560px); overflow: auto; padding: .75rem; background: var(--bg-side); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 8px 24px #0008; }
.expression-popover input, .expression-popover select { width: 100%; margin: .2rem 0; }
.expression-popover label { display: block; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: .15rem; }
.emoji-grid button { font-size: 1.35rem; padding: .3rem .1rem; min-width: 0; }
.local-expressions { display: flex; flex-wrap: wrap; gap: .25rem; }
.mention-candidates { display: flex; flex-wrap: wrap; gap: .2rem; max-height: 5rem; overflow: auto; }
.custom-emoji { display: inline-block; vertical-align: middle; max-width: 2rem; max-height: 2rem; }
.custom-emoji img { width: 1.7rem; height: 1.7rem; object-fit: contain; }
.sticker { display: inline-block; max-width: min(100%, 240px); }
.sticker img { width: auto; max-width: 100%; height: auto; max-height: 240px; object-fit: contain; }
.expression-manager { margin-top: .5rem; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, pre, bdi { unicode-bidi: plaintext; }
bdi { overflow-wrap: anywhere; }
p { line-height: 1.5; }
h1, h2, h3 { line-height: 1.3; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
pre { font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; margin: .4rem 0; }

/* Controls */
button {
  padding: .45rem .75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-raise);
  color: var(--text);
  font-size: .875rem;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  transition: background-color .12s, border-color .12s, opacity .12s;
}
button:hover { background: var(--bg-hover); }
button:disabled { opacity: .55; cursor: not-allowed; }
button[aria-pressed=true] { border-color: var(--accent-line); background: var(--accent-soft); color: #f1ecff; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.primary:hover { background: var(--accent-hover); }
.primary:disabled { background: #5b5574; border-color: #5b5574; color: #2a2638; opacity: 1; }
.quiet { background: transparent; border-color: transparent; color: var(--text-dim); }
.quiet:hover { background: var(--bg-hover); color: var(--text); }
.danger { color: var(--danger); border-color: var(--danger-line); background: var(--danger-bg); }
.danger:hover { background: #45232c; }
summary.danger { background: none; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  flex: none;
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  font-size: 1rem;
}
.icon-button:hover { background: var(--bg-hover); color: var(--text); }

input, textarea, select {
  width: 100%;
  padding: .55rem .65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; line-height: 1.5; min-height: 5rem; }
label { display: block; margin: .7rem 0 .3rem; font-size: .8rem; font-weight: 600; color: var(--text-dim); }
.checkbox { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
form button { margin-top: .6rem; }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
summary:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.workspace:focus { outline: none; }

details { margin: .35rem 0; }
summary {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .55rem;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: .85rem;
  cursor: pointer;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "";
  flex: none;
  width: .38rem;
  height: .38rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
details[open] > summary::before { transform: rotate(45deg); }
summary:hover { background: var(--bg-hover); color: var(--text); }

/* Shared text */
.muted { color: var(--text-dim); font-size: .8rem; }
.hint { margin: .3rem 0 0; color: var(--text-faint); font-size: .75rem; line-height: 1.4; }
.badge {
  padding: .12rem .4rem;
  border-radius: 4px;
  background: #2d2c40;
  color: #ddd4ff;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.role-tag {
  padding: .12rem .45rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  font-size: .66rem;
  font-weight: 600;
  white-space: nowrap;
}
.role-tag.owner { border-color: var(--accent-line); color: var(--accent); }
.tag {
  padding: .05rem .4rem;
  border-radius: 4px;
  background: #2a2e3b;
  color: var(--text-dim);
  font-size: .68rem;
  font-weight: 600;
  white-space: nowrap;
}
.tag.pinned { background: var(--accent-soft); color: var(--accent); }
.stack { display: flex; flex-direction: column; }
.stack label { margin-top: .55rem; }
.stack > button { align-self: flex-start; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link { position: fixed; top: -100px; left: 10px; z-index: 100; padding: .7rem; border-radius: var(--radius); background: #e1d7ff; color: #211733; }
.skip-link:focus { top: 10px; }
.mobile-only { display: none; }
.boot { padding: 2rem; }

/* Shell */
.app-shell {
  display: grid;
  grid-template-columns: 68px 248px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}
.app-shell:has(.detail-panel) { grid-template-columns: 68px 248px minmax(0, 1fr) 360px; }

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: .8rem 0;
  overflow-y: auto;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
}
.brand {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent);
  color: #282039;
  font-size: 1.55rem;
  font-weight: 900;
}
.rail-separator { flex: none; width: 28px; height: 2px; margin: .15rem 0; border-radius: 2px; background: var(--line); }
.community {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--line);
  background: var(--bg-raise);
  font-size: 1.05rem;
  font-weight: 700;
  transition: border-radius .15s, background-color .12s;
}
.community:hover { border-radius: 14px; }
.community.selected { border-radius: 14px; border-color: var(--accent-line); background: #4a3f6e; }
.community.selected::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
}
.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  padding: .85rem .9rem .75rem 1rem;
  border-bottom: 1px solid var(--line);
}
.sidebar-title { min-width: 0; }
.sidebar h1 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 0; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: .35rem .55rem .9rem; }
.sidebar-section + .sidebar-section { margin-top: .4rem; }
.section-label {
  margin: .9rem .5rem .3rem;
  color: var(--text-faint);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sidebar-empty { margin: .4rem .5rem; color: var(--text-faint); font-size: .8rem; }
.channel, .nav-row {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  margin: 1px 0;
  padding: .4rem .55rem;
  border-color: transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  text-align: left;
}
.channel:hover, .nav-row:hover { background: var(--bg-hover); color: var(--text); }
.channel.active, .nav-row[aria-current=true] { background: var(--accent-soft); color: #f4efff; font-weight: 600; }
.channel-hash { flex: none; width: 1ch; color: var(--text-faint); font-weight: 600; }
.channel.active .channel-hash { color: var(--accent); }
.setup form { padding: 0 .55rem .6rem; }
.inline-setup summary, .sidebar .setup summary { color: var(--text-faint); }
.setup-forms { display: grid; gap: .25rem; }
.user-panel {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .7rem;
  border-top: 1px solid var(--line);
  background: #17191f;
}
.user-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.user-meta strong { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta .muted { font-size: .7rem; color: var(--text-faint); }
.user-panel .quiet { padding: .35rem .55rem; font-size: .8rem; }
.sidebar-footer { margin: 0; padding: 0 .75rem .6rem; background: #17191f; color: var(--text-faint); font-size: .68rem; }

/* Workspace */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.topbar {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  min-height: 56px;
  padding: .5rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: #181a21;
}
.topbar-title { flex: 1 1 180px; min-width: 0; }
.topbar h2 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-meta { margin: .1rem 0 0; color: var(--text-faint); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  flex: none;
  padding: .22rem .6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: .72rem;
  white-space: nowrap;
}
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status-pill.syncing .dot { background: var(--accent); }
.status-pill.offline { border-color: var(--warn-line); color: var(--warn); }
.status-pill.offline .dot { background: var(--warn); }
.searchbar { display: flex; flex: 1 1 240px; gap: .35rem; max-width: 420px; margin: 0; }
.searchbar input { flex: 1; min-width: 0; padding: .4rem .6rem; }
.searchbar button { margin: 0; flex: none; white-space: nowrap; }
.pins-button { flex: none; white-space: nowrap; }
.pins-button[aria-current=true] { border-color: var(--accent-line); color: var(--accent); }

.banners { display: flex; flex: 0 1 auto; flex-direction: column; gap: .4rem; min-height: 2.75rem; padding: .55rem 1.25rem 0; overflow-y: auto; }
.banner {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin: 0;
  padding: .5rem .55rem .5rem .8rem;
  border: 1px solid #3f4763;
  border-radius: var(--radius);
  background: #222738;
  font-size: .85rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.banner-text { flex: 1; min-width: 0; padding: .15rem 0; }
.banner.error { border-color: var(--danger-line); background: var(--danger-bg); color: #ffd6de; }
.banner.warning { border-color: var(--warn-line); background: var(--warn-bg); color: #f8e2b4; }
.dismiss { flex: none; width: 1.75rem; height: 1.75rem; padding: 0; border-color: transparent; background: transparent; color: inherit; font-size: .85rem; }
.dismiss:hover { background: rgba(255, 255, 255, .08); }

.search-results {
  flex: 0 1 auto;
  min-height: 4rem;
  max-height: 38vh;
  overflow-y: auto;
  padding: .4rem 1.25rem .6rem;
  border-bottom: 1px solid var(--line);
  background: #1a1c24;
}
.results-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .75rem; }
.results-header h3 { margin: .35rem 0; font-size: .85rem; }
.results-header .muted { margin: 0; font-size: .74rem; color: var(--text-faint); }
.results-empty { margin: .25rem 0 .4rem; color: var(--text-faint); font-size: .85rem; }

.timeline {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 6rem;
  overflow-y: auto;
  padding: .5rem 1.25rem 1rem;
  scrollbar-color: #4b4f60 transparent;
}
.timeline > :first-child { margin-top: auto; }
.timeline-state, .timeline-note { margin: .5rem 0; color: var(--text-faint); font-size: .8rem; text-align: center; }
.load-older { align-self: center; margin: .25rem 0 .5rem; font-size: .8rem; }
.channel-intro { padding: 1rem 0 .8rem; margin-bottom: .25rem; border-bottom: 1px solid var(--line); }
.channel-intro h3 { margin: 0 0 .25rem; font-size: 1.3rem; letter-spacing: -.01em; }
.channel-intro p { margin: 0; color: var(--text-dim); font-size: .875rem; }
.day-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: .9rem 0 .2rem;
  color: var(--text-faint);
  font-size: .72rem;
  font-weight: 600;
}
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Messages */
.message {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: .75rem;
  margin: .45rem -.5rem 0;
  padding: .3rem .5rem;
  border-radius: var(--radius);
}
.message.grouped { margin-top: 0; padding-top: .05rem; }
.message:hover, .message:focus-within { background: rgba(255, 255, 255, .025); }
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #3a3556;
  color: #e6ddff;
  font-weight: 700;
}
.avatar.small { flex: none; width: 32px; height: 32px; font-size: .85rem; }
.gutter-time { padding-top: .2rem; color: var(--text-faint); font-size: .62rem; text-align: right; white-space: nowrap; opacity: 0; }
.message:hover .gutter-time, .message:focus-within .gutter-time { opacity: 1; }
.message-content { min-width: 0; }
.message.has-actions .message-content { padding-right: 2.25rem; }
.message-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .5rem; }
.author { font-size: .9rem; font-weight: 650; }
.message-time, .edited { color: var(--text-faint); font-size: .72rem; }
.message-body { margin: .05rem 0 0; font-size: .94rem; color: #e5e5ee; }
.message-deleted { margin: .05rem 0 0; color: var(--text-faint); font-size: .85rem; font-style: italic; }
.message-menu-button {
  position: absolute;
  top: .25rem;
  right: .4rem;
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border-color: var(--line-strong);
  border-radius: 6px;
  background: var(--bg-raise);
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
}
.message-menu-button[aria-expanded=true] { border-color: var(--accent-line); color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .message .message-menu-button { opacity: 0; }
  .message:hover .message-menu-button,
  .message:focus-within .message-menu-button,
  .message.tray-open .message-menu-button { opacity: 1; }
}
.message-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .6rem;
  margin: .4rem 0 .2rem;
  padding: .4rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg-raise);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.tray-reactions { display: flex; flex-wrap: wrap; gap: .1rem; }
.reaction-pick { padding: .2rem .35rem; border-color: transparent; background: transparent; font-size: 1.05rem; line-height: 1.2; }
.reaction-pick:hover { background: var(--bg-hover); }
.reaction-pick.chosen { border-color: var(--accent-line); background: var(--accent-soft); }
.tray-actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.tray-actions button { padding: .32rem .65rem; font-size: .8rem; }
.reactions { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0 .1rem; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .12rem .5rem;
  border-color: #393e4e;
  border-radius: 999px;
  background: #20232d;
  font-size: .8rem;
}
.reaction.chosen { border-color: var(--accent-line); background: var(--accent-soft); }
.reaction:disabled { cursor: default; opacity: .75; }
.reaction .count { font-weight: 600; font-variant-numeric: tabular-nums; }
.message.compact {
  grid-template-columns: minmax(0, 1fr);
  margin: .45rem 0;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  background: var(--bg-card);
}
.message.compact .avatar { display: none; }
.message.compact .message-body { font-size: .875rem; }

/* Composer */
.composer-wrap { display: flex; flex: none; flex-direction: column; padding: .3rem 1.25rem 1rem; }
.composer { border: 1px solid var(--line-strong); border-radius: 12px; background: #1f222c; overflow: hidden; }
.composer:focus-within { border-color: var(--accent-line); }
.composer:has(textarea:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.composer.disabled { opacity: .75; }
.composer textarea {
  display: block;
  min-height: 2.9rem;
  max-height: 14rem;
  padding: .7rem .9rem .3rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  resize: none;
  field-sizing: content;
}
.composer textarea:focus-visible { outline: none; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .3rem .45rem .45rem .9rem; }
.composer-bottom button { margin: 0; padding: .45rem 1.15rem; }
.composer-bottom .attach-button { flex: none; padding: .45rem .65rem; font-size: .8rem; }
.attach-icon { display: none; }
.selected-file { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; padding: .35rem .7rem; border-bottom: 1px solid var(--line); font-size: .8rem; }
.selected-file bdi { min-width: 0; overflow-wrap: anywhere; }
.selected-file button { margin: 0 0 0 auto; padding: .25rem .55rem; }
.attachment { width: fit-content; max-width: 100%; margin: .4rem 0; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-card); }
.attachment-preview { display: block; max-width: min(100%, 320px); max-height: 220px; object-fit: contain; width: auto; height: auto; border-radius: 4px; }
.attachment-info { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .65rem; font-size: .8rem; }
.attachment-info bdi { min-width: 0; overflow-wrap: anywhere; }
.attachment-info button { margin: .15rem 0; padding: .3rem .6rem; }
.composer-hint { color: var(--text-faint); font-size: .72rem; }
.reply-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .2rem .35rem .2rem .9rem;
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
  color: #e3dbff;
  font-size: .8rem;
}
.reply-indicator .icon-button { width: 1.9rem; height: 1.9rem; margin: 0; }
.pending {
  flex: 0 1 auto;
  min-height: 0;
  margin-bottom: .5rem;
  padding: .55rem .75rem;
  overflow-y: auto;
  border: 1px solid #4d4568;
  border-radius: 10px;
  background: #211f2c;
  font-size: .85rem;
}
.pending.uncertain { border-color: var(--warn-line); background: var(--warn-bg); }
.pending.rejected { border-color: var(--danger-line); background: var(--danger-bg); }
.pending-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .75rem; }
.pending-title { margin: 0; font-size: .8rem; font-weight: 650; }
.pending-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.pending-actions button { margin: 0; padding: .32rem .7rem; font-size: .8rem; }
.pending pre { max-height: 6rem; margin: .4rem 0 .2rem; padding: .35rem .55rem; overflow: auto; border-radius: 6px; background: rgba(0, 0, 0, .25); }
.pending .error-text { margin: .3rem 0 0; }
.pending .muted { margin: .2rem 0 0; font-size: .75rem; }
.error-text { color: #ffc0cd; }

/* Empty states */
.empty-state, .welcome {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 2rem 1.5rem;
  overflow-y: auto;
  text-align: center;
}
.empty-state > :first-child, .welcome > :first-child { margin-top: auto; }
.empty-state > :last-child, .welcome > :last-child { margin-bottom: auto; }
.empty-state h2 { margin: 0 0 .4rem; }
.empty-state p { max-width: 420px; margin: 0; color: var(--text-dim); }
.welcome-icon { color: var(--accent); font-size: 3rem; line-height: 1; }
.welcome h2 { margin: .75rem 0 .4rem; font-size: 1.8rem; letter-spacing: -.02em; }
.welcome > p { max-width: 460px; margin: 0 0 1rem; color: var(--text-dim); }
.welcome .setup {
  width: min(100%, 620px);
  margin: .5rem 0 1rem;
  padding: .35rem .5rem .5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-side);
  text-align: left;
}
.welcome .setup summary { color: var(--text); font-weight: 600; }
.welcome .setup-forms { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .5rem 1rem; }
.welcome > .muted { color: var(--text-faint); }

/* Detail panel */
.detail-panel {
  grid-column: 4;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100dvh;
  background: var(--bg-side);
  border-left: 1px solid var(--line);
}
.panel-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 56px;
  padding: .5rem .6rem .5rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.panel-header h2 { margin: 0; font-size: 1rem; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: .6rem 1.1rem 1.25rem; }
.panel-toolbar { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; margin: .25rem 0 .75rem; }
.panel-toolbar p { margin: 0; }
.panel-intro { margin: .25rem 0 .5rem; color: var(--text-faint); font-size: .8rem; }
.panel-empty { margin: 1.25rem 0; color: var(--text-faint); font-size: .85rem; text-align: center; }
.panel-cta { width: 100%; margin-top: .75rem; }
.panel-section { padding: .5rem 0 .9rem; border-top: 1px solid var(--line); }
.panel-section h3 { margin: .6rem 0 .5rem; font-size: .9rem; }
.panel-section > .muted { margin: 0 0 .5rem; }
.detail-panel .setup, .event-editor.setup { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-card); }
.detail-panel .setup summary { color: var(--text); font-weight: 600; }
.detail-panel form { padding: 0 .55rem .6rem; }

.event-card, .member, .role-editor {
  margin: .6rem 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-card);
}
.event-card { padding: .75rem .85rem .5rem; }
.event-card.ended { opacity: .85; }
.event-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.event-head h3 { margin: 0; font-size: .95rem; }
.event-time { margin: .35rem 0 0; font-size: .85rem; font-weight: 600; }
.event-time + .muted { margin: .05rem 0 .3rem; }
.event-description { color: var(--text-dim); font-size: .86rem; }
.event-counts { margin: .35rem 0; color: var(--text-dim); font-size: .8rem; }
.rsvp { display: flex; flex-wrap: wrap; gap: .35rem; }
.rsvp button { padding: .32rem .7rem; font-size: .8rem; }
.event-owner-tools { margin-top: .6rem; padding-top: .2rem; border-top: 1px solid var(--line); }
.event-owner-tools details { margin: .2rem 0; }
.event-owner-tools form, .danger-zone > p, .danger-zone > button { margin-left: .55rem; margin-right: .55rem; }
.danger-zone > p { margin-top: .2rem; font-size: .8rem; color: var(--text-dim); }
.danger-zone > button { margin-bottom: .6rem; }
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.field-pair > *, .field-pair input { min-width: 0; }

.member { padding: .6rem .7rem; min-width: 0; }
.member-name { display: flex; align-items: center; gap: .5rem; }
.member-roles { display: flex; flex-wrap: wrap; gap: .35rem; margin: .45rem 0 .1rem; }
.chip { padding: .28rem .6rem; border-radius: 999px; font-size: .78rem; }
.role-editor { padding: .1rem .5rem; font-size: .85rem; }
.role-editor > summary { color: var(--text); font-weight: 600; }
.role-editor form { padding: 0 .2rem .6rem; }
.role-editor form button { display: block; width: 100%; margin-top: .45rem; }
.role-editor > .muted { margin: 0 .2rem .3rem; overflow-wrap: anywhere; }
.inline-form { margin-top: .6rem; padding: 0 !important; }
.input-row { display: flex; gap: .4rem; }
.input-row input { flex: 1; min-width: 0; }
.input-row button { flex: none; margin: 0; white-space: nowrap; }
.invitation-result { margin-top: .4rem; }
.invitation-result input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Login */
.login-shell { display: grid; place-items: center; min-height: 100dvh; padding: 1.5rem; background: radial-gradient(ellipse at top, #302842 0%, var(--bg) 70%); }
.login-card { width: 100%; max-width: 480px; padding: 2.3rem; border: 1px solid #4a435d; border-radius: 20px; background: #22242e; }
.login-card h1 { font-size: 2.25rem; letter-spacing: -.04em; }
.login-card p { color: #c1c1d0; font-size: .9rem; }
.login-card .primary { width: 100%; margin: 1rem 0; padding: .65rem; }
.login-card .banner { display: block; margin: 1rem 0; }
.eyebrow { margin-top: 1.5rem; color: #d6c9ff !important; font-size: .65rem !important; letter-spacing: .13em; }

@media (min-width: 1600px) {
  .topbar, .timeline, .composer-wrap, .search-results, .banners { padding-left: 2.5rem; padding-right: 2.5rem; }
}

@media (max-width: 1100px) {
  .app-shell, .app-shell:has(.detail-panel) { grid-template-columns: 64px 220px minmax(0, 1fr); }
  .detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: min(400px, 92vw);
    box-shadow: -15px 0 60px rgba(0, 0, 0, .6);
  }
  .topbar, .timeline, .composer-wrap, .search-results, .banners { padding-left: 1rem; padding-right: 1rem; }
}

@media (max-width: 650px) {
  .app-shell, .app-shell:has(.detail-panel) { grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: 100dvh; }
  .rail { grid-column: 1; grid-row: 1; padding: .5rem 0; }
  .community.selected::before { left: -6px; }
  .mobile-only { display: inline-grid; }
  button, summary { min-height: 44px; min-width: 44px; }
  .icon-button { width: 44px; height: 44px; }
  .sidebar { display: none; }
  .nav-open .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 56px;
    z-index: 20;
    display: flex;
    box-shadow: 0 0 50px rgba(0, 0, 0, .6);
  }
  /* The overlay covers the conversation; keep covered controls out of the tab order. */
  .nav-open .workspace { visibility: hidden; }
  .sidebar-footer { display: none; }
  .topbar { gap: .35rem .4rem; padding: .35rem .5rem; }
  .topbar-title { flex: 1 1 0; }
  .topbar h2 { font-size: .95rem; }
  .topbar-meta { display: none; }
  .status-pill { padding: .3rem; border: 0; }
  .status-pill .status-text, .wide-only, .results-header .muted {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .pins-button { padding: .3rem .6rem; }
  .searchbar { order: 10; flex: 1 1 100%; max-width: none; }
  .searchbar button { padding: .3rem .6rem; font-size: .8rem; }
  /*
   * Grid rows, not flex leftovers, allocate the crowded mobile workspace. The
   * header and composer rows keep their full content height (automatic minimums,
   * so neither may be a scroll container or set a fixed min-height), and the
   * timeline row reserves part of the viewport. Banners, search results and a
   * pending send share only the remaining space, each up to its own cap, and
   * scroll internally, so platform font metrics cannot squeeze the conversation
   * or push the composer out of view.
   */
  .workspace {
    --timeline-reserve: max(5rem, 26dvh);
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(var(--timeline-reserve), 1fr) auto auto auto;
  }
  .topbar { grid-row: 1; min-height: auto; }
  .banners { grid-row: 2; min-height: 0; max-height: 18dvh; padding: .35rem .5rem 0; gap: .3rem; }
  .search-results { grid-row: 3; min-height: 0; max-height: 20dvh; padding: .1rem .5rem .35rem; }
  .timeline, .empty-state, .welcome { grid-row: 4; }
  .composer-wrap { display: contents; }
  .pending { grid-row: 5; min-height: 0; max-height: 21dvh; margin: .25rem .5rem 0; padding: .4rem .55rem; }
  .expressive-tools { grid-row: 6; margin: 0 .5rem; padding: 0; }
  .composer { grid-row: 7; margin: .25rem .5rem .5rem; overflow: clip; }
  .banner { padding: .3rem .3rem .3rem .6rem; font-size: .78rem; }
  .dismiss { width: 44px; height: 44px; margin: -.3rem -.3rem -.3rem 0; }
  .results-header h3 { margin: .25rem 0; }
  .timeline { padding: .25rem .6rem .5rem; }
  .message { grid-template-columns: minmax(0, 1fr); margin-left: -.35rem; margin-right: -.35rem; padding-left: .35rem; padding-right: .35rem; }
  .message .avatar, .gutter-time { display: none; }
  .message.has-actions .message-content { padding-right: 2.9rem; }
  .message-menu-button { top: .1rem; right: .1rem; width: 44px; height: 44px; }
  .reaction-pick { width: 44px; }
  .composer { display: flex; flex-wrap: wrap; align-items: flex-end; }
  .reply-indicator { flex: 1 1 100%; }
  .selected-file { flex: 1 1 100%; max-width: 100%; }
  .composer textarea { flex: 1 1 0; width: auto; min-width: 0; min-height: 2.75rem; max-height: 7.5rem; padding: .6rem .7rem; }
  .composer-bottom { flex: none; gap: .25rem; padding: .25rem; }
  .composer-hint {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .composer-bottom button { padding: .3rem .9rem; }
  .composer-bottom .attach-button { width: 44px; padding: 0; }
  .attach-icon { display: inline; font-size: 1.35rem; }
  .attach-label { display: none; }
  .pending-actions button { padding: .3rem .8rem; }
  .pending pre { max-height: 3.2rem; }
  .welcome { padding: 1.25rem 1rem; }
  .welcome h2 { font-size: 1.45rem; }
  .login-card { padding: 1.5rem; }
  .login-card h1 { font-size: 1.9rem; }
}

@media (max-width: 650px) and (max-height: 720px) {
  .workspace { --timeline-reserve: max(4rem, 24dvh); }
  .banners { max-height: 16dvh; }
  .search-results { max-height: 16dvh; }
  .pending { max-height: 18dvh; }
}

@media (hover: none) {
  .message.has-actions .message-content { padding-right: 2.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
