/*
 * Probe dashboard
 * Visual language follows probe.ac: black canvas, thin rules, IBM Plex Sans,
 * nearly square controls, and the purple Probe mark as the only brand colour.
 */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/plex-sans-regular.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/plex-sans-medium.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/plex-sans-semibold.woff2") format("woff2");
}

/* ---- Tokens ----------------------------------------------------------- */

:root {
  color-scheme: dark;

  --bg: #000;
  --surface: #0a0a0a;
  --surface-2: #141414;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --dim: #8f8f8f;
  --line: #262626;
  --line-strong: #404040;
  --accent: #e6c5a5;
  --brand: #a07cff;
  --on-primary: #0a0a0a;
  --primary: #f5f5f5;
  --primary-hover: #e6c5a5;

  --success: #79dca9;
  --warning: #f0c47e;
  --danger: #f09aa8;
  --danger-bg: rgba(240, 154, 168, 0.08);
  --danger-line: rgba(240, 154, 168, 0.35);
  --danger-solid: #f2a3ae;
  --on-danger: #1f0408;

  /* Discord message preview */
  --discord-bg: #313338;
  --discord-embed: #2b2d31;
  --discord-line: #3f4147;
  --discord-text: #dbdee1;
  --discord-heading: #f2f3f5;
  --discord-muted: #b5bac1;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --max: 86.25rem;
  --pad: 3rem;
  --control: 2.75rem;
  --radius: 2px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #fafafa;
  --surface: #fff;
  --surface-2: #f0f0f0;
  --text: #0a0a0a;
  --muted: #525252;
  --dim: #646464;
  --line: #e3e3e3;
  --line-strong: #c4c4c4;
  --accent: #8a5527;
  --brand: #6b3fd4;
  --on-primary: #fafafa;
  --primary: #0a0a0a;
  --primary-hover: #333;

  --success: #13704a;
  --warning: #8a5800;
  --danger: #b42318;
  --danger-bg: #fdf1f0;
  --danger-line: #f1b8b2;
  --danger-solid: #b42318;
  --on-danger: #fff;

  --discord-bg: #fff;
  --discord-embed: #f2f3f5;
  --discord-line: #e3e5e8;
  --discord-text: #313338;
  --discord-heading: #060607;
  --discord-muted: #4e5058;
}

/* ---- Base ------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
  scrollbar-color: var(--line-strong) var(--bg);
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  font-synthesis: none;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition: none !important;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3 {
  font-weight: 500;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

ul,
ol {
  list-style: none;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

main:focus,
#view-title:focus,
#rule-editor-title:focus {
  outline: none;
}

.icon-library {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: -8rem;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 0.875rem;
  font-weight: 500;
}

.skip-link:focus {
  top: 1rem;
}

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

.section-label {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

/* Shared page width */
.topbar-inner,
.notice,
.login-screen,
.app-grid,
.standalone-state {
  width: min(var(--max), 100% - var(--pad) * 2);
  margin-inline: auto;
}

/* ---- Buttons ---------------------------------------------------------- */

.button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--control);
  padding: 0.625rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button .icon {
  width: 1rem;
  height: 1rem;
}

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

.primary-button {
  background: var(--primary);
  color: var(--on-primary);
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.secondary-button {
  border-color: var(--line-strong);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--text);
}

.quiet-button {
  color: var(--muted);
}

.quiet-button:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.danger-quiet {
  color: var(--danger);
}

.danger-quiet:hover:not(:disabled) {
  background: var(--danger-bg);
  color: var(--danger);
}

.danger-button {
  background: var(--danger-solid);
  color: var(--on-danger);
}

.danger-button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.icon-button {
  width: var(--control);
  padding: 0;
  border-color: var(--line-strong);
}

.icon-button:hover:not(:disabled) {
  border-color: var(--text);
}

.icon-button .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.icon-button.danger-quiet {
  border-color: var(--line);
}

.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.25em;
  transition: text-decoration-color 160ms ease;
}

.text-button:hover {
  text-decoration-color: currentColor;
}

.spinner {
  display: inline-block;
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--line-strong);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.button .spinner {
  width: 1em;
  height: 1em;
  border-color: currentColor;
  border-top-color: transparent;
}

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

/* ---- Badges, icons, notes --------------------------------------------- */

.badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.4375rem;
  min-height: 1.5rem;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 1px;
  background: var(--dim);
}

