/* =============================================================================================
   Design system. Modelled on native settings apps: a full-height sidebar with coloured tiles, quiet
   grouped lists, hairline separators, the system font, and depth only where something floats.
   --brand is the bot's colour (set at runtime) and is the single accent.
   ============================================================================================= */

/* ---- Tokens: dark ---------------------------------------------------------------------------- */
:root {
  --brand: #4fd1c5;
  --bg: #19191b;
  --sidebar-bg: #202023;
  --surface: #242427;
  --surface-2: #2b2b2f;
  --elevated: #2c2c30;
  --field: #2f2f33;
  --hover: #2e2e32;
  --selected: rgb(255 255 255 / 0.09);
  --segment: #4a4a4f;
  --toggle-off: #48484c;
  --separator: #333336;
  --border: #3a3a3d;
  --border-strong: #48484c;
  --text: #f5f5f7;
  --text-2: #aeaeb2;
  --text-3: #98989d; /* ≥ 4.5:1 on bg, surface and elevated */
  --accent: var(--brand);
  --accent-ink: #06201d;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --brand-ink: #06201d;
  --danger: #ff453a;
  --warning: #ff9f0a;
  --success: #30d158;
  --focus: color-mix(in srgb, var(--accent) 55%, transparent);
  --menu-bg: rgb(44 44 48 / 0.95); /* nearly opaque: legible even where blur is unavailable */
  --hud-bg: rgb(58 58 62 / 0.92);
  --shadow-sm: 0 1px 1px rgb(0 0 0 / 0.25), 0 0 0 0.5px rgb(255 255 255 / 0.06);
  --shadow-card: none;
  --shadow-pop: 0 0 0 0.5px rgb(255 255 255 / 0.14), 0 4px 12px rgb(0 0 0 / 0.3), 0 16px 40px rgb(0 0 0 / 0.45);
  --scrim: rgb(0 0 0 / 0.5);
  /* Tile colours for the sidebar */
  --blue: #0a84ff; --red: #ff453a; --orange: #ff9f0a; --teal: #40c8e0; --green: #30d158;
  --pink: #ff375f; --purple: #bf5af2; --indigo: #5e5ce6; --brown: #ac8e68; --gray: #8e8e93; --yellow: #ffd60a;
  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 24px;
  --text-2xl: 28px;
  /* Space, shape, size */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --control: 32px;
  --topbar: 52px;
  --sidebar: 236px;
  --sidebar-collapsed: 64px;
  /* Layers */
  --z-scrim: 25; --z-sidebar: 30; --z-popover: 40; --z-tooltip: 50; --z-toast: 60;
  /* Motion: short and decelerating, like a critically damped spring */
  --fast: 120ms;
  --base: 200ms;
  --slow: 280ms;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

/* ---- Tokens: light (its own steps, not an inversion) -------------------------------------------- */
:root[data-theme="light"] {
  --bg: #f5f5f7;
  --sidebar-bg: #ebebee;
  --surface: #ffffff;
  --surface-2: #f8f8fa;
  --elevated: #ffffff;
  --field: #ffffff;
  --hover: #f0f0f3;
  --selected: rgb(0 0 0 / 0.07);
  --segment: #ffffff;
  --toggle-off: #e2e2e7;
  --separator: #e5e5ea;
  --border: #d8d8dd;
  --border-strong: #c7c7cc;
  --text: #1d1d1f;
  --text-2: #545459;
  --text-3: #68686d; /* ≥ 4.5:1 on bg, surface and the sidebar */
  --accent: color-mix(in srgb, var(--brand) 62%, #00302b);
  --accent-ink: #ffffff;
  --danger: #d70015;
  --warning: #b25000;
  --success: #248a3d;
  --menu-bg: rgb(250 250 252 / 0.95);
  --hud-bg: rgb(28 28 30 / 0.9);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.08), 0 0 0 0.5px rgb(0 0 0 / 0.06);
  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.04);
  --shadow-pop: 0 0 0 0.5px rgb(0 0 0 / 0.12), 0 4px 12px rgb(0 0 0 / 0.08), 0 16px 40px rgb(0 0 0 / 0.14);
  --scrim: rgb(0 0 0 / 0.22);
  --blue: #007aff; --red: #ff3b30; --orange: #ff9500; --teal: #30b0c7; --green: #34c759;
  --pink: #ff2d55; --purple: #af52de; --indigo: #5856d6; --brown: #a2845e; --gray: #8e8e93; --yellow: #f5b800;
  color-scheme: light;
}
@media (prefers-contrast: more) {
  :root, :root[data-theme="light"] { --separator: var(--border-strong); --border: var(--border-strong); --text-3: var(--text-2); }
}

