/* ==========================================================================
   Components — buttons, inputs, fields, cards, badges, tables, code, menus,
   tabs, segmented controls, empty state, skeletons, timeline, toggle.
   ========================================================================== */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.4;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

.btn:disabled,
.btn[aria-disabled="true"],
.btn[data-loading="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--sm { padding: 4px 10px; font-size: 12px; }
.btn--lg { padding: 10px 18px; font-size: 14px; }

.btn--primary {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}
.btn--primary:hover:not(:disabled):not([data-loading="true"]) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #ffffff;
}

.btn--secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn--secondary:hover:not(:disabled):not([data-loading="true"]) {
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn--ghost:hover:not(:disabled):not([data-loading="true"]) {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn--danger {
  background: var(--color-bg);
  color: var(--color-danger);
  border-color: var(--color-border);
}
.btn--danger:hover:not(:disabled):not([data-loading="true"]) {
  background: var(--color-danger);
  color: #ffffff;
  border-color: var(--color-danger);
}

.btn--block { display: flex; width: 100%; }

/* Loading spinner */
.btn[data-loading="true"] .btn__label { visibility: hidden; }
.btn[data-loading="true"]::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
.btn[data-loading="true"] { position: relative; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* --- Inputs --- */
.input,
.textarea,
.select {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.4;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--color-text-subtle);
}

.input:hover:not(:disabled):not(:focus),
.textarea:hover:not(:disabled):not(:focus),
.select:hover:not(:disabled):not(:focus) {
  border-color: var(--color-border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 22%, transparent);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--color-surface);
}

.input--error,
.textarea--error {
  border-color: var(--color-danger);
}
.input--error:focus,
.textarea--error:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 22%, transparent);
}

.input--mono,
.textarea--mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%2371717a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5l3 3 3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* Input with left prefix (e.g. https://) */
.input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
.input-group:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 22%, transparent);
}
.input-group__prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
}
.input-group .input {
  border: none;
  border-radius: 0;
}
.input-group .input:focus {
  box-shadow: none;
}

/* Checkbox + radio (minimal restyle) */
.checkbox,
.radio {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-bg);
  cursor: pointer;
  transition: background-color 150ms ease-out, border-color 150ms ease-out;
  flex-shrink: 0;
}
.checkbox { border-radius: 3px; }
.radio    { border-radius: 50%; }
.checkbox:hover, .radio:hover { border-color: var(--color-accent); }
.checkbox:checked,
.radio:checked {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.checkbox:checked {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6l2.5 2.5L9.5 3.5'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
}
.radio:checked {
  box-shadow: inset 0 0 0 3px var(--color-bg);
}

/* --- Form section layout ---------------------------------------------- */
/* Stacks cards (or field groups) with consistent breathing room. Use on any
   form that groups fields into multiple .card sections (webhook new/edit,
   server new/edit, etc.). */
.form-sections {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Footer row for Save / Cancel at the bottom of a form. 32px separation
   from the last section so actions don't feel glued to content above. */
.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-8);
}

/* Sticky variant — for long forms where the user scrolls past the fold
   pasting multi-line credentials. Opt-in: add .form-footer--sticky on
   the page that wants it (server_new). Doesn't affect other forms. */
.form-footer--sticky {
  position: sticky;
  bottom: 0;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) 0;
  margin-top: var(--space-8);
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}
.form-footer--sticky .form-footer__hint {
  flex: 1;
  min-width: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}
.form-footer--sticky .form-footer__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}
/* Mobile: the sticky footer feels cramped on narrow viewports and
   competes with the on-screen keyboard. Fall back to static. */
@media (max-width: 640px) {
  .form-footer--sticky {
    position: static;
    justify-content: flex-end;
  }
  .form-footer--sticky .form-footer__hint { display: none; }
}

/* Per-section header inside a form — small title + 1-line description
   that explains WHY the section exists. Sits on .card above the fields. */
.form-section__title {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}
.form-section__description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
  line-height: 1.5;
}

/* --- Checkbox grid (grouped togglables) ------------------------------- */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.checkbox-grid--wide {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 12px;
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 100ms ease-out, border-color 100ms ease-out;
}
.checkbox-item:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
}
/* Modern browsers only — :has gives us a "checked" visual state driven by
   the real input, no JS required. Graceful: older browsers see the default
   bordered item and the checkbox itself still toggles. */
.checkbox-item:has(input:checked) {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 6%, transparent);
}
.checkbox-item__label {
  line-height: 1.35;
}

/* Two-line checkbox item — event name on the first line, short description
   on the second. Used on the webhook forms so users can decide which
   events to subscribe to without leaving the form. */
.checkbox-item--with-desc {
  align-items: flex-start;
  padding: 10px 12px;
}
.checkbox-item__stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.checkbox-item__desc {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* --- Field groups --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-5);
}
.field:last-child { margin-bottom: 0; }

.field__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.field__error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  line-height: 1.4;
}

/* Read-only value rendered where an input would be when there's only one
   choice to display (e.g. Add Domain's Server line when the user has a
   single deployed server). Sits at the same baseline as an input but with
   muted body color so it reads as context, not a control. */
.field__static {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Subline variant of .field__hint used to separate an "Examples:" line
   from the primary helper copy above it. Slightly looser top margin so
   the examples feel like a distinct second line, not a wrap of the first. */
.field__hint--examples {
  margin-top: 2px;
}

.field__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.field--horizontal {
  flex-direction: row;
  align-items: flex-start;
  gap: var(--space-6);
}

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.card--flush { padding: 0; }

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.card--flush .card__header {
  padding: var(--space-4) var(--space-5);
  margin-bottom: 0;
  border-bottom: 1px solid var(--color-border);
}

.card__title {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--color-text);
}

.card__description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.5;
}

.card__body {
  /* optional wrapper inside flush cards */
}

.card--flush .card__body {
  padding: var(--space-5);
}

