/* Design tokens. Every color below comes from here, so the light theme is only a second set of values. */

:root {
  color-scheme: dark;
  --bg: #090a12;
  --surface: #11121d;
  --surface-2: #171828;
  --surface-3: #212338;
  --field: #0c0d17;
  --line: #222439;
  --line-strong: #33365a;
  --text: #ecebf7;
  --muted: #8f90b0;
  --accent: #8b5cf6;
  --accent-hover: #9d74f8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-2: #ec4899;
  --accent-3: #22d3ee;
  --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #c04fd8 50%, #ec4899 100%);
  --accent-gradient-soft: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.12));
  --glow-1: rgba(139, 92, 246, 0.16);
  --glow-2: rgba(34, 211, 238, 0.09);
  --glass: rgba(17, 18, 29, 0.72);
  --sheen: rgba(255, 255, 255, 0.04);
  --link: #b49cff;
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #f43f5e;
  --danger-soft: rgba(244, 63, 94, 0.15);
  --info: #22d3ee;
  --info-soft: rgba(34, 211, 238, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  --radius: 18px;
  --radius-sm: 11px;
}

/* The light theme: chosen on the page (data-theme), or the device's choice while the page is on System. */

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f4fb;
  --surface: #ffffff;
  --surface-2: #f3f1fb;
  --surface-3: #e8e5f6;
  --field: #ffffff;
  --line: #e4e1f1;
  --line-strong: #cbc6e3;
  --text: #17152b;
  --muted: #666384;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-ink: #ffffff;
  --accent-soft: rgba(124, 58, 237, 0.11);
  --accent-2: #db2777;
  --accent-3: #0891b2;
  --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #b62fc9 50%, #db2777 100%);
  --accent-gradient-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(219, 39, 119, 0.07));
  --glow-1: rgba(124, 58, 237, 0.09);
  --glow-2: rgba(8, 145, 178, 0.06);
  --glass: rgba(255, 255, 255, 0.78);
  --sheen: rgba(255, 255, 255, 0.5);
  --link: #6d28d9;
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.11);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.11);
  --danger: #e11d48;
  --danger-soft: rgba(225, 29, 72, 0.1);
  --info: #0891b2;
  --info-soft: rgba(8, 145, 178, 0.12);
  --shadow: 0 1px 2px rgba(23, 21, 43, 0.05), 0 6px 20px rgba(23, 21, 43, 0.06);
  --shadow-lg: 0 24px 60px rgba(23, 21, 43, 0.2);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;
    --bg: #f5f4fb;
    --surface: #ffffff;
    --surface-2: #f3f1fb;
    --surface-3: #e8e5f6;
    --field: #ffffff;
    --line: #e4e1f1;
    --line-strong: #cbc6e3;
    --text: #17152b;
    --muted: #666384;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-ink: #ffffff;
    --accent-soft: rgba(124, 58, 237, 0.11);
    --accent-2: #db2777;
    --accent-3: #0891b2;
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #b62fc9 50%, #db2777 100%);
    --accent-gradient-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(219, 39, 119, 0.07));
    --glow-1: rgba(124, 58, 237, 0.09);
    --glow-2: rgba(8, 145, 178, 0.06);
    --glass: rgba(255, 255, 255, 0.78);
    --sheen: rgba(255, 255, 255, 0.5);
    --link: #6d28d9;
    --ok: #059669;
    --ok-soft: rgba(5, 150, 105, 0.11);
    --warn: #b45309;
    --warn-soft: rgba(180, 83, 9, 0.11);
    --danger: #e11d48;
    --danger-soft: rgba(225, 29, 72, 0.1);
    --info: #0891b2;
    --info-soft: rgba(8, 145, 178, 0.12);
    --shadow: 0 1px 2px rgba(23, 21, 43, 0.05), 0 6px 20px rgba(23, 21, 43, 0.06);
    --shadow-lg: 0 24px 60px rgba(23, 21, 43, 0.2);
  }
}

