:root {
  --bg-tertiary: #1e1f22;
  --bg-secondary: #2b2d31;
  --bg-primary: #313338;
  --bg-modifier-hover: #393c41;
  --bg-modifier-active: #404249;
  --bg-floating: #111214;
  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --text-header: #f2f3f5;
  --blurple: #5865f2;
  --blurple-dark: #4752c4;
  --green: #23a55a;
  --green-dark: #1a7943;
  --red: #f23f43;
  --yellow: #f0b232;
  --toggle-off: #80848e;
  --rail-size: 72px;
  --icon-size: 48px;
  --font: "Figtree", "gg sans", "Noto Sans", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.375;
  color: var(--text-normal);
  background: var(--bg-tertiary);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── Server rail ─────────────────────────────────────── */

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 var(--rail-size);
  padding: 12px 0;
  gap: 8px;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.rail-scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  overflow-y: auto;
  scrollbar-width: none;
  flex: 0 1 auto;
}

.rail-scroll::-webkit-scrollbar {
  display: none;
}

.rail-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-size);
  height: var(--icon-size);
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-primary);
  color: var(--text-normal);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  overflow: visible;
  transition:
    border-radius 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease;
}

.rail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.rail-icon-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
}

.rail-item:hover,
.rail-item:focus-visible,
.rail-item.active {
  border-radius: 16px;
  background: var(--blurple);
  color: #fff;
}

.rail-item::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 4px;
  height: 0;
  border-radius: 0 4px 4px 0;
  background: var(--text-header);
  transform: translateY(-50%);
  transition: height 0.18s ease;
}

.rail-item:hover::before {
  height: 20px;
}

.rail-item.active::before {
  height: 40px;
}

.rail-item.offline .rail-icon-inner {
  filter: grayscale(1);
  opacity: 0.55;
}

.rail-divider {
  width: 32px;
  height: 2px;
  border-radius: 1px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.rail-add {
  color: var(--green);
}

.rail-add:hover,
.rail-add:focus-visible {
  background: var(--green);
  color: #fff;
}

.rail-add::before {
  display: none;
}

.rail-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  flex-shrink: 0;
}

.rail-user-badge {
  cursor: default;
}

.rail-user-badge:hover,
.rail-user-badge:focus-visible {
  border-radius: 50%;
  background: var(--bg-primary);
  color: var(--text-normal);
}

.rail-user-badge::before,
.rail-logout::before {
  display: none;
}

.rail-logout {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
}

.rail-logout:hover,
.rail-logout:focus-visible {
  background: var(--red);
  color: #fff;
}

.rail-entry {
  position: relative;
  flex-shrink: 0;
}

.rail-entry.dragging {
  opacity: 0.35;
}

.rail-entry.drop-before::after,
.rail-entry.drop-after::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  height: 4px;
  border-radius: 2px;
  background: var(--blurple);
  pointer-events: none;
  z-index: 1;
}

.rail-entry.drop-before::after {
  top: -6px;
}

.rail-entry.drop-after::after {
  bottom: -6px;
}

.rail-entry.drop-combine > .rail-item {
  border-radius: 16px;
  box-shadow: 0 0 0 2px var(--blurple);
}

.rail-folder {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rail-folder.open {
  gap: 8px;
  padding-bottom: 8px;
  border-radius: 24px;
  background: var(--bg-secondary);
}

.rail-folder-icon {
  background: var(--bg-primary);
  color: var(--text-muted);
}

.rail-folder-icon:hover,
.rail-folder-icon:focus-visible {
  border-radius: 16px;
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.rail-folder-icon.open,
.rail-folder-icon.open:hover,
.rail-folder-icon.open:focus-visible {
  border-radius: 16px;
  background: rgba(88, 101, 242, 0.24);
  color: var(--blurple);
}

.rail-folder-icon.holds-active::before {
  height: 40px;
}

.rail-folder-preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  width: 100%;
  height: 100%;
  padding: 6px;
  border-radius: inherit;
}

.rail-folder-preview img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.rail-folder-preview .mini-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-secondary);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-normal);
}