.card__footer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.card__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Stacked cards */
.stack { display: flex; flex-direction: column; gap: var(--space-6); }
.stack--sm { gap: var(--space-3); }
.stack--md { gap: var(--space-4); }
.stack--lg { gap: var(--space-8); }

/* --- Definition list (label/value rows inside cards) --- */
.dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  row-gap: var(--space-3);
  column-gap: var(--space-4);
  font-size: var(--text-sm);
}
.dl > dt {
  color: var(--color-text-muted);
  font-weight: 400;
}
.dl > dd {
  margin: 0;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  word-break: break-word;
}
.dl > dd.dl__value--text {
  font-family: var(--font-sans);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.5;
  white-space: nowrap;
}

.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
  flex-shrink: 0;
}

.badge--success { color: var(--color-success); background: color-mix(in srgb, var(--color-success) 12%, transparent); }
.badge--warning { color: var(--color-warning); background: color-mix(in srgb, var(--color-warning) 14%, transparent); }
.badge--danger  { color: var(--color-danger);  background: color-mix(in srgb, var(--color-danger)  12%, transparent); }
.badge--info    { color: var(--color-accent);  background: color-mix(in srgb, var(--color-accent)  12%, transparent); }
.badge--neutral { color: var(--color-text-muted); background: var(--color-surface-2); }

/* Pre-flight checks use two badge variants that share the warning palette
   in the existing task-row style map but need to read differently at a
   glance: a check that's *actively running* should pulse; a check
   waiting in line should look inert. */
.badge--running { color: var(--color-warning); background: color-mix(in srgb, var(--color-warning) 14%, transparent); }
.badge--running .badge__dot { animation: badge-pulse 1.4s ease-in-out infinite; }
.badge--pending { color: var(--color-text-muted); background: var(--color-surface-2); }
.badge--pending .badge__dot { opacity: 0.5; }
@keyframes badge-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* --- Tables --- */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  /* overflow: visible so row-level overflow menus can escape the wrapper.
     Corner rounding is handled by the first/last cell rules below. */
  overflow: visible;
}

/* Round the outer corners by applying matching radii to the corner cells. */
.table thead tr:first-child th:first-child { border-top-left-radius: calc(var(--radius-md) - 1px); }
.table thead tr:first-child th:last-child  { border-top-right-radius: calc(var(--radius-md) - 1px); }
.table tbody tr:last-child td:first-child  { border-bottom-left-radius: calc(var(--radius-md) - 1px); }
.table tbody tr:last-child td:last-child   { border-bottom-right-radius: calc(var(--radius-md) - 1px); }
/* If there's no thead, the first tbody row is also at the top. */
.table tbody tr:first-child:not(thead + * tr) td:first-child { border-top-left-radius: calc(var(--radius-md) - 1px); }
.table tbody tr:first-child:not(thead + * tr) td:last-child  { border-top-right-radius: calc(var(--radius-md) - 1px); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text);
  background: var(--color-surface);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr { transition: background-color 100ms ease-out; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--color-surface-2) 70%, var(--color-surface)); }

.table--clickable tbody tr { cursor: pointer; }

.table td.table__cell--mono,
.table th.table__cell--mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.table td.table__cell--right,
.table th.table__cell--right { text-align: right; }

.table td.table__cell--shrink { width: 1px; white-space: nowrap; }

.table td.table__cell--actions {
  width: 1px;
  white-space: nowrap;
  text-align: right;
}

/* --- Inline code + code blocks --- */
.code-inline {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.code-block {
  position: relative;
  background: var(--terminal-bg);
  border: 1px solid #1e1e22;
  border-radius: var(--radius-md);
  color: var(--terminal-fg);
  /* No white-space: pre here — that lives on the inner <pre> so stray
     template whitespace around the copy button doesn't render as visible
     leading space inside the block. */
}

.code-block__pre {
  margin: 0;
  padding: var(--space-4);
  /* Leave room on the right for the Copy button (28px button + 10px inset +
     a little breathing room). */
  padding-right: calc(var(--space-10) + 20px);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  color: inherit;
  background: transparent;
  overflow-x: auto;
  white-space: pre;
  text-align: left;
}

.code-block__pre code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  padding: 0;
  border: 0;
  display: block;
  text-align: left;
  white-space: inherit;
}

.code-block--wrap .code-block__pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.code-block__copy {
  position: absolute;
  top: 8px;
  right: 8px;
  /* Sits above the scroll area and doesn't move with horizontal scroll
     because it's a sibling of the <pre>, anchored to the outer box. */
  z-index: 1;
}

/* --- Copy button --- */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 100ms ease-out, color 100ms ease-out, border-color 100ms ease-out;
  white-space: nowrap;
}
.copy-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
}
.copy-btn--on-dark {
  color: var(--terminal-fg);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
.copy-btn--on-dark:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}
.copy-btn--bare {
  border: none;
  padding: 2px 4px;
}

/* --- Menu (overflow dropdown) --- */
.menu-wrap { position: relative; display: inline-block; }

.menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color 100ms ease-out, color 100ms ease-out;
}
.menu-trigger:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.menu-trigger[aria-expanded="true"] {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 180px;
  z-index: 40;
  display: none;
}
.menu[data-open="true"] { display: block; }

.menu__item {
  display: block;
  width: 100%;
  padding: 6px 10px;
  font-size: var(--text-sm);
  color: var(--color-text);
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
}
.menu__item:hover { background: var(--color-surface-2); }

.menu__divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

.menu__item--danger { color: var(--color-danger); }
.menu__item--danger:hover { background: color-mix(in srgb, var(--color-danger) 10%, transparent); }

