/* ============================================================
   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="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: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; }
.btn-connect { display: block; width: 100%; margin: 10px 0; }

/* ---------- 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: 8px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.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;
}

.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: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
}
.mention.mention-me { color: var(--brand-2); background: var(--brand-soft); }

.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 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: pre-wrap; margin-top: 1px; }
.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 textarea {
  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; }
.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: 960px; margin: 0 auto; padding: 24px 16px 64px; }
.admin-nav {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}
.admin-nav .brand {
  font-family: var(--font-display);
  font-weight: 700;
  margin-right: auto;
  display: flex;
  align-items: center;
}
.admin-nav .brand .brand-logo { height: 20px; }
.admin-nav a { color: var(--text-muted); font-weight: 600; font-size: 14px; }
.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;
}
.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); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
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; }

.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; }

#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; }