.rail-folder-items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ── Main panel ──────────────────────────────────────── */

.panel {
  flex: 1;
  min-width: 0;
  background: var(--bg-primary);
  border-radius: 8px 0 0 0;
  overflow-y: auto;
  padding-bottom: 96px;
  scrollbar-color: var(--bg-tertiary) transparent;
}

.panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid var(--bg-modifier-active);
  border-top-color: var(--blurple);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.guild-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg-primary) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bg-tertiary);
}

.guild-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.guild-header-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.guild-header-info {
  min-width: 0;
}

.guild-header-name {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-header);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guild-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
}

.guild-id {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 1px 6px;
  cursor: pointer;
  border: 0;
  color: var(--text-muted);
}

.guild-id:hover {
  color: var(--text-normal);
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.presence::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--toggle-off);
}

.presence.online {
  color: var(--green);
}

.presence.online::before {
  background: var(--green);
}

.invite-link {
  color: #00a8fc;
  font-weight: 600;
  text-decoration: none;
}

.invite-link:hover {
  text-decoration: underline;
}

.guild-body {
  max-width: 780px;
  padding: 20px 24px 40px;
}

.section-title {
  margin: 24px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-title:first-child {
  margin-top: 4px;
}

/* ── Kit cards ───────────────────────────────────────── */

.kit-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--bg-secondary);
  animation: rise 0.25s ease both;
}

.kit-card:nth-child(2) {
  animation-delay: 0.02s;
}
.kit-card:nth-child(3) {
  animation-delay: 0.04s;
}
.kit-card:nth-child(4) {
  animation-delay: 0.06s;
}
.kit-card:nth-child(5) {
  animation-delay: 0.08s;
}
.kit-card:nth-child(6) {
  animation-delay: 0.1s;
}
.kit-card:nth-child(7) {
  animation-delay: 0.12s;
}
.kit-card:nth-child(8) {
  animation-delay: 0.14s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.kit-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kit-info {
  flex: 1;
  min-width: 0;
}

.kit-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-header);
}

.kit-desc {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.kit-locked {
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.kit-commands {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cmd-chip {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.chip-more {
  background: none;
  border: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #00a8fc;
  cursor: pointer;
  padding: 2px 4px;
}

/* ── Toggle switch ───────────────────────────────────── */

.toggle {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 24px;
  border: 0;
  border-radius: 14px;
  background: var(--toggle-off);
  cursor: pointer;
  padding: 0;
  transition: background-color 0.18s ease;
}

.toggle .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.18s ease;
}

.toggle svg {
  position: absolute;
  inset: 0;
  margin: auto;
  transition: opacity 0.18s ease;
}

.toggle .glyph-on {
  color: var(--green);
  opacity: 0;
}

.toggle .glyph-off {
  color: var(--toggle-off);
  opacity: 1;
}

.toggle[aria-checked="true"] {
  background: var(--green);
}

.toggle[aria-checked="true"] .knob {
  left: 19px;
}

.toggle[aria-checked="true"] .glyph-on {
  opacity: 1;
}

.toggle[aria-checked="true"] .glyph-off {
  opacity: 0;
}

.toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toggle:focus-visible,
.btn:focus-visible,
.rail-item:focus-visible {
  outline: 2px solid var(--blurple);
  outline-offset: 2px;
}

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blurple);
}

.btn-primary:hover {
  background: var(--blurple-dark);
}

.btn-success {
  background: var(--green);
}

.btn-success:hover {
  background: var(--green-dark);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
}

.btn-danger:hover,
.btn-danger.armed {
  background: var(--red);
  color: #fff;
}

.btn-small {
  padding: 3px 10px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-normal);
}

.btn-ghost:hover {
  text-decoration: underline;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Save bar ────────────────────────────────────────── */

.savebar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(740px, calc(100vw - 32px));
  padding: 10px 10px 10px 16px;
  border-radius: 8px;
  background: var(--bg-floating);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transform: translateX(-50%);
  animation: savebar-in 0.2s ease;
}