/* --- Segmented control --- */
.segmented {
  display: inline-flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.segmented__item {
  padding: 5px 12px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 100ms ease-out, color 100ms ease-out;
  white-space: nowrap;
}
.segmented__item:hover {
  color: var(--color-text);
}
.segmented__item--active {
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* --- Empty state --- */
.empty-state {
  padding: var(--space-8) var(--space-6);
  text-align: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.empty-state__title {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.empty-state__description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 460px;
  margin: 0 auto var(--space-5);
  line-height: 1.55;
}

.empty-state__action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

/* Secondary cross-reference link rendered alongside the primary action:
   "[Add your first server]  or see the API reference →". Muted body with
   an accent-colored anchor so it reads as a "by the way" rather than
   competing with the primary CTA. */
.empty-state__secondary {
  font-size: 13px;
  color: var(--color-text-muted);
}
.empty-state__secondary a {
  color: var(--color-accent);
  text-decoration: none;
}
.empty-state__secondary a:hover {
  text-decoration: underline;
}

/* --- Skeleton loaders --- */
.skeleton {
  display: inline-block;
  background: linear-gradient(
    90deg,
    var(--color-surface-2) 0%,
    var(--color-border) 50%,
    var(--color-surface-2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 3px;
  height: 12px;
  width: 100%;
}
.skeleton--lg { height: 20px; }
.skeleton--circle { border-radius: 50%; width: 28px; height: 28px; }

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }

.spinner-center {
  padding: var(--space-10) 0;
  display: flex;
  justify-content: center;
}

/* --- Timeline (for events on email detail, deployment history) --- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: relative;
}
.timeline__item {
  position: relative;
  padding-left: var(--space-6);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: var(--space-3);
  font-size: var(--text-sm);
}
.timeline__item::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 18px;
  bottom: calc(-1 * var(--space-4) - 6px);
  width: 1px;
  background: var(--color-border);
}
.timeline__item:last-child::before { display: none; }
.timeline__dot {
  position: absolute;
  left: 3px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-text-muted);
  border: 2px solid var(--color-bg);
  box-shadow: 0 0 0 1px var(--color-border-strong);
}
.timeline__dot--success { background: var(--color-success); box-shadow: 0 0 0 1px var(--color-success); }
.timeline__dot--warning { background: var(--color-warning); box-shadow: 0 0 0 1px var(--color-warning); }
.timeline__dot--danger  { background: var(--color-danger);  box-shadow: 0 0 0 1px var(--color-danger); }
.timeline__time {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.timeline__label {
  font-weight: 500;
  color: var(--color-text);
}
.timeline__detail {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: 2px;
  line-height: 1.5;
}

/* --- Toggle switch --- */
.toggle {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle__slider {
  position: absolute;
  inset: 0;
  background: var(--color-border-strong);
  border-radius: 10px;
  transition: background-color 150ms ease-out;
  cursor: pointer;
}
.toggle__slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 150ms ease-out;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.toggle input:checked + .toggle__slider {
  background: var(--color-accent);
}
.toggle input:checked + .toggle__slider::before {
  transform: translateX(14px);
}
.toggle input:focus-visible + .toggle__slider {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 28%, transparent);
}

/* Inbound diagnostics panel inside the Inbound mail card on the domain
   detail page. Default-collapsed <details>; opens to a controls row +
   list of result rows. Receiving-debug is the canonical use; the panel
   is generic enough to host other diagnostic categories later. */
.diagnostics-panel {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.diagnostics-panel__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--color-text);
}
/* Hide the default arrow on Webkit + Firefox — we render our own SVG. */
.diagnostics-panel__summary::-webkit-details-marker { display: none; }
.diagnostics-panel__summary { list-style: none; }
.diagnostics-panel__summary:hover { color: var(--color-accent); }
.diagnostics-panel__summary-label { display: flex; align-items: baseline; gap: 6px; }
.diagnostics-panel__chevron {
  color: var(--color-text-muted);
  display: inline-flex;
  transition: transform 150ms ease-out;
}
.diagnostics-panel[open] .diagnostics-panel__chevron {
  transform: rotate(180deg);
}
.diagnostics-panel__body {
  margin-top: var(--space-4);
}
.diagnostics-panel__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

/* One result row. Icon column (16px) + body (label + detail) + optional
   fix button on the right. Color/bg keyed by --pass / --fail / --skip. */
.diagnostic-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  font-size: var(--text-sm);
}
.diagnostic-row--pass { border-left-color: var(--color-success); }
.diagnostic-row--fail { border-left-color: var(--color-danger); background: color-mix(in srgb, var(--color-danger) 4%, transparent); }
.diagnostic-row--skip { border-left-color: var(--color-text-subtle); }
.diagnostic-row__icon {
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}
.diagnostic-row--pass .diagnostic-row__icon { color: var(--color-success); }
.diagnostic-row--fail .diagnostic-row__icon { color: var(--color-danger); }
.diagnostic-row--skip .diagnostic-row__icon { color: var(--color-text-subtle); }
.diagnostic-row__body { min-width: 0; }
.diagnostic-row__label {
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.4;
}
.diagnostic-row__detail {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: 2px;
  word-break: break-word;
}
.diagnostic-row__fix {
  margin: 0;
  align-self: center;
  flex-shrink: 0;
}

/* One-shot webhook/API-key secret reveal — amber warning + focal code block.
   Scoped because the generic .banner banner--warning is used app-wide for
   lighter advisory cases; the reveal page needs a visually distinct "save
   now or lose it" treatment. Tight, self-contained rules — all three
   elements share the same amber accent token. */
.secret-warning {
  background: color-mix(in srgb, var(--color-warning) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-warning) 30%, transparent);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
.secret-warning__icon {
  color: var(--color-warning);
  display: inline-flex;
  margin-top: 2px;
  flex-shrink: 0;
}
.secret-warning__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.secret-warning__body {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Webhook detail Health card — focal status + 3-column signals grid.
   The status badge uses a slightly larger variant (.badge--lg) so it
   reads as the page's anchor; signals stack into one column on mobile. */
.health-card__status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.health-card__subtext {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.health-card__signals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
@media (max-width: 640px) {
  .health-card__signals { grid-template-columns: 1fr; }
}
.health-card__signal-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.health-card__signal-value {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}
.health-card__signal-value a {
  color: inherit;
  text-decoration: none;
}
.health-card__signal-value a:hover {
  color: var(--color-accent);
}
.health-card__signal-value--warning { color: var(--color-warning); }
.health-card__signal-value--danger  { color: var(--color-danger); }

/* Slightly weightier badge for "this is the focal element of the card".
   Reused by the webhook detail Health card; safe to apply anywhere a
   regular .badge needs to dominate visually. */
.badge--lg {
  font-size: 13px;
  padding: 6px 12px;
  letter-spacing: 0.05em;
}

/* Whole-card collapsible primitive. Header is a button; body wraps in
   the same hidden+max-height transition the API endpoint cards use,
   so collapsed state is instant on first paint and animates on toggle. */
.card--collapsible {
  overflow: hidden;
}
.card--collapsible > .card__header {
  cursor: pointer;
  user-select: none;
}
.card--collapsible > .card__header:hover {
  background: var(--color-surface-2);
}
.card--collapsible__chevron {
  margin-left: auto;
  color: var(--color-text-muted);
  display: inline-flex;
  transition: transform 150ms ease-out;
}
.card--collapsible[data-expanded="true"] .card--collapsible__chevron {
  transform: rotate(180deg);
}
.card--collapsible__body {
  padding: 0 var(--space-5) var(--space-5);
  max-height: 1500px;
  opacity: 1;
  transition: max-height 200ms ease-out, opacity 150ms ease-out;
}
.card--collapsible[data-expanded="false"] .card--collapsible__body:not([hidden]) {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

/* Secret focal block: the label renders as uppercase-muted metadata above
   the code-block, and the identifier prefix sits below as read-only
   context. Pulls the reader's eye down the page from heading → code → id. */
.secret-card {
  margin-bottom: var(--space-8);
}
.secret-card__label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.secret-card__prefix {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}
.secret-card__prefix code {
  color: var(--color-text);
}

/* --- Banner / callout --- */
.banner {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.banner--info {
  border-color: color-mix(in srgb, var(--color-accent) 30%, var(--color-border));
  background: color-mix(in srgb, var(--color-accent) 5%, var(--color-surface));
}
.banner--warning {
  border-color: color-mix(in srgb, var(--color-warning) 35%, var(--color-border));
  background: color-mix(in srgb, var(--color-warning) 6%, var(--color-surface));
  color: var(--color-text);
}
.banner--danger {
  border-color: color-mix(in srgb, var(--color-danger) 35%, var(--color-border));
  background: color-mix(in srgb, var(--color-danger) 6%, var(--color-surface));
  color: var(--color-text);
}
.banner__title { color: var(--color-text); font-weight: 500; margin-bottom: 2px; }

/* --- Status row (compact) --- */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.status-row__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.status-row__right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  flex-wrap: wrap;
}

/* --- Divider --- */
.divider { height: 1px; background: var(--color-border); width: 100%; }
.divider--v { width: 1px; height: 100%; background: var(--color-border); }

/* --- Link button (inline link that looks like a control) --- */
.link {
  color: var(--color-accent);
  font-size: var(--text-sm);
  text-decoration: none;
  font-weight: 500;
}
.link:hover { text-decoration: underline; color: var(--color-accent-hover); }

.link--muted { color: var(--color-text-muted); }
.link--muted:hover { color: var(--color-text); text-decoration: underline; }

/* --- Inline helper (status dot + text) --- */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-subtle);
  flex-shrink: 0;
}
.dot--success { background: var(--color-success); }
.dot--warning { background: var(--color-warning); }
.dot--danger  { background: var(--color-danger); }
.dot--info    { background: var(--color-accent); }
.dot--neutral { background: var(--color-text-subtle); }

/* --- Key/value inline (label: value) --- */
.kv {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--text-sm);
}
.kv__label { color: var(--color-text-muted); }
.kv__value { color: var(--color-text); font-family: var(--font-mono); }
/* Compact label-less kv for subtitle rows — the value speaks for itself
   when it's obviously a hostname or IP. Visually tight; the per-value
   Copy button still reads the content. */
.kv--mono { gap: 4px; }
.kv--mono .kv__value {
  background: var(--color-surface-2);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* --- Collapsible section --- */
.collapsible {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}
.collapsible__trigger {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background-color 100ms ease-out;
}
.collapsible__trigger:hover { background: var(--color-surface-2); }
.collapsible__trigger[aria-expanded="true"] {
  border-bottom: 1px solid var(--color-border);
}
.collapsible__chevron {
  transition: transform 150ms ease-out;
  color: var(--color-text-muted);
}
.collapsible__trigger[aria-expanded="true"] .collapsible__chevron {
  transform: rotate(180deg);
}
.collapsible__body {
  padding: var(--space-5);
  display: none;
}
.collapsible[data-open="true"] .collapsible__body { display: block; }

/* --- Expandable row (inside tables) --- */
.expand-row {
  cursor: pointer;
}
.expand-row__panel {
  background: var(--color-surface-2);
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* --- Filter bar --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  align-items: center;
}
.filters .input,
.filters .select { width: auto; min-width: 180px; }
.filters__search { flex: 1; min-width: 240px; max-width: 360px; }

/* --- Icon helpers --- */
.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.icon--sm { width: 12px; height: 12px; }
.icon--lg { width: 20px; height: 20px; }

/* --- Auth shell --- */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  background: var(--color-bg);
}

.auth__container {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
}

.auth__brand {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.auth__card {
  width: 100%;
  padding: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.auth__title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}

.auth__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
  line-height: 1.5;
}

.auth__footer {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}
.auth__footer a {
  color: var(--color-accent);
  font-weight: 500;
}

.auth__divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-5) 0;
  color: var(--color-text-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth__divider::before,
.auth__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.auth__oauth {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.auth__error {
  padding: 10px 12px;
  margin-bottom: var(--space-4);
  border: 1px solid color-mix(in srgb, var(--color-danger) 40%, var(--color-border));
  background: color-mix(in srgb, var(--color-danger) 8%, var(--color-surface));
  color: var(--color-danger);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.auth__forgot {
  font-size: var(--text-xs);
  color: var(--color-accent);
  font-weight: 500;
}
.auth__forgot:hover { text-decoration: underline; }

/* --- Pre-flight checks page ----------------------------------------- */
/* Two-line status banner shared by pre-flight + deploy pages. Base is
   neutral (in-progress / queued); `data-variant` swaps color for terminal
   states. Pages pick the variant that matches their status: pre-flight
   uses `warning` for a failed run (amber, re-run expected); deploy uses
   `danger` for a failed deploy (red, action required). */
.status-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  transition: background-color 200ms ease-out, border-color 200ms ease-out;
}
.status-banner__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.status-banner__title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text);
}
.status-banner__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.status-banner__counter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-muted);
  margin-left: var(--space-2);
}