/* =============================================================================================
   Base
   ============================================================================================= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--text-base)/1.45 var(--font); letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-optical-sizing: auto;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-radius: var(--radius-sm); }
/* `hidden` always wins, also over components that set their own display */
[hidden] { display: none !important; }
.icon { width: 16px; height: 16px; flex: none; }
.mono { font-family: var(--mono); font-size: var(--text-xs); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.strong { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.prewrap { white-space: pre-wrap; }
.hint { color: var(--text-3); font-size: var(--text-sm); margin: 8px 4px 22px; }
.hint a, .link-subtle { color: var(--accent); }
.hint a:hover, .link-subtle:hover { text-decoration: underline; text-underline-offset: 3px; }
.option-problem { color: var(--danger); font-size: var(--text-sm); }
.mobile-only, .btn.mobile-only { display: none; }
.skip-link { position: absolute; left: 12px; top: -40px; z-index: var(--z-toast); padding: 6px 10px; border-radius: var(--radius); background: var(--elevated); }
.skip-link:focus { top: 10px; box-shadow: var(--shadow-pop); } /* no shadow while parked off-screen: it would bleed into the corner */
kbd { font: 500 var(--text-xs) var(--font); padding: 0 5px; border-radius: 5px; border: 1px solid var(--border); color: var(--text-3); }
.logo { width: 22px; height: 22px; flex: none; }
.logo-fill { fill: var(--accent); }
.logo-mark { stroke: var(--accent-ink); stroke-width: 2.2; stroke-linecap: round; fill: none; }
.chevron { color: var(--text-3); width: 14px; height: 14px; }

/* =============================================================================================
   App shell: a full-height sidebar, a slim toolbar and the page
   ============================================================================================= */
.app {
  display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: var(--topbar) minmax(0, 1fr);
  height: 100vh; height: 100dvh; transition: grid-template-columns var(--base) var(--ease-out);
}
.app.collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }

/* Sidebar */
.sidebar { grid-column: 1; grid-row: 1 / -1; display: flex; flex-direction: column; min-height: 0; background: var(--sidebar-bg); border-right: 1px solid var(--separator); overflow: hidden auto; scrollbar-width: none; }
.sidebar-head { display: flex; align-items: center; gap: 10px; height: var(--topbar); padding: 0 20px; flex: none; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.sidebar-nav { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 0 10px 12px; }
.nav-group { padding: 16px 10px 5px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-3); white-space: nowrap; }
.nav-group:first-of-type { padding-top: 4px; }
.sidebar-nav a { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: var(--radius); color: var(--text); font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; transition: background-color var(--fast); }
.sidebar-nav a:hover { background: var(--selected); }
.sidebar-nav a[aria-current="page"]:hover { background: none; }
.nav-tile { display: grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 6px; color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--tile) 88%, #fff), var(--tile)); box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.08); }
.nav-tile .icon { width: 14px; height: 14px; stroke-width: 2.2; }
.nav-tile[data-tint="blue"] { --tile: var(--blue); }
.nav-tile[data-tint="red"] { --tile: var(--red); }
.nav-tile[data-tint="orange"] { --tile: var(--orange); }
.nav-tile[data-tint="teal"] { --tile: var(--teal); }
.nav-tile[data-tint="green"] { --tile: var(--green); }
.nav-tile[data-tint="pink"] { --tile: var(--pink); }
.nav-tile[data-tint="purple"] { --tile: var(--purple); }
.nav-tile[data-tint="indigo"] { --tile: var(--indigo); }
.nav-tile[data-tint="brown"] { --tile: var(--brown); }
.nav-tile[data-tint="gray"] { --tile: var(--gray); }
.nav-tile[data-tint="yellow"] { --tile: var(--yellow); }
/* One soft selection that glides to the current page */
.nav-indicator { position: absolute; top: 0; left: 10px; right: 10px; border-radius: var(--radius); background: var(--selected); pointer-events: none; }
.nav-indicator.ready { transition: transform var(--base) var(--ease-out), height var(--base) var(--ease-out); }
.sidebar-toggle { display: flex; align-items: center; gap: 10px; height: 32px; margin: auto 10px 12px; padding: 0 10px; border: 0; border-radius: var(--radius); background: none; color: var(--text-3); font-weight: 500; white-space: nowrap; transition: background-color var(--fast), color var(--fast); }
.sidebar-toggle:hover { background: var(--selected); color: var(--text); }
.toggle-icon { display: grid; }
.app.collapsed .nav-label, .app.collapsed .nav-group { display: none; }
.app.collapsed .sidebar-head, .app.collapsed .sidebar-nav a, .app.collapsed .sidebar-toggle { justify-content: center; padding: 0; }
.app.collapsed .sidebar { overflow: visible; }
.scrim { display: none; }

/* Toolbar */
.topbar { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 6px; min-width: 0; padding: 0 14px 0 16px; border-bottom: 1px solid var(--separator); background: var(--bg); }
.topbar-divider { width: 1px; height: 16px; margin: 0 4px; background: var(--border); }
.topbar-spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; white-space: nowrap; }
.menu-anchor { position: relative; }
.server-button { display: flex; align-items: center; gap: 8px; max-width: 240px; height: 32px; padding: 0 8px 0 6px; border: 0; border-radius: var(--radius); background: none; font-weight: 600; transition: background-color var(--fast); }
.server-button:hover, .server-button[aria-expanded="true"] { background: var(--selected); }
.server-name { font-weight: 600; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-3); }
.crumb { white-space: nowrap; transition: color var(--fast); }
a.crumb:hover { color: var(--text); }
.crumb.current { color: var(--text-2); }
.crumb-sep { color: var(--border-strong); }
.crumbs > .crumb-sep:first-child { display: none; }
.search-button { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 10px; border: 0; border-radius: var(--radius); background: var(--selected); color: var(--text-3); transition: color var(--fast), background-color var(--fast); }
.search-button:hover { color: var(--text-2); background: color-mix(in srgb, var(--selected) 70%, var(--text-3) 12%); }
.search-label { min-width: 120px; text-align: left; }
.bell { position: relative; }
.bell-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--bg); }
.profile-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; }
.profile-button:hover .avatar { box-shadow: 0 0 0 3px var(--selected); }

/* Tooltips for icon-only controls (collapsed sidebar, toolbar) */
[data-tooltip] { position: relative; }
[data-tooltip]:not([data-tooltip=""])::after {
  content: attr(data-tooltip); position: absolute; z-index: var(--z-tooltip); pointer-events: none; white-space: nowrap;
  padding: 4px 8px; border-radius: var(--radius-sm); background: var(--elevated); color: var(--text); box-shadow: var(--shadow-pop);
  font: 500 var(--text-xs) var(--font); opacity: 0; transition: opacity var(--fast) var(--fast);
}
.topbar [data-tooltip]::after { top: calc(100% + 6px); left: 50%; transform: translateX(-50%); }
.sidebar [data-tooltip]::after { left: calc(100% + 12px); top: 50%; transform: translateY(-50%); }
.topbar .search-button[data-tooltip]::after, .topbar [aria-expanded="true"]::after { display: none; }
.app:not(.collapsed) .sidebar [data-tooltip]::after { display: none; }
.topbar [data-tooltip]:focus-visible::after, .app.collapsed .sidebar [data-tooltip]:focus-visible::after { opacity: 1; }
@media (hover: hover) {
  .topbar [data-tooltip]:hover::after, .app.collapsed .sidebar [data-tooltip]:hover::after { opacity: 1; }
}