@keyframes savebar-in {
  from {
    transform: translate(-50%, 12px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.savebar.shake {
  animation: shake 0.3s ease;
}

@keyframes shake {
  20% {
    transform: translate(calc(-50% - 6px), 0);
  }
  40% {
    transform: translate(calc(-50% + 6px), 0);
  }
  60% {
    transform: translate(calc(-50% - 4px), 0);
  }
  80% {
    transform: translate(calc(-50% + 4px), 0);
  }
}

.savebar-text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-header);
}

.savebar-actions {
  display: flex;
  gap: 8px;
}

/* ── Modal ───────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  padding: 16px;
}

.modal {
  width: min(460px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border-radius: 8px;
  background: var(--bg-primary);
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px 20px 0;
  text-align: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-header);
}

.modal-subtitle {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: block;
  border: 0;
  margin: 0;
  padding: 0;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.field input[type="text"] {
  width: 100%;
  padding: 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-normal);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
}

.field input[type="text"]:focus {
  border-color: var(--blurple);
}

.modal-kits {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-kit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  background: var(--bg-secondary);
  cursor: pointer;
}

.modal-kit:hover {
  background: var(--bg-modifier-hover);
}

.modal-kit .kit-name {
  flex: 1;
  font-size: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-radius: 0 0 8px 8px;
}

/* ── Toasts ──────────────────────────────────────────── */

.toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(480px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--bg-floating);
  color: var(--text-header);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s ease;
}

.toast.leaving {
  transition: opacity 0.3s ease;
  opacity: 0;
}

@keyframes toast-in {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.toast::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--green);
}

.toast.error::before {
  background: var(--red);
}

.toast.warn::before {
  background: var(--yellow);
}

/* ── Empty state ─────────────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty h2 {
  margin: 0;
  color: var(--text-header);
  font-size: 20px;
}

/* ── Mobile ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .rail {
    flex-direction: row;
    flex: 0 0 auto;
    width: 100%;
    padding: 8px 12px;
    gap: 8px;
  }

  .rail-scroll {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 0 1 auto;
    min-width: 0;
  }

  .rail-divider {
    width: 2px;
    height: 32px;
    align-self: center;
  }

  .rail-item {
    width: 44px;
    height: 44px;
  }

  .rail-item::before {
    left: 50%;
    top: auto;
    bottom: -8px;
    width: 0;
    height: 4px;
    border-radius: 4px 4px 0 0;
    transform: translateX(-50%);
  }

  .rail-item:hover::before {
    width: 20px;
  }

  .rail-item.active::before {
    width: 32px;
  }

  .panel {
    border-radius: 8px 8px 0 0;
  }

  .guild-header {
    padding: 12px 16px;
  }

  .guild-body {
    padding: 16px 16px 40px;
  }

  .savebar {
    flex-wrap: wrap;
    bottom: 12px;
  }

  .savebar-actions {
    margin-left: auto;
  }
}

/* ── Guild tabs ──────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 24px 0;
  border-bottom: 1px solid var(--bg-tertiary);
}

.tab {
  position: relative;
  background: none;
  border: 0;
  border-radius: 4px 4px 0 0;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.tab:hover {
  color: var(--text-normal);
  background: var(--bg-modifier-hover);
}

.tab.active {
  color: var(--text-header);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--blurple);
}

.guild-body.wide {
  max-width: 1160px;
}

.guild-body.welcome-wide {
  max-width: 1400px;
}

/* ── Custom commands: list ───────────────────────────── */

.cc-loading {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}

.cc-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.cc-toolbar-hint {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 460px;
}

.cc-empty {
  padding: 36px 24px;
  border-radius: 8px;
  border: 1px dashed var(--bg-modifier-active);
  text-align: center;
  color: var(--text-muted);
}

.cc-empty h3 {
  margin: 0 0 6px;
  color: var(--text-header);
  font-size: 16px;
}

.cc-empty p {
  margin: 0;
  font-size: 14px;
}

.cc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-normal);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  animation: rise 0.25s ease both;
}

.cc-card:hover {
  background: var(--bg-modifier-hover);
}

.cc-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cc-card-name {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-header);
}