.status-banner[data-variant="success"] {
  border-color: color-mix(in srgb, var(--color-success) 30%, var(--color-border));
  background: color-mix(in srgb, var(--color-success) 5%, var(--color-surface));
}
.status-banner[data-variant="warning"] {
  border-color: color-mix(in srgb, var(--color-warning) 35%, var(--color-border));
  background: color-mix(in srgb, var(--color-warning) 6%, var(--color-surface));
}
.status-banner[data-variant="danger"] {
  border-color: color-mix(in srgb, var(--color-danger) 35%, var(--color-border));
  background: color-mix(in srgb, var(--color-danger) 6%, var(--color-surface));
}

/* Action row shown under the checks — Re-run / Edit server / Cancel.
   Hidden while checks are running; revealed when overall status is
   failed (or passed_with_warnings, for re-check). */
.preflight-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-6);
  align-items: center;
  flex-wrap: wrap;
}
.preflight-actions__spacer { flex: 1; }

/* Structured remediation content inside an expanded failed-check row.
   Sits above the raw terminal log in the task body. */
.remediation {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  border-left: 3px solid var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 5%, var(--color-surface));
  border-radius: 3px;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-text);
}
.remediation__explanation {
  margin: 0 0 var(--space-2);
  color: var(--color-text);
}
.remediation__fix-heading {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: var(--space-3) 0 var(--space-1);
}
.remediation__fix-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.remediation__fix-list li {
  position: relative;
  padding-left: var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.remediation__fix-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--color-warning);
}

