/* ============================================================
   TNC Platform — design system matched to thenorthcop.com
   Near-black / dark grey surfaces, red brand accents.
   ============================================================ */

:root {
  /* Brand (from thenorthcop.com) */
  --brand-1: #ff2d55;
  --brand-2: #ff7a7a;
  --grad-brand: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  --brand-soft: rgba(255, 45, 85, 0.12);

  /* Surfaces */
  --bg: #07070a;
  --bg-soft: #0e0e13;
  --bg-raised: #14141c;
  --bg-input: #0b0b10;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hi: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.16);

  /* Text */
  --text: #f5f5f7;
  --text-muted: #a0a0ab;
  --text-faint: #6b6b78;

  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --success: #3ddc97;
  --success-soft: rgba(61, 220, 151, 0.12);
  --warning: #ffb347;
  --link: #ff7a7a;

  --scroll-thumb-idle: rgba(255, 255, 255, 0.06);
  --scroll-thumb: rgba(255, 255, 255, 0.14);
  --scroll-thumb-hover: rgba(255, 122, 122, 0.55);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;

  --radius-sm: 10px;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  color-scheme: dark;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--text-muted); }

h1, h2, h3, h4 { font-family: var(--font-display); }

/* ---------- Scrollbars ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* The transparent border + content-box clip insets the thumb so it reads as a
   slim pill instead of filling the whole gutter. */
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:active {
  background: var(--brand-1);
  background-clip: content-box;
}

/* Containers keep the thumb quiet until the pointer is inside them. */
.sidebar:hover .sidebar-nav,
.main:hover .messages { scrollbar-color: var(--scroll-thumb-hover) transparent; }

.sidebar-nav::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb { background: var(--scroll-thumb-idle); background-clip: content-box; }
.sidebar:hover .sidebar-nav::-webkit-scrollbar-thumb,
.main:hover .messages::-webkit-scrollbar-thumb { background: var(--scroll-thumb); background-clip: content-box; }
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.messages::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: content-box; }
.sidebar-nav::-webkit-scrollbar-thumb:active,
.messages::-webkit-scrollbar-thumb:active { background: var(--brand-1); background-clip: content-box; }

/* ---------- Buttons & forms ---------- */

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
  text-align: center;
  transition: background .15s, border-color .15s, filter .15s;
}
.btn:hover { text-decoration: none; border-color: var(--border-hi); background: var(--surface-hi); }
.btn-primary {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { background: var(--grad-brand); filter: brightness(1.1); }
.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

input[type="text"], input[type="password"], input[type="number"], input[type="email"],
input[type="search"], input[type="file"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  margin: 4px 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-sans);
}
input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.inline-form { display: inline; }

/* ---------- Flashes ---------- */

.flashes { margin: 12px 0; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-1);
}
.flash-error { border-left-color: var(--danger); }
.flash-success { border-left-color: var(--success); }