.cc-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cc-card-chevron {
  font-size: 22px;
  color: var(--text-muted);
}

.cc-chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.cc-chip.role.add {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, transparent);
}

.cc-chip.role.remove {
  color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, transparent);
}

.cc-chip.cond {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--bg-modifier-active);
}

.cc-count {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Custom commands: editor ─────────────────────────── */

.cc-editor-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
}

.cc-back {
  background: none;
  border: 0;
  padding: 4px 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.cc-back:hover {
  color: var(--text-normal);
}

.cc-editor-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

.cc-editor-name {
  margin: 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-header);
}

.cc-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cc-name-prefix {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-muted);
}

.cc-name-input {
  width: min(280px, 60vw);
  padding: 8px 10px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-header);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
}

.cc-name-input:focus {
  border-color: var(--blurple);
}

.cc-name-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.cc-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.cc-preview-pane {
  position: sticky;
  top: 132px;
}

.cc-section {
  margin-top: 8px;
}

.cc-section + .cc-section {
  margin-top: 24px;
}

.cc-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cc-section-head .section-title {
  margin: 0;
}

.cc-section-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.cc-section-hint {
  margin: 4px 0 10px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Blocks ──────────────────────────────────────────── */

.cc-block {
  position: relative;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--bg-secondary);
}

.cc-block:has(.cc-picker-menu) {
  z-index: 20;
}

.cc-block.cond.on {
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--blurple) 45%, transparent);
}

.cc-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cc-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
}

.cc-badge.chat {
  color: var(--blurple);
  background: color-mix(in srgb, var(--blurple) 15%, transparent);
}

.cc-badge.plus {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 15%, transparent);
}

.cc-badge.minus {
  color: var(--red);
  background: color-mix(in srgb, var(--red) 15%, transparent);
}

.cc-badge.dm {
  color: var(--blurple);
  background: color-mix(in srgb, var(--blurple) 15%, transparent);
}

.cc-badge.smile {
  color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 15%, transparent);
}

.cc-block-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.cc-block-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-header);
}

.cc-block-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.cc-block-controls {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.cc-icon-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}

.cc-icon-btn:hover:not(:disabled) {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.cc-icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.cc-block-body {
  margin-top: 10px;
}

.cc-textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-normal);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
  resize: vertical;
}

.cc-textarea:focus {
  border-color: var(--blurple);
}

.cc-char-count {
  display: block;
  margin-top: 4px;
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
}

.cc-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.cc-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px dashed var(--bg-modifier-active);
  border-radius: 8px;
  background: transparent;
  color: var(--text-normal);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.cc-add-btn:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

.cc-add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Editor inputs ───────────────────────────────────── */

.cc-text-input {
  width: min(320px, 100%);
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-normal);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
}

.cc-text-input:focus {
  border-color: var(--blurple);
}

.cc-number-input {
  width: 90px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-normal);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
}

.cc-number-input:focus {
  border-color: var(--blurple);
}

.cc-cooldown-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.cc-inline-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.cc-segment {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: var(--bg-tertiary);
}

.cc-segment-btn {
  border: 0;
  border-radius: 4px;
  padding: 7px 12px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.cc-segment-btn:hover {
  color: var(--text-normal);
}

.cc-segment-btn.active {
  background: var(--blurple);
  color: #fff;
}

.cc-field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Role picker ─────────────────────────────────────── */

.cc-picker-wrap {
  position: relative;
  max-width: 320px;
}

.cc-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.cc-picker:hover:not(.disabled) {
  border-color: var(--bg-modifier-active);
}

.cc-picker.disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.cc-picker-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-picker-value.placeholder {
  color: var(--text-muted);
}

.cc-picker-caret {
  color: var(--text-muted);
  font-size: 11px;
}

.cc-role-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cc-picker-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  padding: 8px;
  border-radius: 8px;
  background: var(--bg-floating);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.cc-picker-search {
  width: 100%;
  padding: 8px;
  margin-bottom: 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.cc-picker-search:focus {
  border-color: var(--blurple);
}

.cc-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}

.cc-picker-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text-normal);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.cc-picker-option:hover {
  background: var(--bg-modifier-hover);
}