/* Page */
.content { grid-column: 2; grid-row: 2; overflow-y: auto; outline: none; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.page { max-width: 880px; margin: 0 auto; padding: 32px 40px 96px; }
.page-enter { animation: page-enter var(--base) var(--ease-out); }
.page-switch .page-body { animation: fade-in var(--base) ease-out; }
@keyframes page-enter { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade-in { from { opacity: 0; } }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.022em; line-height: 1.2; }
.page-header p { margin-top: 4px; max-width: 560px; color: var(--text-2); }

/* =============================================================================================
   Controls
   ============================================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--control); padding: 0 14px;
  border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text);
  font-weight: 500; white-space: nowrap; transition: background-color var(--fast), color var(--fast), transform var(--fast) var(--ease-out), filter var(--fast);
}
:root:not([data-theme="light"]) .btn { background: var(--surface-2); }
.btn:hover:where(:not(:disabled)) { filter: brightness(0.97); }
:root:not([data-theme="light"]) .btn:hover:where(:not(:disabled)) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: scale(0.97); transition-duration: 60ms; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; opacity: 0.85; }
.btn[aria-busy="true"]::before { content: ""; width: 12px; height: 12px; flex: none; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; animation: spin 0.6s linear infinite; }
.btn[aria-busy="true"] > .icon { display: none; }
.btn-primary, :root:not([data-theme="light"]) .btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-danger, :root:not([data-theme="light"]) .btn-danger { background: var(--danger); color: #fff; }
.btn-ghost, :root:not([data-theme="light"]) .btn-ghost { background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover:where(:not(:disabled)), :root:not([data-theme="light"]) .btn-ghost:hover:where(:not(:disabled)) { filter: none; background: var(--selected); color: var(--text); }
.btn-sm { height: 28px; padding: 0 11px; border-radius: var(--radius-sm); font-size: var(--text-sm); }
.btn-icon { width: var(--control); padding: 0; }
.btn-block { width: 100%; height: 38px; }

/* Fields: zero specificity, so a class on an input always wins */
:where(input[type="text"], input[type="search"], input[type="number"], input[type="date"], select, textarea) {
  width: 100%; height: var(--control); padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--field); transition: border-color var(--fast), box-shadow var(--fast);
}
:where(select) {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 11px) 14px; background-size: 4px 4px; background-repeat: no-repeat;
}
:where(input[type="date"]) { width: auto; }
:where(textarea) { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
:is(input, select, textarea)::placeholder { color: var(--text-3); }
:is(input, select, textarea):hover:where(:not(:disabled)) { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); box-shadow: 0 0 0 3px var(--accent-soft); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
:disabled { cursor: not-allowed; }
:is(input, select, textarea, .switch, .combo, .segmented button, .color-input):disabled { opacity: 0.5; }
.input-number { width: 96px; }
.text-control { position: relative; width: 100%; }
.text-control:has(> .counter:not(:empty)) > input { padding-right: 76px; } /* the counter shows near the limit; text never runs under it */
.counter { position: absolute; right: 9px; bottom: 7px; font-size: var(--text-xs); color: var(--text-3); pointer-events: none; }
.color-input { width: 44px; height: var(--control); padding: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--field); cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); font-size: var(--text-sm); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* Switch: a round knob that slides, and stretches while pressed */
.switch { position: relative; width: 38px; height: 22px; flex: none; padding: 0; border: 0; border-radius: 999px; background: var(--toggle-off); transition: background-color var(--base) var(--ease); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25), 0 0 0 0.5px rgb(0 0 0 / 0.04); transition: transform var(--base) var(--ease-out), width var(--fast) var(--ease-out); }
.switch:active::after { width: 22px; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch[aria-checked="true"]:active::after { transform: translateX(12px); }

/* Segmented control: filters and choices within a page */
.segmented { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--radius); background: var(--selected); flex: none; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented button { flex: none; height: 26px; display: inline-flex; align-items: center; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-2); font-weight: 500; font-size: var(--text-sm); white-space: nowrap; transition: background-color var(--fast), color var(--fast), box-shadow var(--fast); }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--segment); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button:focus-visible { outline-offset: -2px; }

/* Page tabs: the sections of a page, underlined so they never look like the filters below them. A side that
   scrolls out of view fades, so phones show there is more. */
.tabs { display: flex; gap: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--separator); overflow-x: auto; scrollbar-width: none; }
.tabs a { flex: none; height: 36px; display: inline-flex; align-items: center; padding: 0 2px; color: var(--text-2); font-weight: 500; font-size: var(--text-sm); white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; transition: color var(--fast), box-shadow var(--fast); }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tabs a:focus-visible { outline-offset: -3px; }
.tabs.more-end { mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.tabs.more-start { mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); }
.tabs.more-start.more-end { mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }

/* Searchable pickers and chips */
.combo-anchor { width: 100%; }
.combo { display: flex; align-items: center; gap: 8px; width: 100%; height: var(--control); padding: 0 8px 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--field); text-align: left; transition: border-color var(--fast); }
.combo:hover, .combo[aria-expanded="true"] { border-color: var(--border-strong); }
.combo-value { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 6px; }
.combo-menu { width: max(100%, 260px); max-width: 340px; }
.combo-menu .menu-item[disabled] { opacity: 0.45; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--selected); font-size: var(--text-sm); }
.chip-remove { display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-3); }
.chip-remove:hover { background: var(--selected); color: var(--text); }
.chip-remove .icon { width: 12px; height: 12px; }
.chips .combo-anchor { width: auto; }
.chips .combo { height: 26px; border-style: dashed; border-radius: 999px; padding: 0 10px; background: none; color: var(--text-2); }
.chips .combo .chevron { display: none; }
.chip-limit { font-size: var(--text-sm); }

/* Toolbars above lists */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar select { width: 170px; }
.toolbar-search { max-width: 260px; }
.date-range { display: flex; align-items: center; gap: 6px; color: var(--text-3); }
.results { min-height: 120px; }
.inline-controls { display: flex; gap: 8px; width: 100%; }
.inline-controls.end { justify-content: flex-end; align-items: center; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s4); flex-wrap: wrap; }
.section-bar.end { justify-content: flex-end; margin-top: -8px; }
.field { display: grid; gap: 6px; }
.field > span:first-child { font-size: var(--text-sm); font-weight: 500; }