/* --- Task list rows (shared by pre-flight checks, deploy phases, DNS rows, TLS row) --- */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.task-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  overflow: hidden;
  transition: border-color 150ms ease-out;
}
.task-row:hover { border-color: var(--color-border-strong); }

.task-head {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: var(--space-3);
  align-items: center;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--text-sm);
}
.task-head:hover { background: var(--color-surface-2); }

.task-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: transform 150ms ease-out;
}
.task-head[aria-expanded="true"] .task-chevron { transform: rotate(180deg); }

.task-text { min-width: 0; }
.task-label {
  font-weight: 500;
  color: var(--color-text);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.task-label .dns-type {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
}
.task-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.5;
}

.task-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.task-status__indicator {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

/* Status colour mapping driven by data-task-status on .task-row. */
.task-row[data-task-status="verified"] .task-status,
.task-row[data-task-status="passed"] .task-status,
.task-row[data-task-status="delivered"] .task-status,
.task-row[data-task-status="completed"] .task-status,
.task-row[data-task-status="success"] .task-status {
  color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 12%, transparent);
}
.task-row[data-task-status="running"] .task-status,
.task-row[data-task-status="provisioning"] .task-status,
.task-row[data-task-status="mismatch"] .task-status,
.task-row[data-task-status="warning"] .task-status {
  color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 14%, transparent);
}
/* Distinguish actively-running from queued-waiting: running checks pulse
   so the current bottleneck is obvious at a glance; pending checks sit in
   a neutral inert style. */
.task-row[data-task-status="running"] .task-status__indicator {
  animation: badge-pulse 1.4s ease-in-out infinite;
}
.task-row[data-task-status="pending"] .task-status,
.task-row[data-task-status="not-set"] .task-status {
  color: var(--color-text-muted);
  background: var(--color-surface-2);
}
.task-row[data-task-status="pending"] .task-status__indicator,
.task-row[data-task-status="not-set"] .task-status__indicator { opacity: 0.5; }

.task-row[data-task-status="failed"] .task-status,
.task-row[data-task-status="error"] .task-status {
  color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 12%, transparent);
}
.task-row[data-task-status="skipped"] .task-status {
  color: var(--color-text-subtle);
}

.task-body {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}
.task-body:not([hidden]) { display: block; }

.task-body-log {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--terminal-fg);
  background: var(--terminal-bg);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  max-height: 340px;
}

/* DNS row specifics — the row has an external Verify button sitting alongside the expand head */
.dns-row-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
}
.dns-row-header .task-head { border-right: 1px solid var(--color-border); }
.dns-row-verify {
  margin: var(--space-2);
  align-self: center;
}

.dns-fields {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: var(--space-3) var(--space-4);
  margin: var(--space-3) 0;
  font-size: var(--text-sm);
}
.dns-fields dt { color: var(--color-text-muted); font-weight: 400; }
.dns-fields dd { margin: 0; display: flex; gap: var(--space-2); align-items: center; min-width: 0; }
.dns-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface-2);
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px solid var(--color-border);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
.dns-value-wrap { white-space: pre-wrap; }
.dns-purpose { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.5; margin: 0; }
.dns-helper { font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.55; margin-top: var(--space-3); }