.cc-picker-option.active {
  background: var(--bg-modifier-active);
}

.cc-picker-none {
  margin: 0;
  padding: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Channel checklist ───────────────────────────────── */

.cc-channel-list {
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-tertiary);
}

.cc-channel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cc-channel-head .cc-picker-search {
  flex: 1;
  margin-bottom: 0;
  background: var(--bg-primary);
}

.cc-channel-scroll {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 8px;
}

.cc-channel-group {
  margin: 8px 0 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.cc-channel-group:first-child {
  margin-top: 0;
}

.cc-channel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

.cc-channel-row:hover {
  background: var(--bg-modifier-hover);
}

.cc-check {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 2px solid var(--toggle-off);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease;
}

.cc-check:hover:not(:disabled) {
  border-color: var(--text-muted);
}

.cc-check:checked {
  border-color: var(--blurple);
  background: var(--blurple)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M8.99991 16.17L4.82991 12L3.40991 13.41L8.99991 19L20.9999 7.00003L19.5899 5.59003L8.99991 16.17Z'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

.cc-check:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cc-check:focus-visible {
  outline: 2px solid var(--blurple);
  outline-offset: 2px;
}

.cc-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-normal);
  cursor: pointer;
  user-select: none;
}

.cc-emoji-input {
  width: 140px;
}

.cc-emoji-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.cc-emoji-picker {
  width: 200px;
}

.cc-emoji-picker .cc-picker-menu {
  width: 296px;
  right: auto;
}

.cc-emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}

.cc-emoji-grid .cc-picker-none {
  grid-column: 1 / -1;
}

.cc-emoji-option {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: none;
  padding: 5px;
  cursor: pointer;
}

.cc-emoji-option:hover {
  background: var(--bg-modifier-hover);
}

.cc-emoji-option img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.cc-role-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cc-role-pills:not(:empty) {
  margin-bottom: 8px;
}

.cc-role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  border-radius: 14px;
  background: var(--bg-tertiary);
  font-size: 13px;
  color: var(--text-normal);
}

.cc-role-pill button {
  border: 0;
  background: none;
  padding: 0 6px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}

.cc-role-pill button:hover {
  color: var(--text-normal);
}

.cc-opt-check {
  margin-left: auto;
  color: var(--blurple);
  font-weight: 700;
  visibility: hidden;
}

.cc-picker-option.selected .cc-opt-check {
  visibility: visible;
}

.cc-picker-option:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cc-channel-hash {
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Chat preview ────────────────────────────────────── */

.chat-preview {
  padding: 14px;
  border-radius: 8px;
  background: var(--bg-secondary);
}

.chat-preview-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.chat-msg {
  display: flex;
  gap: 10px;
  padding: 6px 0;
}

.chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-avatar.user {
  background: var(--bg-modifier-active);
  color: var(--text-normal);
}

.chat-avatar.bot {
  background: var(--blurple);
  color: #fff;
  overflow: hidden;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chat-msg-body {
  min-width: 0;
}

.chat-msg-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.chat-author {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-header);
}

.chat-bot-badge {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--blurple);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chat-time {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-text {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--text-normal);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-text strong {
  font-weight: 700;
  color: var(--text-header);
}

.chat-text code {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.chat-line {
  min-height: 1.375em;
}

.chat-h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-header);
  margin: 4px 0 2px;
}

.chat-h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-header);
  margin: 4px 0 2px;
}

.chat-h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-header);
  margin: 4px 0 2px;
}