/* Base */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h2 {
  font-size: 15.5px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

ul {
  padding-left: 20px;
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.error {
  color: var(--danger);
}

.good {
  color: var(--ok);
}

.fair {
  color: var(--warn);
}

.poor {
  color: var(--danger);
}

.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Shell */

.shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 20px 14px 14px;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand img {
  width: 30px;
  height: 30px;
}

.server {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}

.server:hover {
  border-color: var(--line-strong);
}

.server-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.server-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.server select,
.server select:focus {
  height: auto;
  padding: 0 18px 0 0;
  border: none;
  background-color: transparent;
  background-position: right 0 center;
  box-shadow: none;
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  padding: 0 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav button,
.logout {
  justify-content: flex-start;
  gap: 11px;
  height: 36px;
  padding: 0 10px;
  border-color: transparent;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-weight: 500;
}

.nav button:hover,
.logout:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav button.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.nav button.active .icon {
  color: var(--link);
}

.sidebar .spacer {
  flex: 1;
}

.main {
  width: 100%;
  max-width: 1120px;
  min-width: 0;
  margin: 0 auto;
  padding: 36px 40px 80px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
}

.page-head p {
  max-width: 68ch;
  margin-top: 5px;
}

.page-head .row {
  flex: none;
  flex-wrap: nowrap;
}

/* Layout helpers */

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.grow {
  flex: 1;
  min-width: 0;
}

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card > h2,
.card > .row:first-child {
  margin-bottom: 14px;
}

.card > .row:first-child h2 {
  margin: 0;
}

/* Buttons */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s,
    color 0.12s;
}

button:hover,
.button:hover {
  background: var(--surface-3);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

button.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

button.danger {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}

button.danger:hover {
  filter: brightness(1.08);
}

button.ghost,
a.button.ghost {
  height: 30px;
  padding: 0 9px;
  border-color: transparent;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}

button.ghost:hover:not(:disabled),
a.button.ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* Fields */

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text);
  font: inherit;
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

textarea {
  padding: 9px 11px;
  line-height: 1.5;
  resize: vertical;
}

select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93a4' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type='checkbox'],
input[type='radio'] {
  flex: none;
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

input[type='color'] {
  width: 46px;
  padding: 3px;
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
}

.field > .small {
  font-weight: 400;
}

label.check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  padding: 12px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--field);
}

.step {
  display: flex;
  align-items: center;
  gap: 9px;
}

.step input {
  width: 74px;
}

.step select {
  flex: 1;
}

.idle {
  opacity: 0.45;
}

/* Switches */

.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
}

.switch-row h2 {
  margin-bottom: 2px;
}

input.switch {
  appearance: none;
  position: relative;
  width: 40px;
  height: 22px;
  margin: 1px 0 0;
  border: none;
  border-radius: 99px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 0.15s;
}

input.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

input.switch:checked {
  background: var(--ok);
}

input.switch:checked::after {
  transform: translateX(18px);
}

/* Tags and pills */

.tag,
.pill {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 20px;
  padding: 0 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

strong + .tag {
  margin-left: 7px;
}

.tag.warned,
.pill.medium {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill {
  width: 62px;
  justify-content: center;
  margin-top: 1px;
  text-transform: capitalize;
}

.pill.high {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Login */

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login .card {
  width: 100%;
  max-width: 360px;
  padding: 30px;
  box-shadow: var(--shadow-lg);
}

.login img {
  width: 52px;
  height: 52px;
}

.login button {
  height: 40px;
}

/* Overview */

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1.5fr);
  gap: 18px;
}

.health {
  display: flex;
  align-items: center;
  gap: 20px;
}

.score {
  --tone: var(--ok);
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: conic-gradient(var(--tone) calc(var(--value) * 1%), var(--surface-3) 0);
}

.score::before {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--surface);
}

.score strong {
  position: relative;
  color: var(--text);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.score.fair {
  --tone: var(--warn);
}

.score.poor {
  --tone: var(--danger);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--link);
}