/* --- Dashboard metric cards ------------------------------------------- */
.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-height: 92px;
}

.metric__label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.metric__value {
  font-size: 24px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--color-text);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-top: 2px;
}

.metric__sublabel {
  font-size: 11px;
  color: var(--color-text-subtle);
  line-height: 1.4;
  margin-top: auto;
  padding-top: var(--space-2);
}

.metric--highlight .metric__value { color: var(--color-accent); }

.metric-row {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: var(--space-6);
}

.metric__value-skeleton {
  display: inline-block;
  height: 30px;
  width: 60%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--color-surface-2) 0%, var(--color-border) 50%, var(--color-surface-2) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

/* --- Dashboard section header ---------------------------------------- */
.dashboard-section {
  margin-bottom: var(--space-10);
}
.dashboard-section:last-child { margin-bottom: 0; }

.dashboard-section__header {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

/* --- Chart card + container ------------------------------------------- */
.chart-card {
  margin-bottom: var(--space-6);
}
.chart-card .card__header {
  margin-bottom: var(--space-3);
}

.chart-container {
  height: 260px;
  position: relative;
}

.chart-skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--color-surface-2) 0%, var(--color-border) 50%, var(--color-surface-2) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

/* Custom chart legend — sits in the chart card's header. Click to toggle
   the corresponding series; hidden items dim. Chart.js's built-in legend
   is disabled in dashboard_chart.js to avoid the double-render. */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
}
.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  transition: color 100ms ease-out, opacity 100ms ease-out;
}
.chart-legend__item:hover { color: var(--color-text); }
.chart-legend__item--hidden { opacity: 0.4; }
.chart-legend__item--hidden .chart-legend__dot { opacity: 0.4; }
.chart-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- "Prefer REST API?" footer on the SMTP credentials card --------- */
.smtp-alt-link {
  display: inline-block;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-accent);
  text-decoration: none;
}
.smtp-alt-link:hover { text-decoration: underline; }

/* --- Inline reset-link confirmation on Settings --------------------- */
.settings-reset-confirm {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--color-success) 6%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-success) 30%, var(--color-border));
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.settings-reset-confirm__title {
  font-weight: 500;
  color: var(--color-text);
}
.settings-reset-confirm__body {
  color: var(--color-text-muted);
}

/* --- Empty-state inline row (e.g. "No webhooks configured") ---------- */
.attn-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.attn-empty .dot { background: var(--color-success); }

/* --- Dashboard filter bar -------------------------------------------- */
.dashboard-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}
/* Scoped auto-width override — the global .select rule sets width: 100%,
   which would make each dropdown stretch the full flex line and wrap to
   its own row. We want three inline dropdowns instead. */
.dashboard-filters .select {
  width: auto;
  min-width: 180px;
}
.dashboard-filters__refresh {
  margin-left: auto;
}

/* Welcome empty state for the dashboard (zero servers) -------------- */
/* Two stacked cards: primary CTA + prerequisites, then a "what happens
   next" preview. Spans the full layout container so the cards line up
   with every other empty state in the app (/servers, /domains, etc.). */
.empty-state-welcome {
  padding: var(--space-2) 0;
}

.empty-state-welcome__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  margin-bottom: var(--space-4);
}

.empty-state-welcome__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  letter-spacing: -0.01em;
}

.empty-state-welcome__description {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.55;
  margin-bottom: var(--space-5);
}
.empty-state-welcome__description p { margin: 0; }
.empty-state-welcome__description p + p { margin-top: var(--space-2); }

.empty-state-welcome__prereq-heading {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.empty-state-welcome__prereq-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.empty-state-welcome__prereq-item {
  font-size: var(--text-sm);
  color: var(--color-text);
  padding-left: var(--space-4);
  position: relative;
  line-height: 1.5;
}
.empty-state-welcome__prereq-item::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--color-text-subtle);
}

.empty-state-welcome__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.empty-state-welcome__secondary-link {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
}
.empty-state-welcome__secondary-link strong {
  color: var(--color-accent);
  font-weight: 500;
}
.empty-state-welcome__secondary-link:hover strong { text-decoration: underline; }

/* "What happens next" steps card ------------------------------------ */
.welcome-steps {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.welcome-steps__title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.welcome-steps__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.welcome-steps__item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: var(--space-3);
  align-items: start;
}

.welcome-steps__number {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  line-height: 1.4;
  padding-top: 1px;
}

.welcome-steps__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.4;
}