/* ---------- Auth pages ---------- */

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 55% 40% at 12% 0%, rgba(255, 45, 85, .12), transparent),
    radial-gradient(ellipse 45% 35% at 92% 100%, rgba(179, 0, 34, .14), transparent),
    var(--bg);
}
.auth-card {
  width: 430px;
  max-width: 92vw;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.auth-logo { display: block; height: 44px; max-width: 60%; object-fit: contain; margin-bottom: 18px; }
.auth-card form { margin-top: 18px; }
.auth-card .btn-primary { width: 100%; margin-top: 8px; }
.auth-card .cf-turnstile { margin: 14px 0 4px; }
.btn-connect { display: block; width: 100%; margin: 10px 0; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.btn-discord {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: #5865F2;
  border-color: #5865F2;
  color: #fff;
}
.btn-discord:hover {
  background: #4752c4;
  border-color: #4752c4;
  color: #fff;
  filter: none;
}

.access-state {
  margin: 4px 0 18px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  border-left: 3px solid var(--border);
  font-size: 14px;
}
.access-state.access-open { border-left-color: var(--success); }
.access-state.access-closed { border-left-color: var(--warning); }

.standby-step {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.standby-step h2 { margin: 0 0 6px; font-size: 15px; }
.standby-ready {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  border-left: 3px solid var(--success);
  font-size: 14px;
}

/* ---------- App shell ---------- */

body.app { overflow: hidden; }
.app-shell { display: flex; height: 100vh; }

.sidebar {
  width: 264px;
  min-width: 264px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  display: flex;
  align-items: center;
  padding: 18px 18px 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--border);
}
/* Stand-in mark, used until a logo is uploaded in the admin panel. */
.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--grad-brand);
  margin-right: 10px;
  flex-shrink: 0;
}
.brand-logo {
  height: 22px;
  max-width: 96px;
  object-fit: contain;
  margin-right: 10px;
  flex-shrink: 0;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.sidebar-empty { color: var(--text-faint); padding: 12px; font-size: 14px; }

.category { margin-bottom: 20px; }
.category-name {
  display: flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px 6px;
  letter-spacing: .08em;
}
.category-name { cursor: pointer; user-select: none; }
.category-name:hover { color: var(--text-muted); }
.cat-caret {
  font-size: 10px;
  line-height: 1;
  margin-right: 4px;
  transition: transform .12s ease;
}
.category.collapsed .cat-caret { transform: rotate(-90deg); }
/* Collapsing hides the channels you have caught up on. The open one and anything
   waiting to be read stay listed, so nothing is missed behind a closed category. */
.category.collapsed .channel-row:not(.active):not(.unread):not(.mention) { display: none; }
.category.collapsed .quick-add { display: none; }

.cat-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-add {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
  visibility: hidden;
}
.category:hover .cat-add { visibility: visible; }
.cat-add:hover { color: var(--brand-2); }

.quick-add { margin: 0 6px 6px; }
.quick-add.hidden { display: none; }
.quick-add input {
  margin: 0;
  padding: 6px 10px;
  font-size: 13px;
}

.channel-row {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  margin-bottom: 1px;
}

/* Unread marker: white dot, red when a message pings you. */
.unread-dot { display: none; }
.channel-row.unread > .channel-link > .unread-dot,
.channel-row.mention > .channel-link > .unread-dot {
  display: block;
  position: absolute;
  left: -5px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: #fff;
}
.channel-row.mention > .channel-link > .unread-dot {
  background: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(255, 70, 85, .18);
}
.channel-row.unread { color: var(--text); }
.channel-row.unread .channel-name { font-weight: 700; }
.channel-row.mention .channel-name { font-weight: 700; color: var(--brand-2); }

/* Muted channels sit back until you open them. */
.channel-row.muted:not(.active) > .channel-link { opacity: .45; }
.channel-row.muted:hover > .channel-link { opacity: .75; }
.channel-row:hover { background: var(--surface); color: var(--text); }
.channel-row.active {
  background: var(--brand-soft);
  color: var(--brand-2);
}
.channel-row.active .channel-link { color: var(--brand-2); font-weight: 600; }
.channel-row.dragging, .category.dragging { opacity: .4; }
.channel-row[draggable="true"] { cursor: grab; }

.channel-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  flex: 1;
  min-width: 0;
  color: inherit;
  font-weight: 500;
}
.channel-link:hover { color: inherit; text-decoration: none; }
.channel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-link .hash { color: var(--text-faint); font-weight: 400; }
.channel-row.active .hash { color: var(--brand-1); }
.badge-mirror { margin-left: auto; font-size: 12px; color: var(--text-faint); }

.badge-lock { font-size: 10px; color: var(--text-faint); opacity: .8; }
.badge-lock.staff { color: var(--brand-2); opacity: 1; }

.chan-edit {
  color: var(--text-faint);
  font-size: 13px;
  padding: 4px 8px 4px 2px;
  visibility: hidden;
}
.channel-row:hover .chan-edit { visibility: visible; }
.chan-edit:hover { color: var(--brand-2); text-decoration: none; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, .3);
}
.avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-fallback {
  background: var(--grad-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: var(--radius-sm);
  color: inherit;
}
.user-card:hover { background: var(--surface-hi); text-decoration: none; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-faint); text-transform: capitalize; }