.badge.success {
  color: var(--success);
}

.badge.warning {
  color: var(--warning);
}

.badge.success::before,
.badge.warning::before {
  background: currentColor;
}

.feature-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
}

.feature-icon .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.feature-icon.danger-icon {
  border-color: var(--danger-line);
  color: var(--danger);
}

.logo-mark,
.logo-icon,
.bot-avatar {
  background: url("/assets/probe-logo.png") center / 58% auto no-repeat;
}

.logo-icon {
  background-color: var(--surface);
}

.soft-note {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--line);
  border-left: 2px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
}

.soft-note .icon {
  margin-top: 0.1875rem;
  color: var(--brand);
}

.soft-note strong {
  color: var(--text);
  font-weight: 500;
}

.warning-note {
  border-left-color: var(--warning);
}

.warning-note .icon {
  color: var(--warning);
}

.inline-error {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.875rem;
}

/* ---- Top bar ---------------------------------------------------------- */

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  width: 1.5rem;
  height: auto;
}

.brand-name {
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-label {
  margin-left: 0.25rem;
  padding-left: 0.875rem;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.topbar-actions form {
  display: flex;
}

.signed-in-user {
  max-width: 14rem;
  margin-right: 0.75rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Notice ----------------------------------------------------------- */

.notice {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 0.5rem 0.5rem 0.5rem 1.125rem;
  border: 1px solid var(--line);
  border-left: 2px solid var(--success);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.9375rem;
}

.notice.error {
  border-left-color: var(--danger);
}

.notice #notice-message {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.notice .icon-button {
  border-color: transparent;
}

/* ---- Startup and fallback states -------------------------------------- */

main {
  flex: 1;
}

.standalone-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 60vh;
  text-align: center;
}

.standalone-state .muted {
  max-width: 32rem;
}

.state-title {
  font-size: 1.75rem;
  line-height: 1.2;
}

/* ---- Login ------------------------------------------------------------ */

.login-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 4vw, 4.5rem);
  padding: clamp(3.5rem, 8vw, 6.5rem) 0 clamp(3rem, 6vw, 5rem);
}

.login-copy h1 {
  margin-top: 0.75rem;
  font-size: clamp(2.75rem, 5vw, 4.75rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.login-description {
  max-width: 30rem;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.65;
}

#login-form {
  margin-top: 2.25rem;
}

.discord-button {
  min-height: 3rem;
  padding-inline: 1.25rem;
  font-size: 0.9375rem;
}

.discord-button .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.login-permissions {
  max-width: 28rem;
  margin-top: 1.25rem;
  color: var(--dim);
  font-size: 0.875rem;
}

.login-brand {
  display: grid;
  place-items: center;
}

.login-brand img {
  width: min(60%, 15rem);
  animation: mark-in 420ms var(--ease) both;
}

@keyframes mark-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.login-tools {
  border-top: 1px solid var(--line);
}

.login-tools > h2 {
  padding: clamp(2.5rem, 5vw, 3.5rem) 0 clamp(2rem, 4vw, 3rem);
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.tool-row {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr) minmax(14rem, 18rem);
  gap: 1rem 3rem;
  padding: 2rem 0 2.25rem;
  border-top: 1px solid var(--line);
}

.tool-row h3 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
}

.tool-row p {
  max-width: 34rem;
  color: var(--muted);
}

.tool-row ul,
.checklist {
  display: grid;
  gap: 0.5rem;
}

.tool-row li {
  position: relative;
  padding-left: 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.tool-row li::before {
  content: "";
  position: absolute;
  top: 0.6em;
  left: 0;
  width: 0.3125rem;
  height: 0.3125rem;
  border-radius: 1px;
  background: var(--brand);
}

.member-link {
  padding: 1.75rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.member-link strong {
  color: var(--text);
  font-weight: 500;
}

.login-footer,
.workspace-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 0.8125rem;
}

.login-footer a {
  text-decoration: none;
}

.login-footer a:hover {
  color: var(--text);
}

/* ---- Workspace shell -------------------------------------------------- */

.app-grid {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  align-items: start;
  gap: 0 clamp(2rem, 4vw, 4rem);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 4.5rem);
  padding: 2.75rem 0 2rem;
}

.field-label {
  display: block;
  margin-bottom: 0.625rem;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 500;
}