.welcome-steps__description {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.welcome-steps__footer {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  text-align: center;
}

/* --- SMTP panel (data-state driven) ---------------------------------- */
.smtp-panel-body[data-state="loading"] .smtp-loading { display: block; }
.smtp-panel-body[data-state="loading"] .smtp-kv,
.smtp-panel-body[data-state="loading"] .smtp-not-configured,
.smtp-panel-body[data-state="loading"] .smtp-error { display: none !important; }

.smtp-panel-body[data-state="configured"] .smtp-loading,
.smtp-panel-body[data-state="configured"] .smtp-not-configured,
.smtp-panel-body[data-state="configured"] .smtp-error { display: none !important; }
.smtp-panel-body[data-state="configured"] .smtp-kv { display: grid !important; }

.smtp-panel-body[data-state="not_configured"] .smtp-loading,
.smtp-panel-body[data-state="not_configured"] .smtp-kv,
.smtp-panel-body[data-state="not_configured"] .smtp-error { display: none !important; }
.smtp-panel-body[data-state="not_configured"] .smtp-not-configured { display: block !important; }

.smtp-panel-body[data-state="error"] .smtp-loading,
.smtp-panel-body[data-state="error"] .smtp-kv,
.smtp-panel-body[data-state="error"] .smtp-not-configured { display: none !important; }
.smtp-panel-body[data-state="error"] .smtp-error { display: block !important; }

.smtp-password-value {
  letter-spacing: 0.06em;
  user-select: all;
}

/* Deployment page action visibility — actions live in the next-steps card
   on success (always-visible inside the card), so we only gate retry/back
   on failure here. */
.deploy-retry,
.deploy-back { display: none; }
.deployment-view[data-deployment-status="failed"] .deploy-retry,
.deployment-view[data-deployment-status="deploy_failed"] .deploy-retry { display: inline-flex; }
.deployment-view[data-deployment-status="failed"] .deploy-back,
.deployment-view[data-deployment-status="deploy_failed"] .deploy-back { display: inline-flex; }

/* Fresh-deploy banner + its inline CTA. The .status-banner macro is
   purely informational; the button lives alongside it (outside the
   macro) so the banner stays a reusable primitive. Mobile wraps the
   button under the banner. */
.status-banner-row {
  display: flex;
  align-items: stretch;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.status-banner-row > .status-banner {
  flex: 1;
  margin-bottom: 0;
}
.status-banner-row__cta {
  align-self: center;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .status-banner-row { flex-direction: column; align-items: flex-start; }
  .status-banner-row__cta { align-self: stretch; justify-content: center; }
}

/* "N items need attention" line. Sits under the status row when there
   are deliverability or config issues; empty otherwise. Amber left
   border matches the remediation treatment on pre-flight/deploy rows. */
.attention-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 5%, var(--color-surface));
  border-radius: 3px;
  font-size: var(--text-sm);
}
.attention-row__indicator { color: var(--color-warning); }
.attention-row__link { color: var(--color-text); text-decoration: underline; text-underline-offset: 3px; }
.attention-row__link:hover { color: var(--color-accent); }
.attention-row__first { color: var(--color-text-muted); }

/* TLS card — rendered inside a standard .card on the server detail page.
   Header shows hostname (left) + status badge (right) on one row; body
   has explanation + optional primary action. */
.tls-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.tls-card__hostname {
  font-size: var(--text-sm);
  color: var(--color-text);
}
.tls-card__status { margin: 0; }
.tls-card__error {
  margin: var(--space-3) 0 0;
  max-height: 180px;
  overflow: auto;
}
.tls-card__error-details {
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
}
.tls-card__error-details summary {
  cursor: pointer;
  user-select: none;
}
.tls-card__error-details summary:hover { color: var(--color-text); }
.tls-card__dep-link {
  margin-top: var(--space-3);
  margin-right: var(--space-3);
}
.tls-card__actions { margin: var(--space-4) 0 0; }
/* Disabled primary/secondary buttons in this card stay visible but
   un-interactable; the adjacent Set-A-record link is the real CTA. */
.tls-card__actions .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.next-steps-card { display: none; margin-top: var(--space-6); }
.deployment-view[data-deployment-status="deployed"] .next-steps-card,
.deployment-view[data-deployment-status="success"] .next-steps-card { display: block; }

/* Three-step preview card. Mirrors the dashboard welcome steps visually
   so the deploy-success "what happens next" feels familiar. */
.next-steps-card__heading {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-3);
}
.next-steps-card__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.next-steps-card__item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: var(--space-3);
  align-items: start;
}
.next-steps-card__number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.next-steps-card__title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}
.next-steps-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.next-steps-card__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

/* --- API reference page (/api-reference) ------------------------------
   Two-column layout: main content (endpoints + narrative) + sticky right
   TOC. TOC collapses on tablet/mobile so the main column gets the width.
   Search lives at the top of the main column. */
.api-reference {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: var(--space-8);
  align-items: start;
}
.api-reference__main {
  min-width: 0;
}
.api-reference__toc {
  position: sticky;
  top: var(--space-6);
  max-height: calc(100vh - var(--space-12));
  overflow-y: auto;
  padding-right: var(--space-2);
}
@media (max-width: 1024px) {
  .api-reference {
    grid-template-columns: 1fr;
  }
  .api-reference__toc {
    display: none;
  }
}

.api-search-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.api-search__input {
  flex: 1;
}
.api-search-row__toggles {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
/* Small text-link toggles (Expand all / Collapse all). Unobtrusive per
   spec — just available, not promoted. */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--color-accent);
  cursor: pointer;
}
.link-btn:hover {
  text-decoration: underline;
}

/* Collapsible endpoint card — applied on /api-reference.
   Card is a standalone bordered container; header is a full-width
   button; body slides open via max-height transition. Non-collapsible
   endpoints (no current consumer; see api_endpoint.html docstring) omit
   .api-endpoint--collapsible and render with their inline paragraph
   layout instead. */
.api-endpoint--collapsible {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
  margin-bottom: var(--space-3);
}
/* Collapsed endpoint header uses CSS grid so the description aligns to
   the same left edge on every card. Top row: title (method + path) +
   chevron. Bottom row: purpose. Chevron spans both rows and centers
   vertically so it feels anchored to the card, not to either line. */