/* =============================================================================================
   Grouped settings: a heading, then one rounded group of rows with inset separators
   ============================================================================================= */
.section { margin-bottom: 26px; }
.section-head { margin: 0 4px 7px; }
.section-head h2 { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 600; letter-spacing: 0; color: var(--text-2); }
.section-head:has(h2:empty) { display: none; }
.rows { border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); }
.row { position: relative; display: flex; align-items: center; gap: 24px; min-height: 48px; padding: 10px 16px; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--separator); }
.row-text { flex: 1; min-width: 0; }
.row-label { display: flex; align-items: center; gap: 6px; }
.row-help { color: var(--text-2); font-size: var(--text-sm); margin-top: 1px; }
.row-control { flex: 0 0 260px; display: flex; justify-content: flex-end; }
.row.stacked { display: block; }
.row.stacked .row-control { display: block; margin-top: 8px; }
.row.disabled .row-label, .row.disabled .row-help { opacity: 0.55; }
.event-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 16px; }
.event-row + .event-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--separator); }
.log-type { margin-bottom: 10px; }
.log-type .section { margin-bottom: 0; }
.log-type.channel-off .event-row { opacity: 0.5; }
.section-details { transition: opacity var(--base); }
.section-details.is-off { opacity: 0.5; }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 20px; padding: 4px; }
.permission-grid.compact { margin-bottom: 14px; }

/* Saving: a quiet word next to the setting's name */
.save-status { font-size: var(--text-xs); font-weight: 400; color: var(--text-3); }
.save-status[data-state="saved"] { color: var(--success); }
.save-status[data-state="saved"]::before { content: "✓ "; }
.save-status[data-state="error"] { color: var(--danger); }
.save-status[data-state="dirty"] { color: var(--warning); }

/* Less common settings, one level deeper */
.expandable { margin-bottom: 12px; }
.expandable > summary { display: flex; align-items: center; gap: 6px; width: fit-content; padding: 6px 4px; color: var(--text-2); font-weight: 500; cursor: pointer; list-style: none; user-select: none; transition: color var(--fast); }
.expandable > summary::-webkit-details-marker { display: none; }
.expandable > summary:hover { color: var(--text); }
.expandable-icon { width: 14px; height: 14px; transition: transform var(--base) var(--ease-out); }
.expandable[open] > summary .expandable-icon { transform: rotate(90deg); }
.expandable-body { padding: 6px 0 10px; }

/* ⓘ explanations: shown on hover, focus or tap */
.info { position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-3); cursor: help; vertical-align: -2px; transition: color var(--fast); }
.info .icon { width: 14px; height: 14px; }
.info:hover, .info:focus-visible { color: var(--text-2); }
.info::after {
  content: attr(data-tip); display: none; position: absolute; left: -8px; bottom: calc(100% + 8px); z-index: var(--z-tooltip);
  width: max-content; max-width: min(300px, 72vw); padding: 8px 11px; border-radius: var(--radius); background: var(--elevated); color: var(--text); box-shadow: var(--shadow-pop);
  font: 400 var(--text-sm)/1.45 var(--font); text-align: left; white-space: normal; pointer-events: none;
}
.info:focus::after { display: block; animation: tip-in var(--fast) var(--ease-out); }
@media (hover: hover) { .info:hover::after { display: block; animation: tip-in var(--fast) var(--ease-out); } }
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } }

/* =============================================================================================
   Data
   ============================================================================================= */
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; color: var(--text-2); background: var(--selected); }
.badge-accent { color: var(--accent); background: var(--accent-soft); }
.badge-warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.badge-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--text-2); }
.status-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--text-3); }
.status-ok .status-dot { background: var(--success); }
.status-warn .status-dot { background: var(--warning); }
.status-down .status-dot { background: var(--danger); }
.avatar { width: 20px; height: 20px; flex: none; border-radius: 50%; object-fit: cover; background: var(--selected); }
.avatar.square { border-radius: var(--radius-sm); }
.avatar-md { width: 32px; height: 32px; }
.avatar-lg { width: 40px; height: 40px; }
.avatar-lg.square { border-radius: var(--radius-lg); }
.initials { display: inline-grid; place-items: center; font-size: 10px; font-weight: 600; color: var(--text-2); }
.avatar-md.initials { font-size: 13px; }
.avatar-lg.initials { font-size: 16px; }
.person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
a.person:hover span { text-decoration: underline; text-underline-offset: 3px; }

/* Tables: a rounded list with hairlines */
.table-wrap { border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 16px 8px; border-bottom: 1px solid var(--separator); text-align: left; font-weight: 500; font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }
.table td { height: 44px; padding: 10px 16px; border-bottom: 1px solid var(--separator); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table.clickable tbody tr { cursor: pointer; transition: background-color var(--fast); }
.table.clickable tbody tr:hover { background: var(--hover); }
.table.clickable tbody tr:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
.table .col-narrow { width: 1%; }
.table .col-grow { width: 100%; max-width: 0; }
@media (max-width: 900px) { .table .col-optional { display: none; } } /* tablets: the least needed column goes first */
.table-cards { display: none; }
.table-card { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); }
.table-card.clickable { cursor: pointer; }
.table-card.clickable:active { background: var(--hover); }
.table-card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.table-card-title { flex: 1; font-weight: 500; }
.table-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; font-size: var(--text-sm); color: var(--text-2); }
.cell-reason { display: block; }
.cell-action { display: inline-flex; align-items: center; gap: 8px; }
.action-ban { color: var(--danger); }
.action-kick { color: var(--warning); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; color: var(--text-3); font-size: var(--text-sm); }
.pager-buttons { display: flex; gap: 6px; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 24px; margin: 0 0 20px; }
.details dt { margin-bottom: 2px; font-size: var(--text-xs); color: var(--text-3); }
.details dd { margin: 0; min-width: 0; }
.subheading { margin: 24px 4px 8px; font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }

/* Empty, error, loading */
.empty { padding: 44px 24px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); text-align: center; color: var(--text-2); }
.empty-title { font-size: var(--text-md); font-weight: 600; color: var(--text); }
.empty p { max-width: 360px; margin: 4px auto 0; font-size: var(--text-sm); }
.empty > .btn { margin-top: 16px; }
.error-box { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.error-box .icon { margin-top: 2px; color: var(--danger); }
.error-box .btn { margin-top: 10px; }
.notice { margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); box-shadow: 0 0 0 1px var(--separator); font-size: var(--text-sm); }
.notice-error { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); box-shadow: none; }
.skeleton { display: grid; gap: 14px; padding: 8px 0; }
.skeleton span { height: 12px; border-radius: 999px; background: linear-gradient(90deg, var(--selected) 30%, color-mix(in srgb, var(--selected) 40%, transparent) 50%, var(--selected) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.skeleton span:nth-child(3n+2) { width: 80%; }
.skeleton span:nth-child(3n) { width: 60%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.boot { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--selected); border-top-color: var(--text-2); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================================================
   Overview
   ============================================================================================= */
.overview-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.overview-greeting { margin-bottom: 2px; color: var(--text-2); }
.overview-head h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; }
.bot-status { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); font-size: var(--text-sm); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat { display: grid; gap: 2px; padding: 16px 18px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); transition: background-color var(--fast), transform var(--base) var(--ease-out); }
a.stat:hover { background: var(--surface-2); }
a.stat:active { transform: scale(0.98); }
.stat-value { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--text-sm); color: var(--text-2); }
.all-clear { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; color: var(--text-2); }
.all-clear .icon { color: var(--success); }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
.block { min-width: 0; margin-bottom: 28px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px; }
.block-title { margin-bottom: 8px; font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
.block-head a { color: var(--accent); font-size: var(--text-sm); }
.list { border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); overflow: hidden; }
.list-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 10px 16px; transition: background-color var(--fast); }
.list-row + .list-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--separator); }
a.list-row:hover { background: var(--hover); }
.list-main { flex: 1; min-width: 0; }
.list-time { font-size: var(--text-xs); white-space: nowrap; }
/* attention-*, not a bare .info: that name belongs to the ⓘ help buttons and shrank the whole row */
.attention-warning > .icon:first-child { color: var(--warning); }
.attention-info > .icon:first-child { color: var(--accent); }
.attention .muted { font-size: var(--text-sm); }

/* Activity feed */
.feed { display: flex; flex-direction: column; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); overflow: hidden; }
.feed-day { padding: 12px 16px 4px; font-size: var(--text-xs); font-weight: 600; color: var(--text-3); }
.feed-item { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 10px 16px; transition: background-color var(--fast); }
.feed-item + .feed-item::before { content: ""; position: absolute; top: 0; left: 48px; right: 0; border-top: 1px solid var(--separator); }
a.feed-item:hover { background: var(--hover); }
.feed-icon { display: grid; place-items: center; width: 22px; height: 22px; flex: none; color: var(--text-3); }
.feed-icon .icon { width: 15px; height: 15px; }
.feed-text { flex: 1; min-width: 0; padding-top: 1px; }
.feed-line { color: var(--text-2); }
.feed-line strong { color: var(--text); font-weight: 500; }
.feed-detail { font-size: var(--text-sm); color: var(--text-3); }
.feed-time { padding-top: 2px; font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }
:is(a.stat, .server-card, .list-row, .feed-item, .panel-card):focus-visible { outline-offset: -2px; }

/* =============================================================================================
   Detail views: profiles, tickets, notes
   ============================================================================================= */
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; font-size: var(--text-sm); color: var(--accent); }
.back-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.back-link .icon { width: 14px; height: 14px; }
.profile-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.profile-header h2 { font-size: var(--text-lg); }
.profile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 2px; }
.drawer-hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; font-size: var(--text-md); }
.drawer-hero > .truncate { flex: 1; }
.drawer-hero > .inline-controls { width: auto; flex: none; }
.answers { display: grid; gap: 10px; margin: 0 0 18px; }
.staff-note { display: grid; gap: 4px; margin-bottom: 16px; padding: 10px 12px; border-radius: var(--radius); background: color-mix(in srgb, var(--warning) 9%, var(--surface)); }
.timeline { margin-top: 20px; }
.timeline h3 { margin-bottom: 10px; font-size: var(--text-sm); color: var(--text-2); }
.timeline-item { position: relative; display: flex; gap: 12px; padding-bottom: 12px; color: var(--text-2); }
.timeline-item strong { color: var(--text); font-weight: 500; }
.timeline-item::before { content: ""; position: absolute; left: 3px; top: 13px; bottom: 0; width: 1px; background: var(--separator); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 7px; height: 7px; flex: none; margin-top: 6px; border-radius: 50%; background: var(--accent); }
.transcript { max-height: 60vh; margin: 0; padding: 12px; overflow: auto; border-radius: var(--radius); background: var(--bg); font: var(--text-xs)/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; }
.notes { display: grid; gap: 8px; margin-bottom: 10px; }
.note { display: grid; gap: 4px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.note-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--text-sm); }
.note-form { display: grid; gap: 8px; justify-items: end; }
.lockdown-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; padding: 10px 12px 10px 16px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); }
.lockdown-bar:has(.status-down) { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); box-shadow: none; }

/* Giveaways */
.gw-stack { display: grid; gap: 18px; }
.gw-list { display: grid; gap: 8px; }
.gw-subhead { margin: 4px 0 8px; font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
.gw-draw { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--separator); font-size: var(--text-sm); }
.gw-entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--text-sm); }
.gw-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }

/* =============================================================================================
   Panels and the message designer
   ============================================================================================= */