.server-select-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.server-initials {
  display: grid;
  flex: none;
  place-items: center;
  width: var(--control);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.server-select-wrap select {
  flex: 1;
  min-width: 0;
}

.server-count {
  margin-top: 0.5rem;
  color: var(--dim);
  font-size: 0.8125rem;
}

.main-nav {
  display: flex;
  flex-direction: column;
  margin-top: 2rem;
  border-top: 1px solid var(--line);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font-size: 0.9375rem;
  text-align: left;
  transition: color 160ms ease, background-color 160ms ease;
}

.nav-item:hover {
  color: var(--text);
}

.nav-item.active {
  background: var(--surface);
  box-shadow: inset 2px 0 0 var(--brand);
  color: var(--text);
  font-weight: 500;
}

.nav-item.active .icon {
  color: var(--brand);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 2rem;
  color: var(--dim);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.workspace-main {
  min-width: 0;
  padding-top: 2.75rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  padding-bottom: 2.25rem;
}

.page-heading {
  min-width: 0;
  max-width: 44rem;
}

.page-header h1 {
  margin-top: 0.375rem;
  font-size: clamp(2.25rem, 3.6vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.page-description {
  margin-top: 0.875rem;
  color: var(--muted);
  font-size: 1.0625rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#view-content {
  min-width: 0;
}

.workspace-footer {
  margin-top: 4.5rem;
}

.stack {
  display: grid;
  gap: 1.5rem;
  min-width: 0;
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* ---- Form controls ---------------------------------------------------- */

input[type="text"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  min-height: var(--control);
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: var(--bg);
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.4;
  transition: border-color 160ms ease;
}

select {
  padding-right: 0.5rem;
  cursor: pointer;
}

/* Windows renders the native option list with these colours. */
select option {
  background-color: var(--surface);
  color: var(--text);
}

input:hover:not(:disabled),
select:hover:not(:disabled) {
  border-color: var(--muted);
}

input:focus-visible,
select:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
}

input::placeholder {
  color: var(--dim);
  opacity: 1;
}

input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input[type="checkbox"] {
  flex: none;
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
  cursor: pointer;
}

fieldset {
  min-width: 0;
  border: 0;
}

fieldset:disabled {
  opacity: 0.75;
}

legend {
  padding: 0;
}

.field {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  margin-bottom: 1.5rem;
}

.field > label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.field small,
.field-hint {
  color: var(--dim);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.field-counter {
  color: var(--dim);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}

.duration-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(6.5rem, 8rem);
  gap: 0.5rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.25rem;
  font-size: 0.9375rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}

/* Switch built on the native checkbox; the knob is a gradient, not an image. */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.switch-label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 500;
}

.switch-description {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
}

input.switch-input {
  flex: none;
  width: 2.75rem;
  height: 1.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2) linear-gradient(var(--muted), var(--muted)) no-repeat 0.1875rem center / 1rem 1rem;
  appearance: none;
  cursor: pointer;
  transition: background-color 160ms ease, background-position 160ms var(--ease), border-color 160ms ease;
}

input.switch-input:checked {
  border-color: var(--brand);
  background-color: var(--brand);
  background-image: linear-gradient(#fff, #fff);
  background-position: calc(100% - 0.1875rem) center;
}

/* ---- Cards ------------------------------------------------------------ */

.card {
  min-width: 0;
  padding: clamp(1.25rem, 2.5vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-title {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.card-title h2 {
  font-size: 1.375rem;
  line-height: 1.25;
}

.card-title p {
  margin-top: 0.375rem;
  color: var(--muted);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.rule-editor {
  margin-bottom: 3rem;
}

.rule-editor > .soft-note {
  margin-bottom: 1.5rem;
}

/* ---- Overview --------------------------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 2rem;
}

.fact {
  min-width: 0;
  padding: 1.25rem 0 2.5rem;
  border-top: 1px solid var(--line-strong);
}

.fact dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.fact dd {
  margin-top: 0.5rem;
  font-size: clamp(1.375rem, 2vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.fact-note {
  display: block;
  margin-top: 0.5rem;
  color: var(--dim);
  font-size: 0.8125rem;
  letter-spacing: 0;
  line-height: 1.4;
}

.overview-row {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr) auto;
  align-items: start;
  gap: 1.25rem 3rem;
  padding: 2.25rem 0 2.5rem;
  border-top: 1px solid var(--line);
}

.overview-row-head {
  display: grid;
  justify-items: start;
  gap: 0.75rem;
}

.overview-row-head h2 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
}

.overview-row-body {
  min-width: 0;
}

.overview-row-body > p {
  max-width: 40rem;
  color: var(--muted);
}

.overview-row-actions {
  display: flex;
  justify-content: flex-end;
}

.checklist {
  margin-top: 1.25rem;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--dim);
  font-size: 0.875rem;
}

.checklist li .icon {
  width: 1rem;
  height: 1rem;
}

.checklist li.done {
  color: var(--text);
}

.checklist li.done .icon {
  color: var(--success);
}

/* ---- Empty states and install steps ----------------------------------- */

.empty-state {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 1.25rem;
  padding: 2.5rem 0;
  border-top: 1px solid var(--line);
}

.empty-copy h2 {
  font-size: 1.5rem;
  line-height: 1.25;
}

.empty-copy p {
  max-width: 38rem;
  margin-top: 0.5rem;
  color: var(--muted);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  grid-column: 2;
  margin-top: 1.5rem;
}

.empty-state.inline-empty {
  padding: 0;
  border-top: 0;
}

.empty-state.inline-empty .empty-copy h2 {
  font-size: 1.25rem;
}

.guild-empty .empty-copy h2 {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
}

.setup-list {
  border-top: 1px solid var(--line);
}

.setup-list li {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.setup-index,
.step-number {
  color: var(--accent);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1.9;
}

.setup-list strong {
  font-weight: 500;
}

.setup-list p {
  color: var(--muted);
  font-size: 0.9375rem;
}

/* ---- Giveaways -------------------------------------------------------- */

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
}

.compose-layout + .section-heading,
.rule-editor + .section-heading {
  margin-top: 1rem;
}

.section-heading h2 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

.section-heading p {
  margin-top: 0.25rem;
  color: var(--dim);
  font-size: 0.875rem;
}

.heading-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.375rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.giveaway-list {
  border-top: 1px solid var(--line);
}

.giveaway-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem 2rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

.giveaway-main {
  min-width: 0;
}

.giveaway-row-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.875rem;
}

.giveaway-row-heading h3 {
  min-width: 0;
  font-size: 1.1875rem;
  line-height: 1.35;
}

.giveaway-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 1.5rem;
  margin-top: 0.625rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.giveaway-meta li {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.giveaway-meta .icon {
  width: 0.9375rem;
  height: 0.9375rem;
  color: var(--dim);
}

.giveaway-rules {
  margin-top: 0.5rem;
  color: var(--dim);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.giveaway-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.giveaway-list.compact {
  border-top: 0;
}

.giveaway-row.compact {
  padding: 1.125rem 0;
}

.giveaway-row.compact:first-child {
  padding-top: 0;
}

.giveaway-row.compact:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.giveaway-row.compact h3 {
  font-size: 1.0625rem;
}

.giveaway-list-note {
  margin-top: 1rem;
  color: var(--dim);
  font-size: 0.8125rem;
}

.compose-layout,
.verification-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 25rem);
  align-items: start;
  gap: 2.5rem;
}

.compose-layout {
  margin-bottom: 3rem;
}

/* Entry rules */
.rules-details {
  margin: 0.25rem 0 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.rules-details summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.75rem 1.125rem;
  font-size: 0.9375rem;
  font-weight: 500;
  list-style: none;
  cursor: pointer;
}

.rules-details summary::-webkit-details-marker {
  display: none;
}

.rules-details summary .badge::before {
  display: none;
}

.rules-details summary > .icon {
  margin-left: auto;
  color: var(--muted);
  transition: transform 160ms var(--ease);
}

.rules-details[open] summary > .icon {
  transform: rotate(180deg);
}

.rules-body {
  padding: 0 1.125rem 1.25rem;
  border-top: 1px solid var(--line);
}

.rules-section {
  padding-top: 1.25rem;
}

.rules-section + .rules-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.rules-section legend {
  float: left;
  width: 100%;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.rules-section legend + * {
  clear: both;
}

.rules-explanation,
.role-limit {
  color: var(--dim);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.rules-explanation {
  margin: 0.25rem 0 0.75rem;
}

.role-picker {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.role-search {
  margin-bottom: 0.5rem;
}

.role-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr));
  gap: 0 1rem;
  max-height: 14rem;
  overflow-y: auto;
}

.role-limit {
  margin-top: 0.5rem;
}

.bonus-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.bonus-list:empty {
  display: none;
}

.bonus-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem var(--control);
  gap: 0.5rem;
}

/* ---- Discord previews ------------------------------------------------- */

.preview-column {
  position: sticky;
  top: 1.5rem;
  min-width: 0;
}

.preview-label {
  margin-bottom: 0.75rem;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 500;
}

.preview-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--discord-bg);
  color: var(--discord-text);
}

.preview-topbar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--discord-line);
  color: var(--discord-heading);
  font-size: 0.875rem;
  font-weight: 600;
}

.preview-topbar .icon {
  width: 1rem;
  height: 1rem;
  color: var(--discord-muted);
}

.preview-channel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-tag {
  margin-left: auto;
  padding: 0 0.375rem;
  border: 1px solid var(--discord-line);
  border-radius: var(--radius);
  color: var(--discord-muted);
  font-size: 0.6875rem;
  font-weight: 500;
}

.preview-body {
  padding: 1rem 0.875rem 1.25rem;
}

.bot-byline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bot-avatar {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background-color: #000;
}

.bot-name {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--discord-heading);
  font-size: 0.9375rem;
  font-weight: 500;
}