.api-endpoint__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title   chevron"
    "purpose chevron";
  gap: 4px var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
  color: inherit;
}
.api-endpoint__header:hover {
  background: var(--color-surface-2);
}
.api-endpoint__header:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.api-endpoint__title {
  grid-area: title;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.api-endpoint--collapsible .api-endpoint__method {
  flex-shrink: 0;
}
.api-endpoint--collapsible .api-endpoint__path {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Scoped to collapsible cards so the non-collapsible layout's
   `<p class="api-endpoint__purpose">` paragraph styling stays intact.
   That non-collapsible layout has no current consumer but is kept
   available for future contextual panels. */
.api-endpoint--collapsible .api-endpoint__purpose {
  grid-area: purpose;
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin: 0;
}
.api-endpoint__chevron {
  grid-area: chevron;
  align-self: center;
  color: var(--color-text-muted);
  display: inline-flex;
  transition: transform 150ms ease-out;
}
.api-endpoint--collapsible[data-expanded="true"] .api-endpoint__chevron {
  transform: rotate(180deg);
}
.api-endpoint__body {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4);
  /* Smooth open/close without measuring heights in JS. 1000px covers
     every realistic sample size (our longest response body is under
     600px rendered). Hidden attr (default-collapsed) forces display:none
     which bypasses the transition on first paint — the page loads
     instantly collapsed, transition applies on subsequent toggles. */
  max-height: 1000px;
  opacity: 1;
  transition: max-height 180ms ease-out, opacity 150ms ease-out;
}
.api-endpoint--collapsible[data-expanded="false"] .api-endpoint__body:not([hidden]) {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}
/* Reset the per-card tabs/code margins so the body feels tight inside
   the card (no double-padding from the outer card + inner tabs). */
.api-endpoint__body > .api-endpoint__tabs {
  margin-top: 0;
}

/* Very narrow viewports: let long paths scroll horizontally inside the
   title cell rather than wrapping awkwardly across the method pill. The
   grid layout itself handles small screens without change — purpose is
   already on its own row. */
@media (max-width: 480px) {
  .api-endpoint--collapsible .api-endpoint__path {
    font-size: 12px;
    overflow-x: auto;
  }
}

.api-ref-section {
  margin-bottom: var(--space-10);
  scroll-margin-top: var(--space-6);
}
.api-ref-section:last-child {
  margin-bottom: 0;
}
.api-ref-section__title {
  font-size: 20px;
  font-weight: 500;
  color: var(--color-text);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.api-ref-section > p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
  margin: 0 0 var(--space-4);
}
.api-ref-section .api-endpoint {
  margin-bottom: var(--space-4);
  scroll-margin-top: var(--space-6);
}
.api-ref-errors-table {
  margin-bottom: var(--space-4);
}

/* Flat TOC — one entry per top-level section. Sticky position comes
   from .api-reference__toc; this styles only the links themselves. */
.toc {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.toc__item {
  display: block;
  padding: 6px 0 6px 12px;
  color: var(--color-text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.4;
  transition: color 100ms ease-out, border-color 100ms ease-out;
}
.toc__item:hover {
  color: var(--color-text);
}
.toc__item--active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
}

/* --- API section (unified reference panel) --- */
/* API section acts as a dashboard-level section — match header styling so
   "API" reads like a peer of "INFRASTRUCTURE", "EMAIL ACTIVITY", etc.
   The wrapper uses the .collapsible primitive, so we override its
   trigger styling rather than build a new control. */
.api-section {
  margin-top: var(--space-10);
  border: none;
  background: transparent;
  border-radius: 0;
  overflow: visible;
}
.api-section .collapsible__trigger {
  padding: 0 0 var(--space-2) 0;
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.api-section .collapsible__trigger:hover {
  background: transparent;
  color: var(--color-text);
}
.api-section .collapsible__trigger[aria-expanded="true"] {
  border-bottom: 1px solid var(--color-border);
}
.api-section .collapsible__body {
  padding: 0;
}

.api-endpoint {
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.api-endpoint:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.api-endpoint__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 6px;
}

.api-endpoint__method {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  background: var(--color-surface-2);
  color: var(--color-text);
}
.api-endpoint__method--get    { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.api-endpoint__method--post   { color: var(--color-success); background: color-mix(in srgb, var(--color-success) 10%, transparent); }
.api-endpoint__method--patch  { color: var(--color-warning); background: color-mix(in srgb, var(--color-warning) 12%, transparent); }
.api-endpoint__method--put    { color: var(--color-warning); background: color-mix(in srgb, var(--color-warning) 12%, transparent); }
.api-endpoint__method--delete { color: var(--color-danger);  background: color-mix(in srgb, var(--color-danger) 10%, transparent); }

.api-endpoint__path {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.api-endpoint__purpose {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

/* Request/Response tabs — sit flush against the top of the code block. The
   active tab's dark fill merges with the terminal-bg of the block below
   via a -1px bottom margin that overlaps the block's top border. The
   sibling code-block's top-left radius is zeroed (see rule further down)
   so the corner meets the tab's sharp bottom-left cleanly instead of
   showing the curved edge as a seam. */
.api-endpoint__tabs {
  display: flex;
  gap: 2px;
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
}

.api-endpoint__tab {
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  /* No color/background transition: a 100ms interpolation against a dark
     active fill flickers through gray on the way to white. Instant swap
     reads sharper for this state change. */
}
/* Scope hover to inactive tabs only — `:hover` has higher specificity than
   `.api-endpoint__tab--active`, so an unscoped rule would paint the active
   tab's text near-black in light mode, unreadable on the dark fill. */
.api-endpoint__tab:not(.api-endpoint__tab--active):hover {
  color: var(--color-text);
}
/* Keyboard focus ring stays inside the tab — a box-shadow ring would
   extend past the bottom edge and bleed across the tab/block boundary. */
.api-endpoint__tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  box-shadow: none;
}

.api-endpoint__tab--active {
  color: #fafafa;
  background: var(--terminal-bg);
  border-color: #1e1e22;
}

.api-endpoint__tab-status {
  color: var(--color-text-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  margin-left: 4px;
}
.api-endpoint__tab--active .api-endpoint__tab-status {
  color: #a1a1aa;
}

/* Code block directly beneath tabs — zero the top-left radius so the
   block's rounded corner doesn't show as a seam behind the leftmost
   (sharp-cornered) tab. Top-right stays rounded because no tab extends
   there. */
.api-endpoint__tabs + .code-block {
  margin-top: 0;
  border-top-left-radius: 0;
}

/* Empty response-body placeholder — keeps the visual rhythm without a real
   terminal block. */
.code-block--empty {
  background: transparent;
  border: 1px dashed var(--color-border);
  color: var(--color-text-subtle);
}
.code-block--empty .code-block__pre {
  padding: var(--space-2) var(--space-4);
  color: var(--color-text-subtle);
  font-style: italic;
}