input[type="file"] { padding: 8px 10px; font-size: 13px; color: var(--text-muted); }
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 12px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--brand-1); color: var(--brand-2); }

.avatar-lg { width: 72px; height: 72px; font-size: 26px; border-radius: var(--radius); }
.profile-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.profile-head-fields { flex: 1; min-width: 0; }
.profile-head-fields label { margin-top: 0; }
.field-hint { margin: -6px 0 14px; font-size: 12px; color: var(--text-faint); }
.logo-preview {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 10px;
}
.logo-preview-empty { display: flex; align-items: center; justify-content: center; }
.logo-preview-empty .brand-mark { width: 26px; height: 26px; margin: 0; border-radius: 7px; }
input:disabled { opacity: .6; cursor: not-allowed; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; padding: 6px; border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--surface-hi); color: var(--text); text-decoration: none; }

/* ---------- Main pane ---------- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg);
}

/* Swapped in on its own when you change channel, so the page never reloads. */
.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: pane-in .12s ease-out;
}
@keyframes pane-in { from { opacity: 0; } to { opacity: 1; } }

/* Only shown when a channel takes a moment to arrive. */
.main.switching .pane { opacity: .4; transition: opacity .1s ease; }
.main.switching::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 2;
  background: linear-gradient(90deg, transparent, var(--brand-1), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: pane-progress 1s ease-in-out infinite;
}
@keyframes pane-progress {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

.channel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  min-width: 0;
}
.channel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.channel-header .hash { color: var(--brand-1); font-size: 18px; font-weight: 600; }
.channel-title { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
.channel-topic {
  color: var(--text-muted);
  font-size: 13px;
  border-left: 1px solid var(--border-hi);
  padding-left: 14px;
  margin-left: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.channel-header-search {
  position: relative;
  flex-shrink: 0;
}

.mentions-bell { position: relative; flex-shrink: 0; }
.mentions-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.mentions-toggle:hover {
  background: var(--surface-hi);
  border-color: var(--border-hi);
  color: var(--text);
}
.mentions-toggle.has-pings {
  color: var(--brand-2);
  border-color: rgba(255, 45, 85, .35);
  background: var(--brand-soft);
}
.mentions-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--brand-1);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-soft);
}
.mentions-badge.hidden { display: none; }
.mentions-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(380px, calc(100vw - 40px));
  max-height: min(420px, 70vh);
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  z-index: 30;
}
.mentions-panel.hidden { display: none; }
.mentions-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.mentions-panel-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.01em;
}
.mentions-clear {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-faint);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.mentions-clear:hover { color: var(--brand-2); }
.mentions-clear.hidden { display: none; }
.mentions-status {
  font-size: 12px;
  margin-bottom: 6px;
}
.mentions-results {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  margin: 0 -4px;
}
.mentions-hit {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.mentions-hit:hover,
.mentions-hit:focus {
  background: var(--surface-hi);
  outline: none;
}
.mentions-hit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.mentions-hit-channel {
  font-weight: 700;
  font-size: 13px;
  color: var(--brand-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mentions-hit-time {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
}
.mentions-hit-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--text-muted);
}
.mentions-hit-role {
  color: var(--brand-2);
  font-weight: 600;
}
.mentions-hit-preview {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.channel-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  width: clamp(180px, 24vw, 260px);
  margin: 0;
  padding: 0 12px 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-faint);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  cursor: text;
}
.channel-search-field:hover {
  border-color: var(--border-hi);
  background: var(--bg-raised);
  color: var(--text-muted);
}
.channel-search-field:focus-within {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px var(--brand-soft);
  background: var(--bg-raised);
  color: var(--brand-2);
}
.channel-search-icon {
  display: flex;
  flex-shrink: 0;
  line-height: 0;
}
/* Beat global input[type="search"] so the pill is the only box. */
.channel-search-field input.channel-search-input[type="search"] {
  flex: 1;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-sans);
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}
.channel-search-field input.channel-search-input[type="search"]::placeholder {
  color: var(--text-faint);
}
.channel-search-field input.channel-search-input[type="search"]:focus {
  outline: none;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.channel-search-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(380px, calc(100vw - 40px));
  max-height: min(420px, 70vh);
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  z-index: 30;
}
.channel-search-panel.hidden { display: none; }
.channel-search-channel-label {
  margin: 0 0 4px;
  font-size: 11px;
}
.channel-search-channel {
  width: 100%;
  margin: 0 0 10px;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.channel-search-status {
  font-size: 12px;
  margin-bottom: 6px;
}
.channel-search-results {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  margin: 0 -4px;
}
.channel-search-hit {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.channel-search-hit:hover,
.channel-search-hit:focus {
  background: var(--surface-hi);
  outline: none;
}
.channel-search-hit-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.channel-search-hit-author {
  font-weight: 600;
  font-size: 13px;
}
.channel-search-hit-time {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
}
.channel-search-hit-preview {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.messages { flex: 1; overflow-y: auto; padding: 20px 20px 8px; }
.load-sentinel { height: 1px; }

.message {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 6px 10px;
  margin-top: 10px;
  border-radius: var(--radius-sm);
}
.message:hover { background: var(--surface); }
.message.pinged {
  background: rgba(255, 70, 85, .07);
  box-shadow: inset 2px 0 0 var(--brand-1);
}

.mention {
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  white-space: nowrap;
}
/* Discord-style role ping pill (blurple wash). */
.mention.mention-role {
  color: #c9cdfb;
  background: rgba(88, 101, 242, 0.3);
}
.mention.mention-me { color: var(--brand-2); background: var(--brand-soft); }
.mention.mention-role.mention-me {
  color: #fff;
  background: rgba(88, 101, 242, 0.55);
}

.channel-mention {
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--link);
  background: var(--brand-soft);
  text-decoration: none;
}
.channel-mention:hover { text-decoration: underline; }

.message-jump {
  display: flex;
  align-items: baseline;
  gap: 0;
  max-width: 100%;
  width: fit-content;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
}
.message-jump:hover {
  background: var(--surface-hi);
  border-color: var(--border-hi);
  text-decoration: none;
}
.message-jump-channel {
  font-weight: 700;
  color: var(--link);
  flex-shrink: 0;
}
.message-jump-sep { color: var(--text-faint); }
.message-jump-preview {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.message-jump.unavailable { opacity: .55; cursor: default; }
.message-jump.unavailable .message-jump-channel { color: var(--text-muted); }

.message-highlight {
  animation: message-flash 1.6s ease-out;
}
@keyframes message-flash {
  0%, 35% { background: var(--brand-soft); box-shadow: inset 2px 0 0 var(--brand-1); }
  100% { background: transparent; box-shadow: none; }
}

.message-actions {
  position: absolute;
  top: -10px;
  right: 10px;
  display: none;
  gap: 2px;
  padding: 2px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.message:hover .message-actions { display: flex; }
.msg-action {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
}
.msg-action:hover { background: var(--surface-hi); color: var(--text); }
.msg-action.danger:hover { background: var(--danger-soft); color: var(--danger); }

.edit-form { margin-top: 6px; }
.edit-form .composer-input-wrap { width: 100%; }
.edit-form textarea {
  width: 100%;
  margin: 0;
  resize: none;
  background: var(--bg-input);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.5;
}
.edit-hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.message .avatar { width: 38px; height: 38px; margin-top: 2px; }
.message-body { flex: 1; min-width: 0; }
.message-meta { display: flex; align-items: baseline; gap: 8px; }
.message-author { font-weight: 600; color: var(--text); }
.message-time {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.message-edited { font-size: 10px; color: var(--text-faint); }
.message-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-hi);
  border-radius: 4px;
  padding: 2px 5px;
}
.message-content { line-height: 1.5; word-wrap: break-word; white-space: normal; margin-top: 1px; }
.embed-description,
.embed-field-value { white-space: normal; }

.md-line { white-space: pre-wrap; word-wrap: break-word; }
.md-break { height: .55em; }
.md-heading {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.25;
  margin: .35em 0 .15em;
}
.md-h1 { font-size: 1.5em; }
.md-h2 { font-size: 1.25em; }
.md-h3 { font-size: 1.1em; }
.md-subtext {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
  margin: .15em 0;
}
.md-quote {
  margin: .35em 0;
  padding: .2em 0 .2em 12px;
  border-left: 3px solid var(--border-hi);
  color: var(--text-muted);
  white-space: pre-wrap;
}
.md-list {
  margin: .35em 0 .35em 1.1em;
  padding: 0;
}
.md-list .md-list { margin: .15em 0 .15em 1.1em; }
.md-list li { margin: .15em 0; }
.md-inline-code,
code.md-inline-code {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.md-codeblock {
  position: relative;
  margin: .45em 0;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}
.md-codeblock code {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
}
.md-codeblock-lang {
  display: block;
  font-size: 11px;
  font-family: var(--font-sans);
  color: var(--text-faint);
  text-transform: lowercase;
  margin-bottom: 6px;
}
.md-codeblock-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  font-family: var(--font-sans);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
}
.md-codeblock-copy:hover {
  color: var(--text);
  background: var(--surface-hi);
}
.md-spoiler {
  background: var(--text);
  color: transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}
.md-spoiler.revealed {
  background: var(--surface-hi);
  color: inherit;
  cursor: text;
}
.message-content code {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}

/* ---------- Alert / embed cards ---------- */

.embed {
  display: flex;
  max-width: 540px;
  margin-top: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.embed-accent { width: 4px; flex-shrink: 0; background: var(--grad-brand); }
.embed-inner { padding: 12px 16px 14px; flex: 1; min-width: 0; position: relative; }
.embed-author { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.embed-author img { width: 20px; height: 20px; border-radius: 5px; }
.embed-title { font-family: var(--font-display); font-weight: 700; margin-bottom: 4px; color: var(--text); letter-spacing: -.01em; }
.embed-title a { color: var(--link); }
.embed-description { font-size: 14px; color: var(--text); line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.embed-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.embed-field { min-width: 0; }
.embed-field.full { grid-column: 1 / -1; }
.embed-field-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 2px;
}
.embed-field-value { font-size: 13px; color: var(--text); white-space: pre-wrap; word-wrap: break-word; }
.embed-thumbnail {
  float: right;
  max-width: 80px;
  max-height: 80px;
  border-radius: var(--radius-sm);
  margin-left: 12px;
}
.embed-image { max-width: 100%; border-radius: var(--radius-sm); margin-top: 12px; display: block; }
.embed-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-faint);
}
.embed-footer img { width: 15px; height: 15px; border-radius: 4px; }

.attachment-link { display: block; width: fit-content; }
.attachment-image {
  max-width: min(400px, 100%);
  max-height: 300px;
  width: auto;
  height: auto;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  display: block;
  border: 1px solid var(--border);
}
.attachment-link:hover .attachment-image { border-color: var(--border-hi); }
.attachment-file {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ---------- Composer ---------- */

.composer {
  display: flex;
  gap: 10px;
  padding: 0 20px 20px;
  align-items: flex-end;
}
.composer-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.composer textarea,
.composer-input-wrap .composer-input {
  width: 100%;
  flex: 1;
  resize: none;
  margin: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 160px;
}
.composer .btn { margin-bottom: 1px; }

.mention-suggest {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
  z-index: 40;
}
.mention-suggest.hidden { display: none; }
.mention-suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mention-suggest-item:hover,
.mention-suggest-item.is-active {
  background: var(--surface-hi);
  outline: none;
}
.mention-suggest-avatar,
.mention-suggest-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand-2);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
}
.mention-suggest-icon {
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-display);
}
.mention-suggest-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mention-suggest-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mention-suggest-primary {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mention-suggest-secondary {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-attach {
  flex-shrink: 0;
  height: 44px;
  width: 44px;
  margin-bottom: 1px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.composer-attach:hover { color: var(--text); border-color: var(--border-hi); }

.composer-files.hidden,
.composer-previews.hidden,
.composer-error.hidden { display: none; }

.composer-previews { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 20px 12px; }
.composer-preview { position: relative; }
.composer-preview img {
  display: block;
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hi);
}
.composer-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-hi);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.composer-preview-remove:hover { color: var(--danger); border-color: var(--danger); }

.composer-error { padding: 0 20px 8px; font-size: 13px; color: var(--danger); }

/* Dropping an image anywhere in the channel adds it to the composer. */
.pane.dropping { outline: 2px dashed var(--border-hi); outline-offset: -8px; }

.composer.readonly {
  display: block;
  background: var(--bg-input);
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius-sm);
  margin: 0 20px 20px;
  padding: 12px 14px;
  color: var(--text-faint);
  font-size: 14px;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ---------- Admin ---------- */

body.admin-page { overflow-y: auto; }
.admin-shell {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 64px;
  box-sizing: border-box;
}
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
  width: 100%;
  box-sizing: border-box;
}
.admin-nav .brand {
  font-family: var(--font-display);
  font-weight: 700;
  margin-right: auto;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.admin-nav .brand .brand-logo { height: 20px; }
.admin-nav a {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.admin-nav a.active { color: var(--brand-2); }
.admin-nav a:hover { color: var(--text); text-decoration: none; }

.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}
.card h2 { margin-top: 0; font-size: 16px; letter-spacing: -.01em; }
.card h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.backfill-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.backfill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 280px;
}
.backfill-row input[type="number"] { width: 100px; margin: 0; }
.backfill-form .btn { margin-top: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
th {
  text-align: left;
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 8px;
}
td { padding: 9px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.admin-shell table td:last-child,
.admin-shell table th:last-child {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}
.admin-shell table td:last-child form {
  display: inline;
  margin: 0;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat .num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}
.stat .lbl { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 140px; }
.form-row .btn { margin-bottom: 14px; }

.mirror-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mirror-bar .checkbox-row {
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.mirror-bar .muted { font-size: 12px; }

.mirror-linked { color: var(--text-muted); }
.mirror-suggest {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
}
.mirror-suggest input { width: auto; margin: 0; accent-color: var(--brand-1); }
.mirror-suggest.exact { color: var(--text); }
.mirror-suggest.fuzzy { color: var(--text-faint); }
.mirror-suggest .pill { padding: 1px 7px; font-size: 10px; }

.search-field { display: flex; gap: 10px; align-items: center; }
.search-field input { flex: 1; margin-bottom: 0; }
.search-field .btn { white-space: nowrap; }

.admin-users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.admin-users-header h2 { margin: 0; }
.admin-users-search {
  flex: 1 1 280px;
  max-width: 420px;
  margin-left: auto;
}
.admin-users-search input[type="search"] {
  min-width: 0;
}
.admin-users-count {
  margin: 0 0 12px;
  font-size: 13px;
}

#discord-channel-select { margin-top: 10px; padding: 6px; }
#discord-channel-select option { padding: 5px 8px; border-radius: var(--radius-sm); }
#discord-channel-select option:checked {
  background: var(--brand-soft) linear-gradient(0deg, var(--brand-soft), var(--brand-soft));
  color: var(--text);
  font-weight: 600;
}
#discord-search-status { margin: 6px 0 0; font-size: 12px; }
.suggestion { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.suggestion strong { color: var(--text); }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.pill.verified { background: var(--success-soft); border-color: transparent; color: var(--success); }
.pill.unverified { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.pill.role-owner { background: var(--brand-soft); border-color: transparent; color: var(--brand-1); }
.pill.role-admin { background: var(--brand-soft); border-color: transparent; color: var(--brand-2); }
.pill.staff-pill {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.access-select { max-width: 230px; margin: 0; padding: 6px 8px; font-size: 12px; }
.access-note { margin-left: 8px; font-size: 11px; color: var(--success); }
.access-note.error { color: var(--danger); }

/* ---------- Context menu ---------- */

.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 200px;
  padding: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .6);
}
.context-menu.hidden { display: none; }
.context-menu-label {
  padding: 4px 10px 8px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
}
.context-menu button:hover { background: var(--surface-hi); color: var(--text); }
.context-menu button.danger { color: var(--danger); }
.context-menu button.danger:hover { background: var(--danger-soft); color: var(--danger); }
.context-menu button.checked { color: var(--text); }
.context-menu button.checked::after { content: "\2713"; float: right; color: var(--brand-2); }
.context-menu-label.section {
  padding: 8px 10px 4px;
  margin-bottom: 0;
  border-bottom: none;
}
.context-menu hr {
  height: 1px;
  margin: 6px 4px;
  border: none;
  background: var(--border);
}

/* ---------- Modal dialogs ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .65);
}
.modal {
  width: 440px;
  max-width: 92vw;
  background: var(--bg-soft);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.modal h3 {
  margin: 0 0 10px;
  font-size: 18px;
  text-transform: none;
  letter-spacing: -.01em;
  color: var(--text);
}
.modal p { margin: 0 0 20px; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #2b0008;
}
.btn-danger-solid:hover { filter: brightness(1.08); border-color: var(--danger); }

/* ---------- Channel webhooks ---------- */

.webhook-list { list-style: none; padding: 0; margin: 0 0 22px; }
.webhook {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg);
}
.webhook.inactive { opacity: .6; }
.webhook-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.webhook-name { font-weight: 600; }
.webhook-stats { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.webhook-url { display: flex; gap: 8px; align-items: center; }
.webhook-url input {
  flex: 1;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}
.webhook-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.webhook-actions form { margin: 0; }
.webhook-new { border-top: 1px solid var(--border); padding-top: 16px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.checkbox-row input { width: auto; margin: 0; accent-color: var(--brand-1); }
.checkbox-row label { text-transform: none; font-size: 14px; font-weight: 500; color: var(--text); letter-spacing: 0; }

/* ---------- Mobile: collapsible channel sidebar ---------- */

.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }
.mobile-topbar { display: none; }

@media (max-width: 768px) {
  .app-shell { height: 100dvh; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: min(288px, 86vw);
    min-width: 0;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, .45);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  .app-shell.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
  }
  .sidebar-toggle:hover { background: var(--surface-hi); border-color: var(--border-hi); }
  .sidebar-toggle-bars,
  .sidebar-toggle-bars::before,
  .sidebar-toggle-bars::after {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    content: "";
  }
  .sidebar-toggle-bars { position: relative; }
  .sidebar-toggle-bars::before,
  .sidebar-toggle-bars::after { position: absolute; left: 0; }
  .sidebar-toggle-bars::before { top: -5px; }
  .sidebar-toggle-bars::after { top: 5px; }

  .channel-header {
    position: relative;
    padding: 10px 12px;
    gap: 10px;
  }
  .channel-topic { display: none; }

  /* Search collapses to an icon until tapped. */
  .channel-search-field {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    gap: 0;
    border-radius: var(--radius-sm);
  }
  .channel-search-field input.channel-search-input[type="search"] {
    width: 0;
    min-width: 0;
    flex: 0 0 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
  }
  .channel-header-search.is-expanded {
    position: absolute;
    top: 8px;
    right: 12px;
    left: 12px;
    z-index: 33;
    margin: 0;
  }
  .mentions-panel {
    width: min(380px, calc(100vw - 24px));
    right: -44px;
  }
  .channel-header-search.is-expanded .channel-search-field {
    width: 100%;
    height: auto;
    padding: 0 12px 0 11px;
    gap: 8px;
    border-radius: 999px;
  }
  .channel-header-search.is-expanded .channel-search-field input.channel-search-input[type="search"] {
    width: auto;
    flex: 1 1 auto;
    padding: 8px 0;
    opacity: 1;
    overflow: visible;
  }
  .channel-header-search.is-expanded .channel-search-panel {
    width: 100%;
  }

  .messages { padding: 14px 12px 8px; }
  .composer,
  .composer.readonly,
  .composer-previews { padding-left: 12px; padding-right: 12px; }
  .composer-error { padding-left: 12px; padding-right: 12px; }

  /* Keep the composer a single-line bar; long channel names were wrapping the
     placeholder and stretching the textarea on narrow phones. */
  .composer {
    gap: 8px;
    align-items: center;
    padding-bottom: 12px;
  }
  .composer-attach {
    width: 40px;
    height: 40px;
    margin-bottom: 0;
  }
  .composer .composer-send {
    margin-bottom: 0;
    padding: 0 12px;
    height: 40px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .composer textarea,
  .composer-input-wrap .composer-input {
    padding: 9px 12px;
    min-height: 40px;
    line-height: 1.35;
    overflow-x: hidden;
  }
  .composer textarea:placeholder-shown,
  .composer-input-wrap .composer-input:placeholder-shown {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    flex-shrink: 0;
  }
  .mobile-topbar-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -.01em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Touch devices don't hover — keep edit/add controls reachable. */
  .cat-add,
  .chan-edit { visibility: visible; }
}

/* ---------- Public vault share page ---------- */

body.public-vault {
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(255, 45, 85, 0.16), transparent 55%),
    radial-gradient(700px 360px at 90% 0%, rgba(255, 122, 122, 0.10), transparent 50%),
    var(--bg);
}

.public-vault-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.public-vault-header {
  margin-bottom: 22px;
}

.public-vault-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 18px;
}

.public-vault-brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
}

.public-vault-brand:hover { text-decoration: none; opacity: 0.9; }

.public-vault-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-2);
}