.app-badge {
  padding: 0.0625rem 0.3125rem;
  border-radius: 3px;
  background: #5865f2;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1.4;
}

.preview-embed,
.preview-join {
  margin-left: 3.25rem;
}

.preview-embed {
  max-width: 32rem;
  margin-top: 0.25rem;
  padding: 0.75rem 1rem 0.875rem;
  border-left: 4px solid #f2b134;
  border-radius: 4px;
  background: var(--discord-embed);
  font-size: 0.875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.verify-embed {
  border-left-color: #5865f2;
}

.embed-title {
  display: block;
  margin-bottom: 0.375rem;
  color: var(--discord-heading);
  font-size: 1rem;
  font-weight: 600;
}

.embed-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.625rem 1rem;
  margin-top: 0.75rem;
}

.embed-field {
  display: grid;
  grid-column: 1 / -1;
  gap: 0.125rem;
  font-size: 0.8125rem;
}

.embed-field.inline {
  grid-column: auto;
}

.embed-field-name {
  color: var(--discord-heading);
  font-weight: 600;
}

.embed-line {
  display: block;
}

.embed-footer {
  margin-top: 0.75rem;
  color: var(--discord-muted);
  font-size: 0.75rem;
}

.preview-join {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  margin-top: 0.5rem;
  padding: 0.25rem 1rem;
  border-radius: 3px;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
}