.chat-subtext {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-quote {
  border-left: 3px solid var(--bg-modifier-active);
  border-radius: 2px;
  padding-left: 10px;
  margin: 2px 0;
}

.chat-codeblock {
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  overflow-x: auto;
  white-space: pre;
}

.chat-reply-ref {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.chat-reaction {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  font-size: 13px;
}

.chat-reaction-count {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.chat-emoji {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: -3px;
}

.chat-dm-label {
  margin: 12px 0 2px;
  padding-top: 10px;
  border-top: 1px solid var(--bg-tertiary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.chat-msg.deleted .chat-text {
  opacity: 0.5;
  text-decoration: line-through;
}

.chat-system {
  padding: 4px 0 4px 46px;
  font-size: 13px;
  color: var(--text-muted);
}

.chat-role-pill {
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 600;
  background: color-mix(in srgb, currentColor 16%, transparent);
}

.cc-attachment {
  margin-top: 8px;
}

.cc-file-pill {
  max-width: 100%;
}

.cc-file-pill > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attachment {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid var(--bg-tertiary);
  border-radius: 6px;
  background: var(--bg-secondary);
  font-size: 13px;
}

.chat-attachment-name {
  color: var(--blurple);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.chat-attachment-size {
  color: var(--text-muted);
  font-size: 12px;
}

.chat-preview-notes {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--bg-tertiary);
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Builder responsive ──────────────────────────────── */

@media (max-width: 1100px) {
  .cc-editor-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .cc-preview-pane {
    position: static;
  }
}

@media (max-width: 768px) {
  .tabs {
    padding: 8px 16px 0;
    overflow-x: auto;
  }

  .cc-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .cc-toolbar .btn {
    align-self: flex-start;
  }

  .cc-add-row {
    flex-direction: column;
  }

  .cc-add-btn {
    justify-content: flex-start;
  }

  .cc-icon-btn {
    width: 34px;
    height: 34px;
  }

  .cc-picker-wrap,
  .cc-text-input {
    max-width: 100%;
  }

  .cc-name-input {
    width: 100%;
  }

  .cc-name-wrap {
    width: 100%;
  }
}

/* ── Config tab ──────────────────────────────────────── */

.cfg-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.cfg-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.wl-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 830px);
}

@media (max-width: 1340px) {
  .wl-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cfg-grid .kit-card {
  margin-bottom: 0;
}

.cfg-grid .kit-card:has(.cfg-popover) {
  z-index: 21;
}

@media (max-width: 980px) {
  .cfg-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cfg-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cfg-card .kit-desc {
  margin: 0;
}

.cfg-field {
  max-width: 420px;
}

.cfg-select,
.cfg-number,
.cfg-date,
.cfg-text {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-normal);
  background-color: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.12s ease;
}

.cfg-select:hover,
.cfg-number:hover,
.cfg-date:hover,
.cfg-text:hover {
  border-color: var(--bg-modifier-active);
}

.cfg-select:focus,
.cfg-number:focus,
.cfg-date:focus,
.cfg-text:focus {
  border-color: var(--blurple);
}

.cfg-select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23949ba4' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  cursor: pointer;
}

.cfg-select option {
  background: var(--bg-floating);
  color: var(--text-normal);
}

.cfg-date {
  cursor: pointer;
  caret-color: transparent;
}

.cfg-number {
  appearance: textfield;
}

.cfg-number::-webkit-inner-spin-button,
.cfg-number::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.cfg-picker-wrap {
  position: relative;
}

.cfg-popover {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-floating);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: rise 0.15s ease both;
}

.cfg-color-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cfg-color-btn {
  width: 64px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--bg-modifier-active);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.12s ease;
}

.cfg-color-btn:hover {
  border-color: var(--text-muted);
}

.cfg-color-btn.empty {
  background: linear-gradient(
      to top right,
      transparent calc(50% - 1px),
      var(--red) calc(50% - 1px),
      var(--red) calc(50% + 1px),
      transparent calc(50% + 1px)
    )
    var(--bg-tertiary);
}

.cfg-color-status {
  color: var(--text-muted);
  font-size: 14px;
  min-width: 72px;
}

.cfg-color-pop {
  width: 254px;
}

.cfg-swatches {
  display: grid;
  grid-template-columns: repeat(10, 20px);
  gap: 6px;
}

.cfg-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.cfg-swatch:hover {
  outline: 2px solid var(--text-muted);
  outline-offset: 1px;
}

.cfg-swatch.active {
  outline: 2px solid var(--text-header);
  outline-offset: 1px;
}

.cfg-hex-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.cfg-hex-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 14px;
  color: var(--text-normal);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
  text-transform: uppercase;
}

.cfg-hex-input:focus {
  border-color: var(--blurple);
}

.cfg-cal {
  width: 240px;
  user-select: none;
}

.cfg-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cfg-cal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-header);
}