.panel-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s3); }
.panel-card { display: grid; gap: 6px; padding: 16px 18px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); transition: box-shadow var(--base), transform var(--base) var(--ease-out); }
.panel-card:hover { box-shadow: var(--shadow-pop); transform: translateY(-1px); }
.panel-card:active { transform: scale(0.99); }
.panel-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.panel-card-head .status { font-size: var(--text-sm); }
.panel-card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text-3); font-size: var(--text-sm); }
.editor-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 16px; margin-bottom: var(--s5); }
.editor-head .back-link { grid-column: 1 / -1; margin: 0; }
.editor-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.editor-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
/* The name reads as a title and becomes a field on hover; it grows with its text */
.panel-name { field-sizing: content; min-width: 120px; max-width: 320px; height: 34px; margin-left: -8px; padding: 0 8px; border-color: transparent; background: transparent; font-size: var(--text-lg); font-weight: 650; }
.panel-name:hover, .panel-name:focus { border-color: var(--border); background: var(--field); }
.designer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: var(--s5); align-items: start; }
.designer-form { display: grid; gap: var(--s3); align-content: start; }
.designer-form > .expandable { margin-bottom: 0; }
.designer-form .row { display: block; min-height: 0; }
.designer-form .row-control { display: flex; justify-content: flex-start; flex-basis: auto; margin-top: 8px; }
.designer-form .inline-controls.end { justify-content: flex-start; flex-direction: row-reverse; }
.designer-form .segmented { max-width: 100%; }
.designer-form .row:has(> .row-control > .switch) { display: flex; align-items: center; }
.designer-form .row:has(> .row-control > .switch) .row-control { justify-content: flex-end; margin-top: 0; }
.designer-preview { position: sticky; top: 0; }
.designer-label { margin: var(--s4) 4px 7px; font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
.designer-preview .designer-label { margin-top: 0; }
.design-list { display: grid; gap: 8px; }
.design-stack { display: grid; gap: var(--s3); padding-top: 4px; }
.design-item { display: flex; align-items: flex-start; gap: 6px; padding: 12px; border-radius: var(--radius-lg); background: var(--surface-2); }
.design-item-fields { flex: 1; min-width: 0; display: grid; gap: 6px; }
.type-actions { display: flex; gap: 2px; }
.type-actions.vertical { flex-direction: column; }
.option-line { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 6px; }
.option-emoji { text-align: center; }
.option-roles { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: var(--text-sm); }
.option-roles .chips { flex: 1; width: auto; }
.option-picker { width: 280px; max-width: 100%; }

/* Welcome message lists */
.text-list { display: grid; gap: 8px; margin-bottom: 6px; }
.text-list-item { display: flex; align-items: flex-start; gap: 6px; }
.text-list-item textarea { min-height: 58px; }

/* =============================================================================================
   Discord previews: Discord's own colours, so what you see matches what members see
   ============================================================================================= */
.preview { margin-top: 8px; padding: 14px; border-radius: var(--radius-lg); background: #313338; }
:root[data-theme="light"] .preview { background: #ffffff; box-shadow: 0 0 0 1px var(--separator); }
.preview.stack { display: grid; gap: 10px; }
.embed { max-width: 520px; padding: 10px 16px 14px 12px; border-left: 4px solid var(--brand); border-radius: 4px; background: #2b2d31; color: #dbdee1; font-size: 14px; line-height: 1.375; letter-spacing: 0; }
:root[data-theme="light"] .embed { background: #f2f3f5; color: #313338; }
.embed-author { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; font-size: 13px; font-weight: 600; }
.embed-author img { width: 22px; height: 22px; border-radius: 50%; }
.embed-title { margin: 4px 0; font-weight: 600; }
.embed-subtext { font-size: 12px; color: #949ba4; }
.embed-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin-top: 8px; }
.embed-field.wide { grid-column: 1 / -1; }
.embed-field-name { margin-bottom: 2px; overflow-wrap: anywhere; font-size: 13px; font-weight: 600; }
.embed-footer { margin-top: 8px; font-size: 12px; color: #949ba4; }
.embed .mention { padding: 0 2px; border-radius: 3px; background: rgb(88 101 242 / 0.3); color: #c9cdfb; }
:root[data-theme="light"] .embed .mention { background: rgb(88 101 242 / 0.15); color: #4752c4; }
.embed .link { color: #00a8fc; }
.embed-button { display: inline-block; margin-top: 10px; padding: 6px 14px; border-radius: 4px; background: var(--brand); color: var(--brand-ink); font-size: 13px; font-weight: 500; }
.dc-message { display: flex; align-items: flex-start; gap: 12px; }
.dc-avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.dc-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.dc-author { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #f2f3f5; }
:root[data-theme="light"] .dc-author { color: #060607; }
.dc-tag { padding: 0 4px; border-radius: 3px; background: #5865f2; color: #fff; font-size: 10px; font-weight: 600; line-height: 15px; }
.dc-message .embed { position: relative; max-width: 100%; }
.dc-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.dc-buttons .icon { width: 12px; height: 12px; margin-left: 6px; }
.dc-button { display: inline-flex; align-items: center; height: 32px; padding: 0 16px; border-radius: 4px; color: #fff; font-size: 14px; font-weight: 500; }
.dc-button.primary { background: #5865f2; }
.dc-button.secondary { background: #4e5058; }
.dc-select { display: flex; align-items: center; justify-content: space-between; max-width: 400px; height: 40px; padding: 0 12px; border-radius: 4px; background: #1e1f22; color: #949ba4; font-size: 14px; }
:root[data-theme="light"] .dc-select { background: #ebedef; color: #5c5e66; }
.dc-text { color: #dbdee1; font-size: 14px; line-height: 1.375; white-space: pre-wrap; overflow-wrap: anywhere; }
:root[data-theme="light"] .dc-text { color: #313338; }
.dc-code { padding: 0 3px; border-radius: 3px; background: rgb(0 0 0 / 0.25); font: 12.5px var(--mono); }
.dc-codeblock { margin: 4px 0; padding: 7px 9px; border-radius: 4px; background: rgb(0 0 0 / 0.25); font: 12.5px/1.45 var(--mono); white-space: pre-wrap; }
.preview-message { display: flex; align-items: flex-start; gap: 12px; }
.preview-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.preview-mention { font-size: 14px; color: #c9cdfb; }
.preview-mention::first-letter { font-weight: 500; }
:root[data-theme="light"] .preview-mention { color: #4752c4; }
.preview-text { font-size: 14px; color: #dbdee1; }
:root[data-theme="light"] .preview-text { color: #313338; }
.preview-banner { display: grid; place-items: center; max-width: 520px; height: 90px; border: 1px dashed #4e5058; border-radius: 4px; color: #949ba4; font-size: 12px; }
:root[data-theme="light"] .preview-banner { border-color: #c4c9ce; color: #5c5e66; }

/* =============================================================================================
   Floating layers: menus, dialogs, sheets, search, toasts
   ============================================================================================= */
/* Menus: a translucent material, anchored to the button that opened them */
.popover { position: absolute; top: calc(100% + 6px); z-index: var(--z-popover); min-width: 220px; max-width: 320px; padding: 5px; border-radius: var(--radius-lg); background: var(--menu-bg); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); box-shadow: var(--shadow-pop); animation: pop var(--base) var(--ease-out); transform-origin: top; }
.popover-start { left: 0; transform-origin: top left; }
.popover-end { right: 0; transform-origin: top right; }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
.server-menu { width: 300px; max-width: 300px; }
.notifications-menu { width: 320px; }
.menu-search { width: calc(100% - 8px); margin: 3px 4px 6px; }
.menu-scroll { max-height: 320px; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; min-height: 30px; padding: 5px 9px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); text-align: left; }
/* The highlighted item takes the accent, like a native menu */
.menu-item:hover, .menu-item:focus-visible { outline: none; background: var(--accent); color: var(--accent-ink); }
.menu-item:hover :is(.menu-meta, .faint, .menu-check), .menu-item:focus-visible :is(.menu-meta, .faint, .menu-check) { color: inherit; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--danger); color: #fff; }
.menu-label { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; }
.menu-meta { margin-left: auto; font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }
.menu-stack { display: grid; min-width: 0; }
.menu-stack .menu-meta { margin-left: 0; }
.menu-check { color: var(--accent); }
.menu-group-label { padding: 8px 9px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-3); }
.menu-divider { height: 1px; margin: 5px 9px; background: var(--separator); }
.menu-empty { padding: 12px 9px; color: var(--text-3); }
.menu-profile { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 9px; }
.menu-profile > div { min-width: 0; }

/* Dialogs scale in from the centre; sheets slide in from the side they sit on */
.dialog { width: min(440px, calc(100% - 32px)); padding: 0; border: 0; border-radius: var(--radius-xl); background: var(--elevated); color: var(--text); box-shadow: var(--shadow-pop); }
.dialog[open] { animation: dialog-in var(--base) var(--ease-out); }
.dialog.closing { animation: dialog-out var(--fast) ease-in forwards; }
.dialog::backdrop { background: var(--scrim); }
.dialog.closing::backdrop { opacity: 0; transition: opacity var(--fast); }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.95); } }
@keyframes dialog-out { to { opacity: 0; transform: scale(0.97); } }
.dialog.wide { width: min(720px, calc(100% - 32px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 14px 4px 22px; }
.dialog-head h2 { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-md); font-weight: 650; }
.dialog-body { padding: 8px 22px 4px; }
.dialog-text { color: var(--text-2); white-space: pre-line; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; }
.dialog-actions:empty { display: none; }
.dialog.drawer { display: flex; flex-direction: column; width: min(440px, calc(100% - 16px)); height: calc(100vh - 16px); max-height: calc(100vh - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); margin: 8px 8px 8px auto; }
.dialog.drawer.wide { width: min(880px, calc(100% - 16px)); }
.dialog.drawer[open] { animation: slide var(--base) var(--ease-out); }
.dialog.drawer.closing { animation: slide-out var(--fast) ease-in forwards; }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } }
@keyframes slide-out { to { opacity: 0; transform: translateX(24px); } }
.dialog.drawer .dialog-body { flex: 1; overflow-y: auto; padding-top: 12px; }
.dialog.drawer .dialog-actions { padding-top: 14px; border-top: 1px solid var(--separator); }
.dialog.drawer .details { grid-template-columns: 1fr 1fr; }

/* Search palette */
.palette { width: min(600px, calc(100% - 24px)); margin: 12vh auto auto; padding: 0; overflow: hidden; border: 0; border-radius: var(--radius-xl); background: var(--elevated); color: var(--text); box-shadow: var(--shadow-pop); }
.palette[open] { animation: pop var(--base) var(--ease-out); }
.palette::backdrop { background: var(--scrim); }
.palette-field { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--separator); color: var(--text-3); }
.palette-input, .palette-input:focus { height: 50px; padding: 0; border: 0; background: none; box-shadow: none; color: var(--text); font-size: var(--text-md); }
.palette-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.palette-group-label { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-3); }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius); background: none; color: var(--text-2); text-align: left; }
.palette-item.active { background: var(--accent); color: var(--accent-ink); }
.palette-label { color: var(--text); }
.palette-item.active :is(.palette-label, .palette-detail) { color: inherit; }
.palette-detail { max-width: 45%; margin-left: auto; font-size: var(--text-xs); color: var(--text-3); }
.palette-empty { padding: 28px; text-align: center; color: var(--text-3); }

/* Toasts: a small HUD at the bottom centre, in the top layer so it also shows over dialogs */
.toasts { position: fixed; inset: auto 0 22px; z-index: var(--z-toast); display: grid; justify-items: center; gap: 8px; width: fit-content; margin: 0 auto; padding: 0 16px; border: 0; background: none; overflow: visible; color: #fff; }
.toasts:popover-open:empty { display: none; }
.toast { display: flex; align-items: center; gap: 9px; min-width: 200px; max-width: min(400px, calc(100vw - 32px)); padding: 10px 18px; border-radius: 999px; background: var(--hud-bg); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); box-shadow: 0 8px 28px rgb(0 0 0 / 0.25); color: #fff; font-size: var(--text-sm); font-weight: 500; animation: toast-in var(--base) var(--ease-out); transition: opacity var(--base), transform var(--base); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.toast .icon { color: #30d158; }
.toast.error .icon { color: #ff6961; }
.toast.leaving { opacity: 0; transform: translateY(6px); }

/* =============================================================================================
   Sign-in, server picker and the setup guide
   ============================================================================================= */
.signin { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px; }
.signin-panel { width: 100%; max-width: 340px; text-align: center; }
.signin-mark .logo { width: 44px; height: 44px; }
.signin-panel h1 { margin: 18px 0 6px; font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.022em; }
.signin-panel > p.muted { margin-bottom: 24px; }
.signin-panel .signin-note { margin-top: 16px; font-size: var(--text-sm); color: var(--text-3); }
.signin-panel .notice { text-align: left; }
.picker { min-height: 100vh; min-height: 100dvh; }
.picker-top { display: flex; align-items: center; gap: 8px; height: var(--topbar); padding: 0 14px 0 20px; border-bottom: 1px solid var(--separator); }
.picker-main { max-width: 560px; margin: 0 auto; padding: 56px 20px 80px; }
.picker-main h1 { margin-bottom: 20px; font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.022em; }
.picker-section { margin-top: 32px; }
.picker-section h2 { margin: 0 4px 8px; font-size: var(--text-sm); color: var(--text-2); }
.server-list { display: grid; overflow: hidden; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); }
.server-card { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 16px; transition: background-color var(--fast); }
.server-card + .server-card::before { content: ""; position: absolute; top: 0; left: 68px; right: 0; border-top: 1px solid var(--separator); }
.server-card:hover { background: var(--hover); }
.server-card-text { flex: 1; min-width: 0; }
.setup { max-width: 560px; margin: 8px auto 0; }
.setup-steps { display: flex; gap: 6px; margin: 0 0 32px; padding: 0; list-style: none; }
.setup-steps li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); color: var(--text-3); }
.setup-steps li::before { content: ""; height: 4px; border-radius: 999px; background: var(--selected); transition: background-color var(--base); }
.setup-steps li.done::before, .setup-steps li.current::before { background: var(--accent); }
.setup-steps li.current { color: var(--text); }
.setup-body h1 { margin-bottom: 6px; font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.022em; }
.setup-text { max-width: 480px; margin-bottom: 22px; color: var(--text-2); }
.setup-content { margin-bottom: 28px; }
.setup-content > select { max-width: 320px; }
.setup-server { display: flex; align-items: center; gap: 12px; }
.setup-fields { display: grid; gap: 14px; max-width: 360px; }
.setup-fields label { display: grid; gap: 6px; font-weight: 500; }
.setup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 16px; border-top: 1px solid var(--separator); }

/* =============================================================================================
   Smaller screens. Tablets: the sidebar shows tiles only. Phones: it slides in over the page.
   ============================================================================================= */
@media (max-width: 1024px) {
  .app, .app.collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
  .app .nav-label, .app .nav-group, .sidebar-toggle, .crumbs, .search-label, .search-button kbd { display: none; }
  .app .sidebar-head, .app .sidebar-nav a { justify-content: center; padding: 0; }
  .sidebar { overflow: visible; }
  .app:not(.collapsed) .sidebar [data-tooltip]::after { display: block; }
  .sidebar [data-tooltip]:focus-visible::after { opacity: 1; }
  @media (hover: hover) { .sidebar [data-tooltip]:hover::after { opacity: 1; } }
  .page { padding: 28px 28px 96px; }
}
@media (max-width: 900px) {
  .designer { grid-template-columns: minmax(0, 1fr); }
  .designer-preview { position: static; order: -1; }
}
@media (max-width: 760px) {
  .mobile-only, .btn.mobile-only { display: inline-flex; }
  .app, .app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .topbar, .content { grid-column: 1; }
  .topbar { padding: 0 8px; gap: 2px; }
  .topbar-divider { display: none; }
  .server-button { max-width: 55vw; }
  /* The phone menu: full height, scrolls on short screens */
  /* Closed, it is hidden from keyboard and screen readers too, and casts no shadow onto the page */
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: var(--z-sidebar); width: 280px; overflow-y: auto; visibility: hidden; transform: translateX(-100%); transition: transform var(--slow) var(--ease-out), visibility 0s linear var(--slow); }
  .app.nav-open .sidebar { visibility: visible; transform: none; box-shadow: var(--shadow-pop); transition: transform var(--slow) var(--ease-out), visibility 0s; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: var(--z-scrim); background: var(--scrim); animation: fade-in var(--base) ease-out; }
  .app .nav-label, .app .nav-group { display: block; }
  .app .sidebar-head { justify-content: flex-start; padding: 0 20px; }
  .app .sidebar-nav a { justify-content: flex-start; padding: 0 8px; height: 40px; }
  .sidebar [data-tooltip]::after, .app:not(.collapsed) .sidebar [data-tooltip]::after { display: none; }
  .page { padding: 20px 16px 96px; }
  .page-header h1 { font-size: 22px; }
  .overview-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .row { flex-direction: column; align-items: stretch; gap: 8px; }
  .row-control { flex: none; justify-content: flex-start; }
  .row:has(> .row-control > .switch) { flex-direction: row; align-items: center; }
  .toolbar > * { flex: 1 1 100%; max-width: none; }
  .toolbar select, .toolbar-search { width: 100%; max-width: none; }
  .date-range input { flex: 1; }
  .editor-head { grid-template-columns: minmax(0, 1fr); }
  .editor-actions { justify-content: flex-start; flex-wrap: wrap; }
  .setup-steps .setup-label { display: none; }
  /* Menus that would run off the right edge open across the screen instead */
  .server-menu, .popover-end { position: fixed; top: calc(var(--topbar) + 4px); left: 8px; right: 8px; width: auto; max-width: none; }
  .chips { position: relative; }
  .chips .combo-anchor { position: static; }
  .chips .combo-menu { left: 0; right: 0; width: auto; max-width: none; }
  .dialog.drawer { width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  /* Tables become cards: compact ones where the page defines them, otherwise each value with its column name */
  .table-wrap.has-cards { display: none; }
  .table-cards { display: grid; gap: 8px; }
  .table-wrap { overflow: visible; background: none; box-shadow: none; }
  .table thead { display: none; }
  .table, .table tbody { display: grid; gap: 8px; }
  .table tr { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--separator); }
  .table td { display: flex; justify-content: space-between; align-items: center; gap: 16px; width: auto; max-width: none; height: auto; padding: 0; border: 0; white-space: normal; }
  .table td::before { content: attr(data-label); flex: none; font-size: var(--text-xs); color: var(--text-3); }
  .table td.col-grow { display: block; width: auto; max-width: none; }
  .table td.col-grow::before { display: block; }
  .table td.col-grow .truncate { white-space: normal; overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --menu-bg: var(--elevated); --hud-bg: rgb(40 40 44); }
  .popover, .toast { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