.preview-join.blurple {
  background: #5865f2;
}

.preview-join.green {
  background: #248046;
}

.preview-note {
  margin-top: 0.75rem;
  color: var(--dim);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.verification-layout .preview-column > .soft-note {
  margin-top: 1.5rem;
}

/* ---- Verification ----------------------------------------------------- */

.setup-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.setup-step h2 {
  font-size: 1.375rem;
  line-height: 1.3;
}

.setup-step p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.setup-step .step-number {
  padding-top: 0.125rem;
}

.card > form > fieldset > .soft-note {
  margin-bottom: 1.5rem;
}

.card > form > fieldset > .field-hint {
  display: block;
  margin-bottom: 1rem;
}

/* ---- Help & privacy --------------------------------------------------- */

.help-section {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 1.5rem 3rem;
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--line);
}

.help-section-head h2 {
  font-size: 1.5rem;
  line-height: 1.25;
}

.help-section-head p {
  margin-top: 0.875rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.help-definition > div,
.faq-item {
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
}

.help-definition > div:first-child,
.faq-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.help-definition > div {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 0.5rem 2rem;
}

.help-definition dt,
.faq-item h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.6;
}

.help-definition dd,
.faq-item p {
  max-width: 44rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.faq-item p {
  margin-top: 0.25rem;
}

.help-section .soft-note {
  grid-column: 2;
}

/* ---- Confirmation dialog ---------------------------------------------- */

.confirm-dialog {
  width: min(32rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

:root[data-theme="light"] .confirm-dialog::backdrop {
  background: rgba(10, 10, 10, 0.4);
}

.confirm-dialog[open] {
  animation: dialog-in 180ms var(--ease) both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.dialog-content {
  padding: 1.75rem;
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dialog-head h2 {
  font-size: 1.375rem;
  line-height: 1.25;
}

#confirm-description {
  margin-top: 1rem;
  font-size: 0.9375rem;
}

.confirmation-details {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.confirmation-details > div {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
}

.confirmation-details dt {
  color: var(--dim);
}

.confirmation-details dd {
  overflow-wrap: anywhere;
}

#confirm-error {
  margin: 1.25rem 0 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.75rem;
}

/* ---- Responsive ------------------------------------------------------- */

@media (max-width: 1180px) {
  .overview-row {
    grid-template-columns: 11rem minmax(0, 1fr);
  }

  .overview-row-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .compose-layout,
  .verification-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-column {
    position: static;
    max-width: 36rem;
  }

  .tool-row {
    grid-template-columns: 11rem minmax(0, 1fr);
  }

  .tool-row ul {
    grid-column: 2;
  }
}

@media (max-width: 960px) {
  :root {
    --pad: 1.5rem;
  }

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

  .sidebar {
    position: static;
    min-height: 0;
    padding: 1.5rem 0 0;
  }

  .server-picker {
    max-width: 30rem;
  }

  .main-nav {
    flex-direction: row;
    gap: 1.75rem;
    margin-top: 1.5rem;
    overflow-x: auto;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }

  .main-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item,
  .nav-item.active {
    flex: none;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.5rem 0;
    border-bottom: 0;
    background: none;
    white-space: nowrap;
  }

  .nav-item.active {
    box-shadow: inset 0 -2px 0 var(--text);
  }

  .sidebar-foot {
    display: none;
  }

  .workspace-main {
    padding-top: 2.25rem;
  }

  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .help-section {
    grid-template-columns: minmax(0, 1fr);
  }

  .help-section .soft-note {
    grid-column: auto;
  }
}

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

  .login-brand {
    display: none;
  }

  .login-description {
    font-size: 1rem;
  }

  .tool-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
  }

  .tool-row ul {
    grid-column: auto;
    margin-top: 0.5rem;
  }

  .overview-row {
    grid-template-columns: minmax(0, 1fr);
    padding: 1.75rem 0 2rem;
  }

  .overview-row-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  .overview-row-actions {
    grid-column: auto;
  }

  .giveaway-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .giveaway-actions {
    justify-content: flex-start;
  }

  .help-definition > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  :root {
    --pad: 1.25rem;
  }

  .signed-in-user {
    display: none;
  }

  /* Four tools as a 2 × 2 grid so nothing hides off-screen. */
  .main-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    overflow: visible;
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .nav-item,
  .nav-item.active {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.875rem;
    white-space: normal;
  }

  .nav-item:nth-child(odd) {
    border-right: 1px solid var(--line);
  }

  .nav-item:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .nav-item.active {
    background: var(--surface-2);
    box-shadow: inset 0 -2px 0 var(--brand);
  }

  .page-header {
    padding-bottom: 1.75rem;
  }

  .page-description {
    font-size: 1rem;
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-actions,
  .action-group {
    width: 100%;
  }

  .action-group .button {
    flex: 1 1 auto;
  }

  .empty-state {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .empty-actions {
    grid-column: auto;
    margin-top: 0.5rem;
  }

  .empty-state.inline-empty .feature-icon {
    display: none;
  }

  .preview-embed,
  .preview-join {
    margin-left: 0;
  }

  .preview-embed {
    margin-top: 0.75rem;
  }

  .embed-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-content {
    padding: 1.375rem;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .button {
    width: 100%;
  }

  .confirmation-details > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.125rem;
  }
}

@media (max-width: 440px) {
  :root {
    --pad: 1rem;
  }

  .brand-label {
    display: none;
  }

  .logout-button {
    width: var(--control);
    padding: 0;
  }

  .logout-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .nav-item .icon {
    display: none;
  }

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

  .fact {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    padding: 1rem 0;
  }

  .fact dd {
    margin-top: 0;
    font-size: 1.25rem;
    text-align: right;
  }

  .fact-note {
    text-align: right;
  }

  .bonus-row {
    grid-template-columns: minmax(0, 1fr) 4.5rem var(--control);
  }

  .duration-inputs {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .login-brand img,
  .confirm-dialog[open] {
    animation: none;
  }

  .spinner {
    animation-duration: 1.6s;
  }
}

@media (forced-colors: active) {
  .badge::before,
  .tool-row li::before {
    background: CanvasText;
  }

  .nav-item.active {
    outline: 2px solid Highlight;
  }

  input.switch-input:checked {
    background-color: Highlight;
  }
}