.cfg-cal-nav {
  display: flex;
  gap: 4px;
}

.cfg-cal-nav button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}

.cfg-cal-nav button:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.cfg-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 32px);
  gap: 2px;
  justify-content: center;
}

.cfg-cal-dow {
  padding: 4px 0;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cfg-cal-day {
  height: 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-normal);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.cfg-cal-day:hover {
  background: var(--bg-modifier-hover);
}

.cfg-cal-day.today {
  box-shadow: inset 0 0 0 1px var(--blurple);
}

.cfg-cal-day.selected {
  background: var(--blurple);
  color: #fff;
}

.cfg-cal-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.cfg-cal-footer button {
  padding: 4px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #00a8fc;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.cfg-cal-footer button:hover {
  text-decoration: underline;
}

.cfg-weekdays {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.cfg-weekday {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-normal);
  cursor: pointer;
  user-select: none;
}

.cfg-active-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cfg-active-row .field-label {
  margin: 0;
}

.cfg-sv {
  position: relative;
  height: 140px;
  margin-bottom: 12px;
  border-radius: 4px;
  cursor: crosshair;
  touch-action: none;
}

.cfg-sv-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.cfg-hue {
  position: relative;
  height: 12px;
  margin-bottom: 12px;
  border-radius: 6px;
  background: linear-gradient(
    to right,
    #f00,
    #ff0,
    #0f0,
    #0ff,
    #00f,
    #f0f,
    #f00
  );
  cursor: pointer;
  touch-action: none;
}

.cfg-hue-handle {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* ── Welcome tab ─────────────────────────────────────────── */

.wl-section-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.wl-control-group .wl-section-title:not(:first-child) {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.wl-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

.wl-inline {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 8px;
}

.wl-inline-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wl-pair {
  display: flex;
  gap: 8px;
}

.wl-mini {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wl-mini-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.wl-input {
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
  min-width: 0;
  width: 100%;
}

.wl-seg {
  display: flex;
  gap: 4px;
}

.wl-seg-btn {
  flex: 1;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.wl-seg-btn:hover {
  color: var(--text-normal);
}

.wl-seg-btn.active {
  background: var(--blurple);
  color: #fff;
}

.wl-color {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.wl-color-btn {
  width: 46px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.wl-color-status {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

/* ── Welcome layouts gallery ── */

.wl-templates-host {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg-tertiary);
}

.wl-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.wl-template {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--bg-secondary);
  cursor: pointer;
  font: inherit;
  transition:
    border-color 0.12s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

.wl-template:hover {
  border-color: var(--blurple);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.wl-template-frame {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wl-template-thumb {
  position: relative;
  overflow: hidden;
  outline: 1px solid rgba(255, 255, 255, 0.08);
}

.wl-template-el {
  position: absolute;
  pointer-events: none;
}

.wl-template-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-normal);
}

/* ── Welcome builder controls ── */

.wl-controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg-tertiary);
}

.wl-control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  min-width: 0;
}

.wl-control-group + .wl-control-group {
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

@media (max-width: 980px) {
  .wl-controls-row {
    grid-template-columns: 1fr;
  }

  .wl-control-group + .wl-control-group {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
}

/* ── Welcome editor stage ── */

.wl-editor {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}

.wl-stage-host {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg-floating);
}

.wl-stage-host .wl-hint {
  text-align: center;
  max-width: 480px;
}

.wl-stage {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

.wl-stage-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.wl-layer {
  position: absolute;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.wl-layer:active {
  cursor: grabbing;
}

.wl-layer.selected {
  outline: 2px dashed var(--blurple);
  outline-offset: 2px;
}

.wl-layer-avatar {
  background-color: var(--blurple);
  background-size: cover;
  background-position: center;
}

.wl-layer-text {
  line-height: 1.15;
  white-space: pre;
}

.wl-layer-image {
  background-size: cover;
  background-position: center;
}

.wl-layer-image.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--text-muted);
  color: var(--text-muted);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
}

/* ── Welcome sidebar ── */

.wl-sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg-tertiary);
  max-height: 640px;
  overflow-y: auto;
  scrollbar-color: var(--bg-modifier-active) transparent;
  scrollbar-width: thin;
}

.wl-sidebar-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.wl-sidebar .wl-sidebar-title:not(:first-child) {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.wl-add-row {
  display: flex;
  gap: 6px;
}

.wl-add-btn {
  flex: 1;
  height: 30px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition:
    border-color 0.12s ease,
    background 0.12s ease,
    color 0.12s ease;
}

.wl-add-btn:hover {
  border-color: var(--blurple);
  background: rgba(88, 101, 242, 0.1);
  color: var(--text-normal);
}

.wl-layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wl-layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  transition:
    background 0.12s ease,
    border-color 0.12s ease;
}

.wl-layer-row:hover {
  background: var(--bg-modifier-hover);
}

.wl-layer-row.selected {
  border-color: var(--blurple);
  background: rgba(88, 101, 242, 0.12);
}

.wl-layer-badge {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.wl-layer-badge.avatar {
  background: var(--blurple);
}

.wl-layer-badge.text {
  background: #1f8b4c;
}

.wl-layer-badge.image {
  background: #ad5713;
}

.wl-layer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  background: none;
  border: none;
  padding: 2px 0;
  color: var(--text-normal);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.wl-layer-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.wl-layer-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
}

.wl-layer-btn:hover {
  background: var(--bg-primary);
  color: var(--text-normal);
}

.wl-layer-btn.danger:hover {
  color: var(--red);
}

.wl-props {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wl-chip-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.wl-chip {
  cursor: pointer;
  border: none;
  font: inherit;
  font-size: 11px;
}

.wl-message-input {
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
}

.wl-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wl-slider {
  flex: 1;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  height: 16px;
  margin: 0;
  background: none;
  cursor: pointer;
}

.wl-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--blurple) var(--wl-fill, 0%),
    var(--bg-modifier-active) var(--wl-fill, 0%)
  );
}

.wl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease;
}