.stat strong {
  display: block;
  font-size: 21px;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.finding {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.finding:last-child {
  padding-bottom: 0;
}

.finding p {
  max-width: 78ch;
  margin-top: 2px;
}

.card > ul {
  margin: 10px 0 16px;
}

/* Channels */

.category {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.category-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 7px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.category-head[draggable='true'],
.channel[draggable='true'] {
  cursor: grab;
}

.channel-list {
  min-height: 16px;
  padding: 6px;
}

.channel {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 6px 0 10px;
  border-radius: 8px;
}

.channel:hover {
  background: var(--surface-2);
}

.channel > span:nth-child(2) {
  font-weight: 550;
}

.channel .glyph {
  flex: none;
  width: 18px;
  color: var(--muted);
  text-align: center;
}

.channel .topic {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.channel button,
.category-head button {
  opacity: 0.55;
}

.channel:hover button,
.category-head:hover button,
.channel button:focus-visible,
.category-head button:focus-visible {
  opacity: 1;
}

.dragging {
  opacity: 0.35;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  padding-top: 0;
  border-top: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

th:first-child,
td:first-child {
  padding-left: 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

thead + tbody tr:first-child td {
  border-top-color: var(--line-strong);
}

table > tbody:first-child tr:first-child td {
  padding-top: 0;
  border-top: none;
}

td.actions {
  white-space: nowrap;
  text-align: right;
}

.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  object-fit: cover;
}

.avatar.initial {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 650;
  text-transform: uppercase;
}

/* Rules editor and message previews */

.rule {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.rule .number {
  padding-top: 8px;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
}

.rule .fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule .tools {
  display: flex;
  flex-direction: column;
}

.preview {
  position: sticky;
  top: 24px;
}

.message {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message h3 {
  margin-bottom: 4px;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.message hr {
  margin: 14px 0;
  border: none;
  border-top: 1px solid var(--line);
}

.message .rule-text {
  margin-bottom: 12px;
}

.ping {
  display: inline-block;
  margin-bottom: 8px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--info-soft);
  color: var(--info);
  font-weight: 550;
}

/* Post page: a plain message has no card around it, and the post being edited is marked in its list. */

.message.plain {
  border-color: transparent;
  background: none;
  box-shadow: none;
  padding-left: 0;
}

.post-pictures {
  margin-top: 10px;
}

.post-pictures.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.post-picture {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
}

.post-pictures.grid .post-picture {
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.post-lead {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.post-lead .ping {
  margin-bottom: 0;
}

.post-picture.missing {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  text-align: center;
}

.post-buttons {
  margin-top: 12px;
}

/* The text takes whatever room the time, channel and buttons leave, and is cut short to fit it. */
.post-list .post-summary {
  width: 100%;
  max-width: 0;
}

.post-list .post-summary .clip {
  max-width: 100%;
}

tr.editing td {
  background: var(--accent-soft);
}

/* Messages page */

.chat {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.chat:first-child {
  padding-top: 0;
  border-top: none;
}

.chat:last-child {
  padding-bottom: 0;
}

.chat-text {
  margin-top: 2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  opacity: 0.6;
}

.chat:hover .chat-tools,
.chat-tools:focus-within {
  opacity: 1;
}

.notice {
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--text);
}

/* AutoMod word levels */

.levels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.level {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    border-color 0.12s,
    background 0.12s;
}

.level:hover {
  background: var(--surface-2);
}

.level.chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.level input {
  margin-top: 3px;
}

/* Dialogs and toasts */

dialog {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(8, 10, 14, 0.62);
  backdrop-filter: blur(3px);
}

dialog h2 {
  font-size: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 6px;
}

#toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.toast {
  max-width: 400px;
  padding: 11px 15px 11px 13px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--ok);
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  animation: rise 0.18s ease-out;
}

.toast.bad {
  border-left-color: var(--danger);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Narrow screens: the sidebar becomes a bar across the top. */

@media (max-width: 920px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    height: auto;
    padding: 12px 14px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .sidebar .spacer,
  .nav-label {
    display: none;
  }

  .server {
    flex: 1;
    min-width: 180px;
  }

  .nav {
    order: 5;
    flex-direction: row;
    gap: 4px;
    width: 100%;
    overflow-x: auto;
    /* Swiped or wheel-scrolled; a scrollbar under the tabs would only add a second line. */
    scrollbar-width: none;
  }

  .nav-group {
    flex-direction: row;
    gap: 4px;
  }

  .main {
    padding: 22px 16px 70px;
  }

  .page-head {
    flex-direction: column;
  }

  .hero,
  .columns,
  .form-grid,
  .levels {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview {
    position: static;
  }

  .channel .topic {
    display: none;
  }

  .card {
    padding: 16px;
    overflow-x: auto;
  }

  .finding {
    flex-wrap: wrap;
  }
}

.message .rule-text strong {
  display: inline-block;
  margin-bottom: 2px;
  font-size: 16.5px;
}

/* Typeface: the same Inter the bot draws banners with, so the editor's preview matches the result. */

@font-face {
  font-family: 'Inter';
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-latin-600-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-latin-700-normal.woff2') format('woff2');
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* Buttons: a little depth, a lift on hover, a ripple on press. */

button,
.button {
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0));
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.15s,
    transform 0.12s;
}

button:hover:not(:disabled):not(.ghost):not(.logout),
.button:hover:not(.ghost) {
  border-color: var(--muted);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  box-shadow: none;
  transform: translateY(0) scale(0.98);
}

button.primary {
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 2px 10px var(--accent-soft);
}

button.primary:hover:not(:disabled) {
  border-color: transparent;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 6px 20px var(--accent-soft),
    0 0 0 4px var(--accent-soft);
}

button.danger:hover:not(:disabled) {
  border-color: transparent;
  box-shadow:
    0 6px 20px var(--danger-soft),
    0 0 0 4px var(--danger-soft);
}

.nav button,
.logout,
button.ghost,
.select-menu button {
  background-image: none;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.22;
  pointer-events: none;
  transform: scale(0);
  animation: ripple 0.55s ease-out forwards;
}

@keyframes ripple {
  to {
    opacity: 0;
    transform: scale(1);
  }
}

.nav button .icon {
  transition: transform 0.18s;
}

.nav button:hover .icon {
  transform: translateX(2px);
}

.nav button.active {
  box-shadow: inset 3px 0 var(--accent);
}

/* Dropdowns: the native select stays in the page, hidden, and this stands in for it. */

.native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.select {
  position: relative;
  display: block;
  min-width: 0;
}

.select-button {
  justify-content: space-between;
  width: 100%;
  height: 38px;
  padding: 0 10px 0 12px;
  border-color: var(--line-strong);
  background: var(--field);
  background-image: none;
  box-shadow: none;
  font-weight: 500;
}

.select-button:hover:not(:disabled):not(.ghost):not(.logout) {
  box-shadow: none;
  transform: none;
}

.select-button[aria-expanded='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select-button .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.18s;
}

.select-button[aria-expanded='true'] .icon {
  transform: rotate(180deg);
}

.select-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.select-menu {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: min(420px, calc(100vw - 16px));
  max-height: 300px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  transform-origin: top center;
  animation: menu-in 0.14s ease-out;
}

.select-menu.up {
  transform-origin: bottom center;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: scaleY(0.92) translateY(-4px);
  }
}

.select-menu button {
  flex: none;
  justify-content: flex-start;
  height: 34px;
  padding: 0 10px;
  border-color: transparent;
  background: none;
  box-shadow: none;
  font-weight: 450;
  overflow: hidden;
  text-overflow: ellipsis;
}

.select-menu button:hover:not(:disabled):not(.ghost):not(.logout),
.select-menu button:focus-visible {
  border-color: transparent;
  background: var(--surface-3);
  box-shadow: none;
  outline: none;
  transform: none;
}

.select-menu button.selected {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.server .select-button {
  height: auto;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  font-weight: 600;
}

.step .select {
  flex: 1;
}

/* Motion: pages rise in when you arrive on them, dialogs and toasts ease in and out. */

.main.arriving > * > * {
  animation: arrive 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}

.main.arriving > * > *:nth-child(2) {
  animation-delay: 0.04s;
}

.main.arriving > * > *:nth-child(3) {
  animation-delay: 0.08s;
}

.main.arriving > * > *:nth-child(4) {
  animation-delay: 0.12s;
}

.main.arriving > * > *:nth-child(n + 5) {
  animation-delay: 0.16s;
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@property --value {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}

.main.arriving .score {
  animation: fill-score 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}

@keyframes fill-score {
  from {
    --value: 0;
  }
}

.card,
.stat,
.category {
  transition:
    border-color 0.18s,
    box-shadow 0.18s;
}

.stat:hover,
.category:hover {
  border-color: var(--line-strong);
}

.channel,
tbody tr,
.finding,
.chat,
.part {
  transition: background-color 0.14s;
}

dialog[open] {
  animation: dialog-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

dialog[open]::backdrop {
  animation: fade-in 0.2s ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.toast.leaving {
  animation: sink 0.2s ease-in forwards;
}

@keyframes sink {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

input.switch::after {
  transition:
    transform 0.2s cubic-bezier(0.3, 1.4, 0.6, 1),
    width 0.15s;
}

input.switch:active::after {
  width: 20px;
}

input.switch:checked:active::after {
  transform: translateX(14px);
}

/* Range sliders and color swatches. */

input[type='range'] {
  appearance: none;
  height: 22px;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  cursor: pointer;
}

input[type='range']:focus {
  box-shadow: none;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-3);
}

input[type='range']::-moz-range-track {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-3);
}

input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--line-strong);
  transition: transform 0.12s;
}

input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--line-strong);
}

input[type='range']:hover::-webkit-slider-thumb,
input[type='range']:focus-visible::-webkit-slider-thumb {
  transform: scale(1.15);
}

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  cursor: pointer;
}

.swatch input[type='color'] {
  width: 38px;
  height: 38px;
  padding: 3px;
  border-radius: 50%;
  overflow: hidden;
  transition: transform 0.12s;
}

.swatch input[type='color']:hover {
  transform: scale(1.08);
}

.swatch input[type='color']::-webkit-color-swatch-wrapper {
  padding: 0;
}

.swatch input[type='color']::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.swatch input[type='color']::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

/* Card design page. */

.canvas-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.banner-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: var(--surface-3);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.banner-canvas.grab {
  cursor: grab;
}

.banner-canvas.grabbing {
  cursor: grabbing;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: var(--surface-3);
}

.segmented button {
  height: 32px;
  border-color: transparent;
  background: none;
  background-image: none;
  box-shadow: none;
  color: var(--muted);
}

.segmented button.active {
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
}

.parts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.part {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
}

.part button {
  justify-content: flex-start;
}

.part.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.part.active button {
  color: var(--text);
}

/* Audit log, roles, charts, raid mode */

.nowrap {
  white-space: nowrap;
}

.clip {
  max-width: 46ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag.medium {
  background: var(--warn-soft);
  color: var(--warn);
}

.tag.high {
  background: var(--danger-soft);
  color: var(--danger);
}

.dot {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.none {
  background: none;
  border: 1.5px solid var(--line-strong);
}

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 26px;
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 96px;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
}

.bar {
  flex: 1;
  min-width: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  opacity: 0.8;
  transition: opacity 0.15s ease;
}

.bar:hover {
  opacity: 1;
}

.raid h2 {
  margin: 0 0 2px;
}

.raid.on {
  border-color: var(--danger);
  background: var(--danger-soft);
}

/* Engagement pages */

.row.wrap {
  flex-wrap: wrap;
}

.field.emoji {
  flex: none;
  width: 74px;
}

.answer {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.fake-button {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  background: var(--surface-3);
  font-size: 13px;
  font-weight: 600;
}

.tag.good-tag {
  background: var(--ok-soft);
  color: var(--ok);
}

/* Search */

.search-open {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 4px 0 14px;
  padding: 9px 9px 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--surface-2), var(--field));
  box-shadow: var(--shadow);
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.search-open .icon {
  transition: color 0.2s ease, transform 0.2s ease;
}

.search-open:hover,
.search-open:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  color: var(--text);
  outline: none;
}

.search-open:hover .icon,
.search-open:focus-visible .icon {
  color: var(--accent);
  transform: scale(1.08);
}

.search-open .keys {
  display: flex;
  gap: 3px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 21px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--muted);
  font: 600 11px/1 inherit;
}

dialog.palette {
  width: min(640px, calc(100vw - 32px));
  max-height: none;
  margin-top: 11vh;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--accent-soft);
}

dialog.palette[open] {
  animation: palette-in 0.22s cubic-bezier(0.2, 0.9, 0.25, 1);
}

@keyframes palette-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }
}

.palette-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.palette-field > .icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.palette-field input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  caret-color: var(--accent);
  color: var(--text);
  font-size: 17px;
  outline: none;
}