.public-vault-header h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: -0.02em;
}

.public-vault-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}

.public-vault-summary > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.public-vault-summary strong {
  font-family: var(--font-display);
  font-size: 20px;
}

.public-vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.public-vault-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.public-vault-thumb {
  position: relative;
  aspect-ratio: 5 / 7;
  background: var(--bg-raised);
}

.public-vault-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.public-vault-thumb-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 13px;
}

.public-vault-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(7, 7, 10, 0.82);
  border: 1px solid rgba(255, 122, 122, 0.45);
  color: var(--brand-2);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
}

.public-vault-meta {
  padding: 12px;
}

.public-vault-meta h2 {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.25;
}

.public-vault-meta .muted {
  margin: 0;
  font-size: 12px;
}

.public-vault-tags {
  margin: 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.public-vault-tags span {
  background: var(--surface-hi);
  border-radius: 999px;
  padding: 3px 8px;
}

.public-vault-empty {
  text-align: center;
  padding: 40px 16px;
}

.public-vault-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
}

@media (max-width: 560px) {
  .public-vault-summary {
    grid-template-columns: 1fr;
  }
}

.public-vault-unavailable {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.public-vault-unavailable .public-vault-header h1 {
  max-width: 16ch;
}

.public-vault-unavailable-handle {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}

/* Public legal pages (privacy, etc.) */
body.legal-page {
  background:
    radial-gradient(ellipse 55% 40% at 12% 0%, rgba(255, 45, 85, .10), transparent),
    radial-gradient(ellipse 45% 35% at 92% 100%, rgba(179, 0, 34, .12), transparent),
    var(--bg);
}

.legal-shell {
  width: min(720px, 92vw);
  margin: 48px auto 64px;
}

.legal-header {
  margin-bottom: 28px;
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 22px;
}

.legal-brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
}

.legal-brand:hover { text-decoration: none; opacity: 0.9; }

.legal-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.legal-header h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 5vw, 36px);
  letter-spacing: -.02em;
}

.legal-body {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 8px;
  line-height: 1.55;
  font-size: 15px;
}

.legal-body h2 {
  margin: 28px 0 10px;
  font-size: 17px;
  letter-spacing: -.01em;
}

.legal-body p,
.legal-body ul {
  margin: 0 0 14px;
  color: #d8d8e0;
}

.legal-body ul {
  padding-left: 1.2em;
}

.legal-body li {
  margin-bottom: 8px;
}

.legal-body a {
  color: #ff7a8a;
}

.legal-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
}

.legal-footer a {
  color: var(--text-muted);
}

@media (max-width: 560px) {
  .legal-body {
    padding: 20px 18px 4px;
  }
}