.wl-slider:hover::-webkit-slider-thumb,
.wl-slider:active::-webkit-slider-thumb {
  transform: scale(1.2);
}

.wl-slider:focus-visible {
  outline: none;
}

.wl-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.45);
}

.wl-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-modifier-active);
}

.wl-slider::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--blurple);
}

.wl-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.wl-slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.45);
}

.wl-slider-value {
  min-width: 42px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-normal);
  text-align: center;
}

.wl-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wl-upload-thumb img {
  display: block;
  max-width: 120px;
  max-height: 60px;
  border-radius: 4px;
}

/* ── Welcome preview panel ── */

.wl-preview {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wl-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wl-preview-output:empty {
  display: none;
}

.wl-preview-output img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

@media (max-width: 980px) {
  .wl-editor {
    flex-direction: column;
  }

  .wl-sidebar {
    width: 100%;
  }
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
}

.history-table thead {
  background: var(--bg-secondary);
}

.history-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-header);
  border-bottom: 1px solid var(--bg-modifier-active);
}

.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-normal);
}

.history-table tbody tr:hover {
  background: var(--bg-modifier-hover);
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  margin-top: 1rem;
}

.readonly-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-modifier-active);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.guild-body.readonly :is(input, select, textarea, button):not(.chip-more) {
  pointer-events: none;
  opacity: 0.55;
}

.kit-visibility {
  margin-right: 12px;
  white-space: nowrap;
}

.kit-visibility.hidden-from-users {
  color: var(--text-muted);
  opacity: 0.75;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  max-width: 420px;
  width: 100%;
  padding: 40px 32px;
  border-radius: 12px;
  background: var(--bg-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-secondary);
}

.login-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-header);
}

.login-desc {
  margin: 0;
  color: var(--text-muted);
}

.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: 6px;
  background: var(--blurple);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease;
}

.btn-discord:hover {
  background: var(--blurple-dark);
}

.login-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