.palette-field input::placeholder {
  color: var(--muted);
}

.palette-field input::-webkit-search-cancel-button {
  display: none;
}

.palette-results {
  max-height: min(440px, 56vh);
  overflow-y: auto;
  padding: 6px 8px 10px;
  scroll-padding: 34px 0 8px;
}

.palette-group + .palette-group {
  margin-top: 4px;
}

.palette-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px 6px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.palette-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px 8px 10px;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.palette-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.palette-icon .icon {
  width: 16px;
  height: 16px;
}

.palette-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-label mark {
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.palette-hint {
  flex: none;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.palette-enter {
  flex: none;
  width: 22px;
  color: var(--accent);
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.palette-item.active {
  background: var(--accent-soft);
}

.palette-item.active::before {
  content: '';
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.palette-item.active .palette-icon {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.palette-item.active .palette-enter {
  opacity: 1;
  transform: none;
}

.palette-empty {
  padding: 18px 12px 6px;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

.palette-help {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  color: var(--muted);
  font-size: 12px;
}

.palette-help > span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.palette-help kbd {
  margin-right: 2px;
}

@keyframes flash {
  0%,
  60% {
    box-shadow: 0 0 0 3px var(--accent);
  }
  100% {
    box-shadow: 0 0 0 3px transparent;
  }
}

.flash {
  animation: flash 1.6s ease-out;
}

/* ---------- The modern layer: frosted panels, gradient accents, calmer surfaces ---------- */

body {
  background:
    radial-gradient(900px 520px at 85% -10%, var(--glow-1), transparent 70%),
    radial-gradient(700px 480px at -10% 110%, var(--glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-head {
  margin-bottom: 14px;
}

.page-head p {
  font-size: 14px;
}

/* The sidebar: a frosted column, the bot's name in the logo's colors. */
.sidebar {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.3);
  border-right-color: var(--line);
}

.brand {
  gap: 12px;
  padding: 2px 8px 4px;
  font-size: 16.5px;
  font-weight: 750;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  box-shadow: 0 6px 18px var(--accent-soft);
}

.server {
  border-radius: 14px;
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.server:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.nav-label {
  padding-left: 12px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
}

.nav button,
.logout {
  height: 38px;
  border-radius: 12px;
}

.nav button.active {
  background: var(--accent-gradient-soft);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.nav button.active::before {
  content: '';
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--accent-gradient);
}

.nav button.active .icon {
  color: var(--accent);
}

/* Cards: a faint sheen at the top, a softer edge, a lift for the ones you can act on. */
.card,
.stat {
  border-color: var(--line);
  background:
    linear-gradient(180deg, var(--sheen), transparent 120px),
    var(--surface);
  box-shadow: var(--shadow);
}

.card {
  padding: 24px;
}

.card > h2 {
  font-size: 16px;
}

.stat {
  padding: 16px 18px;
  transition: transform 0.18s, border-color 0.18s;
}

.stat:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--accent-gradient);
  color: var(--accent-ink);
  box-shadow: 0 6px 16px var(--accent-soft);
}

.stat strong {
  font-size: 23px;
}

/* Buttons: pill-round, the main one in the logo's gradient. */
button,
.button {
  border-radius: 12px;
}

button.primary {
  background: var(--accent-gradient);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px var(--accent-soft), inset 0 1px 0 var(--sheen);
}

button.primary:hover:not(:disabled) {
  background: var(--accent-gradient);
  filter: brightness(1.08);
  box-shadow: 0 10px 26px var(--accent-soft), 0 0 0 4px var(--accent-soft);
}

button.danger {
  background: var(--danger);
}

/* Fields: rounder, and a ring in the accent color when in use. */
input,
select,
textarea {
  border-radius: 12px;
  border-color: var(--line-strong);
  background-color: var(--field);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

input.switch:checked {
  background: var(--accent-gradient);
}

/* Tags and pills read better a little rounder and bolder. */
.tag,
.pill {
  border-radius: 999px;
  font-weight: 650;
}

/* Tables: rows that light up under the pointer. */
tbody tr {
  transition: background 0.12s;
}

tbody tr:hover {
  background: var(--surface-2);
}

/* Dialogs and the search: frosted like the sidebar. */
dialog {
  border-radius: 22px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.3);
}

/* Thin scrollbars in the page's own colors. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

/* The login: centred on the same glow, the card frosted. */
.login .card {
  background: var(--glass);
  backdrop-filter: blur(18px);
}

.login h1 {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- The shell: a rail of sections, a panel of pages, and the top bar ---------- */

.shell {
  display: grid;
  grid-template-columns: 96px 244px minmax(0, 1fr);
  min-height: 100vh;
}

/* The rail: the bot on top, one tile per section, log out at the foot. */
.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100vh;
  padding: 16px 0 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.rail-logo {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  box-shadow: 0 8px 22px var(--accent-soft);
}

.rail-line {
  width: 28px;
  height: 2px;
  margin: 8px 0;
  border-radius: 2px;
  background: var(--line-strong);
}

.rail .spacer {
  flex: 1;
}

.rail button {
  position: relative;
  flex-direction: column;
  gap: 4px;
  width: 80px;
  height: 60px;
  padding: 0 8px;
  border: none;
  border-radius: 16px;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.rail button .icon {
  width: 21px;
  height: 21px;
  transition: transform 0.18s ease;
}

.rail button:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Icons stay centered in their tiles on hover: the older rule nudged the page icons sideways. */
.rail button:hover .icon,
.panel .nav button:hover .icon {
  transform: none;
}

.rail button.active {
  background: var(--accent-gradient-soft);
  color: var(--text);
}

.rail button.active .icon {
  color: var(--accent);
}

/* The bar on the rail's edge that marks the open section. */
.rail button.active::before {
  content: '';
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: -8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent-gradient);
}

.rail .rail-out:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* The panel: the server picker, the section's pages, the bot and who is logged in. */
.panel {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  padding: 16px 14px 14px;
  overflow-y: auto;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.3);
  border-right: 1px solid var(--line);
}

.panel-title {
  margin: 8px 6px -4px;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.panel .nav {
  gap: 3px;
}

.panel .nav button {
  position: relative;
  justify-content: flex-start;
  gap: 11px;
  height: 42px;
  padding: 0 8px;
  border: none;
  border-radius: 13px;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-weight: 550;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--surface-2);
  transition: background 0.15s, color 0.15s;
}

.nav-icon .icon {
  width: 16px;
  height: 16px;
}

.panel .nav button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.panel .nav button:hover .nav-icon {
  background: var(--surface-3);
}

.panel .nav button.active {
  background: var(--accent-gradient-soft);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
  color: var(--text);
  font-weight: 650;
}

.panel .nav button.active::before {
  content: none;
}

.panel .nav button.active .nav-icon {
  background: var(--accent-gradient);
  color: var(--accent-ink);
  box-shadow: 0 4px 12px var(--accent-soft);
}

/* Over the older rule that colors an open page's icon in the accent, which would vanish on this gradient tile. */
.panel .nav button.active .nav-icon .icon {
  color: var(--accent-ink);
}

.panel .spacer {
  flex: 1;
}

.bot-card,
.user-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.bot-card {
  background: var(--accent-gradient-soft);
}

.bot-card img {
  width: 38px;
  height: 38px;
  border-radius: 11px;
}

.bot-card strong,
.user-chip strong {
  display: block;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-size: 12px;
  font-weight: 600;
}

.live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 6px transparent;
  }
}

.user-chip .avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: var(--accent-ink);
  font-weight: 700;
}

.user-chip .muted {
  display: block;
  line-height: 1.3;
}

/* The content column: the top bar stays in view over the page. */
.content {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 66px;
  padding: 0 28px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
}

.crumbs .sep {
  color: var(--line-strong);
}

.topbar .search-open {
  width: 300px;
  margin: 0;
}

/* Light, Dark, System: one segmented control. */
.theme-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.theme-switch button {
  width: 34px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: none;
  box-shadow: none;
  color: var(--muted);
}

.theme-switch button .icon {
  width: 16px;
  height: 16px;
}

.theme-switch button:hover {
  color: var(--text);
}

.theme-switch button.active {
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--accent);
}

.login {
  position: relative;
}

.login-theme {
  position: absolute;
  top: 18px;
  right: 18px;
}

.main {
  max-width: 1180px;
  padding: 30px 32px 80px;
}

/* Narrow screens: the rail becomes a bar of sections, the panel a row of pages. */
@media (max-width: 920px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: static;
    flex-direction: row;
    gap: 4px;
    height: auto;
    padding: 10px 12px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }

  .rail-logo {
    width: 38px;
    height: 38px;
    margin-right: 4px;
  }

  .rail-line,
  .rail .spacer {
    display: none;
  }

  .rail button {
    flex: none;
    width: 84px;
    height: 54px;
  }

  .rail button.active::before {
    top: auto;
    bottom: -11px;
    left: 18px;
    right: 18px;
    width: auto;
    height: 4px;
    border-radius: 4px 4px 0 0;
  }

  .panel {
    position: static;
    height: auto;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .panel-title,
  .panel .spacer,
  .bot-card,
  .user-chip {
    display: none;
  }

  .panel .nav {
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .panel .nav button {
    flex: none;
  }

  .topbar {
    height: auto;
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  .topbar .grow {
    display: none;
  }

  .topbar .search-open {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .crumbs {
    width: 100%;
  }

  .main {
    padding: 22px 16px 70px;
  }
}

/* The fresh start: a red edge, and a bar that fills as it goes. */
.danger-zone {
  border-color: var(--danger);
  background: linear-gradient(180deg, var(--danger-soft), transparent 140px), var(--surface);
}

.reset-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.reset-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent-gradient);
  transition: width 0.6s ease;
}
