/*
 * DomainScope — design system
 *
 * 1. Tokens (light) + dark overrides (system preference unless data-theme="light",
 *    and forced with data-theme="dark"); the dark palette is screen-only, so paper always
 *    gets the light one (dark text, see 5. print)
 * 2. Base / reset
 * 3. App shell: header, sidebar nav (horizontal on phones), main, page header, footer
 * 4. Components (match assets/js/ui/components.js): buttons, fields, checks, segmented,
 *    badges, severity, alerts, cards, sections, stats, key-value, code, lists, tabs,
 *    progress, spinner, toast, modal, file drop, empty state, data table
 * 5. Utilities, reduced motion, print
 *
 * Per-view styles live in assets/css/views/<view>.css and use a view prefix (.inv-, .about-, …).
 * No inline styles anywhere (CSP style-src 'self'); JS only sets CSSOM properties.
 */

/* ------------------------------------------------------------------------ */
/* 1. Tokens                                                                */
/* ------------------------------------------------------------------------ */

:root {
  color-scheme: light;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans",
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --bg: #f4f5f7;
  --bg-sidebar: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef2;
  --surface-hover: #f2f4f7;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #14171c;
  --text-2: #464d5b;
  --text-3: #687080;
  --on-accent: #ffffff;

  --accent: #2563eb;
  --accent-hover: #1d4fd7;
  --accent-solid: #2563eb;
  --accent-soft: #edf3ff;
  --accent-soft-border: #cadbfd;
  --accent-text: #1d4ed8;
  --focus: #2563eb;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.25);
  --selection: rgba(37, 99, 235, 0.18);

  --ok: #157a3d;
  --ok-solid: #16a34a;
  --ok-bg: #ebf7ef;
  --ok-border: #bfe4cb;
  --info: #1d4ed8;
  --info-solid: #2563eb;
  --info-bg: #edf3ff;
  --info-border: #cadbfd;
  --warn: #975a06;
  --warn-solid: #d97706;
  --warn-bg: #fdf5e6;
  --warn-border: #f1d9a8;
  --error: #b9232a;
  --error-solid: #dc2626;
  --error-bg: #fdeeee;
  --error-border: #f4c4c6;

  /* Classification kinds (always paired with an icon + text label) */
  --k-cloudflare: #b4500a;
  --k-cloudflare-solid: #f38020;
  --k-cloudflare-bg: #fff2e7;
  --k-cloudflare-border: #fbcfa6;
  --k-cdn: #6135c4;
  --k-cdn-solid: #7c4dea;
  --k-cdn-bg: #f4f0ff;
  --k-cdn-border: #dacdfb;
  --k-platform: #0b6e62;
  --k-platform-solid: #0f9f8c;
  --k-platform-bg: #e6f6f3;
  --k-platform-border: #b2e1d9;
  --k-direct: #09648a;
  --k-direct-solid: #0891b2;
  --k-direct-bg: #e5f4fa;
  --k-direct-border: #b2dced;
  --k-private: #475163;
  --k-private-solid: #64748b;
  --k-private-bg: #eff1f4;
  --k-private-border: #d4d9e1;
  --k-unresolved: #5f6776;
  --k-unresolved-solid: #94a3b8;
  --k-unresolved-bg: #f6f7f9;
  --k-unresolved-border: #c3c9d3;
  --k-nxdomain: #9a1b3b;
  --k-nxdomain-solid: #e11d48;
  --k-nxdomain-bg: #fdeef2;
  --k-nxdomain-border: #f4c4d1;
  --k-dangling: #b02a14;
  --k-dangling-solid: #ea580c;
  --k-dangling-bg: #fff0eb;
  --k-dangling-border: #f7c7b7;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 1px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 1px rgba(16, 24, 40, 0.03);
  --shadow: 0 4px 12px rgba(16, 24, 40, 0.08), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, 0.16), 0 4px 12px rgba(16, 24, 40, 0.08);
  --backdrop: rgba(12, 16, 23, 0.46);
  --header-bg: rgba(255, 255, 255, 0.86);

  --header-h: 56px;
  --sidebar-w: 244px;
  --content-max: 1360px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 140ms;
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1015;
    --bg-sidebar: #10141a;
    --surface: #151a21;
    --surface-2: #1a2028;
    --surface-3: #242b35;
    --surface-hover: #1d242d;
    --border: #28303b;
    --border-strong: #3a4351;
    --text: #e6e9ef;
    --text-2: #b3bbc8;
    --text-3: #8c95a4;
    --on-accent: #ffffff;
    --accent: #5b93ff;
    --accent-hover: #7aa7ff;
    --accent-solid: #2f6bdc;
    --accent-soft: rgba(91, 147, 255, 0.13);
    --accent-soft-border: rgba(91, 147, 255, 0.34);
    --accent-text: #90b6ff;
    --focus: #7aa7ff;
    --focus-ring: 0 0 0 3px rgba(122, 167, 255, 0.32);
    --selection: rgba(91, 147, 255, 0.3);
    --ok: #62d394;
    --ok-solid: #2fb468;
    --ok-bg: rgba(47, 180, 104, 0.13);
    --ok-border: rgba(47, 180, 104, 0.34);
    --info: #90b6ff;
    --info-solid: #5b93ff;
    --info-bg: rgba(91, 147, 255, 0.13);
    --info-border: rgba(91, 147, 255, 0.34);
    --warn: #f2bb5b;
    --warn-solid: #e6a23c;
    --warn-bg: rgba(230, 162, 60, 0.13);
    --warn-border: rgba(230, 162, 60, 0.34);
    --error: #ff8a8a;
    --error-solid: #ef4d4d;
    --error-bg: rgba(239, 77, 77, 0.13);
    --error-border: rgba(239, 77, 77, 0.36);
    --k-cloudflare: #ffa35c;
    --k-cloudflare-solid: #f38020;
    --k-cloudflare-bg: rgba(243, 128, 32, 0.15);
    --k-cloudflare-border: rgba(243, 128, 32, 0.4);
    --k-cdn: #bca5ff;
    --k-cdn-solid: #9b7bff;
    --k-cdn-bg: rgba(139, 92, 246, 0.16);
    --k-cdn-border: rgba(139, 92, 246, 0.4);
    --k-platform: #5ad6c3;
    --k-platform-solid: #19b4a0;
    --k-platform-bg: rgba(20, 184, 166, 0.14);
    --k-platform-border: rgba(20, 184, 166, 0.36);
    --k-direct: #6ccbef;
    --k-direct-solid: #22a8d4;
    --k-direct-bg: rgba(14, 165, 233, 0.14);
    --k-direct-border: rgba(14, 165, 233, 0.36);
    --k-private: #b3bccb;
    --k-private-solid: #8a96a8;
    --k-private-bg: rgba(148, 163, 184, 0.12);
    --k-private-border: rgba(148, 163, 184, 0.32);
    --k-unresolved: #95a0b0;
    --k-unresolved-solid: #6b7686;
    --k-unresolved-bg: rgba(148, 163, 184, 0.06);
    --k-unresolved-border: rgba(148, 163, 184, 0.38);
    --k-nxdomain: #f890ab;
    --k-nxdomain-solid: #e5486d;
    --k-nxdomain-bg: rgba(225, 29, 72, 0.14);
    --k-nxdomain-border: rgba(225, 29, 72, 0.36);
    --k-dangling: #ff9b80;
    --k-dangling-solid: #f46a3d;
    --k-dangling-bg: rgba(244, 106, 61, 0.15);
    --k-dangling-border: rgba(244, 106, 61, 0.4);
    --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 6px 16px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
    --backdrop: rgba(0, 0, 0, 0.6);
    --header-bg: rgba(21, 26, 33, 0.86);
  }
}

@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1015;
    --bg-sidebar: #10141a;
    --surface: #151a21;
    --surface-2: #1a2028;
    --surface-3: #242b35;
    --surface-hover: #1d242d;
    --border: #28303b;
    --border-strong: #3a4351;
    --text: #e6e9ef;
    --text-2: #b3bbc8;
    --text-3: #8c95a4;
    --on-accent: #ffffff;
    --accent: #5b93ff;
    --accent-hover: #7aa7ff;
    --accent-solid: #2f6bdc;
    --accent-soft: rgba(91, 147, 255, 0.13);
    --accent-soft-border: rgba(91, 147, 255, 0.34);
    --accent-text: #90b6ff;
    --focus: #7aa7ff;
    --focus-ring: 0 0 0 3px rgba(122, 167, 255, 0.32);
    --selection: rgba(91, 147, 255, 0.3);
    --ok: #62d394;
    --ok-solid: #2fb468;
    --ok-bg: rgba(47, 180, 104, 0.13);
    --ok-border: rgba(47, 180, 104, 0.34);
    --info: #90b6ff;
    --info-solid: #5b93ff;
    --info-bg: rgba(91, 147, 255, 0.13);
    --info-border: rgba(91, 147, 255, 0.34);
    --warn: #f2bb5b;
    --warn-solid: #e6a23c;
    --warn-bg: rgba(230, 162, 60, 0.13);
    --warn-border: rgba(230, 162, 60, 0.34);
    --error: #ff8a8a;
    --error-solid: #ef4d4d;
    --error-bg: rgba(239, 77, 77, 0.13);
    --error-border: rgba(239, 77, 77, 0.36);
    --k-cloudflare: #ffa35c;
    --k-cloudflare-solid: #f38020;
    --k-cloudflare-bg: rgba(243, 128, 32, 0.15);
    --k-cloudflare-border: rgba(243, 128, 32, 0.4);
    --k-cdn: #bca5ff;
    --k-cdn-solid: #9b7bff;
    --k-cdn-bg: rgba(139, 92, 246, 0.16);
    --k-cdn-border: rgba(139, 92, 246, 0.4);
    --k-platform: #5ad6c3;
    --k-platform-solid: #19b4a0;
    --k-platform-bg: rgba(20, 184, 166, 0.14);
    --k-platform-border: rgba(20, 184, 166, 0.36);
    --k-direct: #6ccbef;
    --k-direct-solid: #22a8d4;
    --k-direct-bg: rgba(14, 165, 233, 0.14);
    --k-direct-border: rgba(14, 165, 233, 0.36);
    --k-private: #b3bccb;
    --k-private-solid: #8a96a8;
    --k-private-bg: rgba(148, 163, 184, 0.12);
    --k-private-border: rgba(148, 163, 184, 0.32);
    --k-unresolved: #95a0b0;
    --k-unresolved-solid: #6b7686;
    --k-unresolved-bg: rgba(148, 163, 184, 0.06);
    --k-unresolved-border: rgba(148, 163, 184, 0.38);
    --k-nxdomain: #f890ab;
    --k-nxdomain-solid: #e5486d;
    --k-nxdomain-bg: rgba(225, 29, 72, 0.14);
    --k-nxdomain-border: rgba(225, 29, 72, 0.36);
    --k-dangling: #ff9b80;
    --k-dangling-solid: #f46a3d;
    --k-dangling-bg: rgba(244, 106, 61, 0.15);
    --k-dangling-border: rgba(244, 106, 61, 0.4);
    --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 6px 16px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
    --backdrop: rgba(0, 0, 0, 0.6);
    --header-bg: rgba(21, 26, 33, 0.86);
  }
}

/* ------------------------------------------------------------------------ */
/* 2. Base                                                                  */
/* ------------------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--border-strong) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

::selection {
  background: var(--selection);
}

h1,
h2,
h3,
h4 {
  line-height: 1.3;
  color: var(--text);
}

p {
  margin: 0 0 10px;
}

a {
  color: var(--accent-text);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

img,
svg {
  flex: none;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
}

code {
  font-size: 0.92em;
}

:not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

kbd {
  font-size: 11.5px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

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

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------------ */
/* 3. App shell                                                             */
/* ------------------------------------------------------------------------ */

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--accent-solid);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--dur) var(--ease);
}

.skip-link:focus {
  top: 10px;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "header header"
    "nav main";
}

/* Header */
.app-header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 0 18px;
  background: var(--surface);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius);
}

.brand-logo {
  width: 30px;
  height: 30px;
  display: block;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.brand-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.012em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.header-actions .theme-cycle {
  display: none;
}

.lang-toggle .seg-btn {
  min-width: 34px;
  justify-content: center;
  letter-spacing: 0.02em;
}

/* Current target (lib/session.js): a chip after the brand, cleared with its × */
.header-target {
  display: flex;
  min-width: 0;
  margin-left: 6px;
}

/* The chip shrinks (its value ellipsised) before the brand does. */
.app-header.has-target .brand {
  flex: none;
}

.target-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 360px;
  height: 30px;
  padding: 0 3px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1;
}

.target-chip-icon {
  flex: none;
  color: var(--accent);
}

.target-chip-label {
  flex: none;
  font-weight: 600;
  color: var(--text-3);
}

.target-chip-value {
  display: inline-flex;
  min-width: 0;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--text);
}

/* A long host name is cut in the middle: its lower labels give way, the registrable domain never
   shrinks (a shrink of a fraction of a pixel would already ellipsise it) and is cut only when it
   alone is wider than the chip. */
.target-chip-head,
.target-chip-tail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-chip-head {
  flex: 0 1 auto;
}

.target-chip-tail {
  flex: none;
  max-width: 100%;
}

.target-chip-clear {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
}

.target-chip-clear:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* Workspace switcher (app.js, ui/workspace-ui.js): after the target chip; in the Tools menu below 720 px */
.header-workspace {
  display: flex;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: 6px;
}

.ws-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 220px;
  height: 30px;
  padding: 0 8px 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
}

.ws-switch:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.ws-switch-icon {
  flex: none;
  color: var(--accent);
}

.ws-switch-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ws-switch.is-default .ws-switch-name {
  color: var(--text-2);
}

.ws-switch-chevron {
  flex: none;
  color: var(--text-3);
}

/* The Tools menu's workspace row (phones) */
.navmenu-workspace {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.navmenu-workspace-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.navmenu-workspace-label {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.navmenu-workspace-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.navmenu-workspace-name .icon {
  color: var(--accent);
}

.navmenu-workspace .btn {
  flex: none;
}

/* "Expected CA" / "Unexpected CA" after an issuer (ui/expected-ca.js) */
.eca-badge {
  margin-inline-start: 6px;
  vertical-align: 1px;
}

/* Thin activity bar under the header while a view is busy */
.busy-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.busy-bar::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: busy-slide 1.1s ease-in-out infinite;
}

.is-busy .busy-bar {
  opacity: 1;
}

@keyframes busy-slide {
  from {
    left: -30%;
  }

  to {
    left: 100%;
  }
}

/* Sidebar nav */
.app-nav {
  grid-area: nav;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}

.nav-group + .nav-group {
  margin-top: 18px;
}

.nav-group-label {
  padding: 0 10px 6px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-weight: 550;
  text-decoration: none;
  transition: background var(--dur), color var(--dur);
}

.nav-link .icon {
  color: var(--text-3);
  transition: color var(--dur);
}

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-link:hover .icon {
  color: var(--text-2);
}

.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.nav-link[aria-current="page"] .icon {
  color: var(--accent);
}

.nav-link.is-busy::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

/* A job running in this view (ui/jobs.js): a small progress ring after the label, also while
   another view is open. It replaces the busy dot. */
.nav-job {
  display: inline-flex;
  flex: none;
  margin-left: auto;
  line-height: 0;
}

.nav-link.has-job::after {
  display: none;
}

.nav-job-ring {
  display: block;
}

.nav-job-track,
.nav-job-bar {
  fill: none;
  stroke-width: 2.6;
}

.nav-job-track {
  stroke: var(--border-strong);
}

.nav-job-bar {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dasharray 0.4s var(--ease);
}

.nav-job.is-indeterminate .nav-job-ring {
  animation: job-spin 1.1s linear infinite;
}

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

/* "Notify me when done" in a running job's panel */
.job-notify {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-left: auto;
}

.job-notify[hidden],
.job-notify [hidden] {
  display: none;
}

/* Pressed (opted in): the label stays, the look says it is on. */
.job-notify .btn.is-on,
.job-notify .btn.is-on:hover:not(:disabled) {
  color: var(--ok);
  background: var(--ok-bg);
  box-shadow: inset 0 0 0 1px var(--ok);
}

.nav-foot {
  margin-top: auto;
  padding: 14px 6px 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  min-width: 0;
}

.nav-status .icon {
  color: var(--text-3);
}

.nav-status span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.link-reset {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

a.nav-status:hover,
button.nav-status:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-status-privacy .icon {
  color: var(--ok);
}

/* Short desktop screens (a 1366 × 768 laptop leaves ~650 px): every tool link of the six groups stays in view,
   with room for one more */
@media (min-width: 900.02px) and (max-height: 860px) {
  .app-nav {
    padding-top: 8px;
  }

  .nav-group + .nav-group {
    margin-top: 6px;
  }

  .nav-group-label {
    padding-bottom: 2px;
  }

  .nav-list {
    gap: 1px;
  }

  /* 15 links and room for one more; a link stays taller than a 24 px target. */
  .nav-link {
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .nav-foot {
    padding-top: 10px;
    gap: 4px;
  }
}

/* Tools button bar: replaces the groups below 720 px (see the phone media query) */
.nav-menu-bar {
  display: none;
}

.nav-menu-btn {
  flex: none;
}

.nav-menu-current {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.nav-menu-current .icon {
  color: var(--accent);
}

.nav-menu-current-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nav-menu-bar.is-busy .nav-menu-current::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

/* Tools menu (a Modal): the sidebar's groups as a grid of large targets */
.navmenu {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.navmenu-label {
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.navmenu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.navmenu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  line-height: 1.25;
  text-decoration: none;
  transition: background var(--dur), border-color var(--dur);
}

.navmenu-link .icon {
  color: var(--text-3);
}

.navmenu-link:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.navmenu-link[aria-current="page"] {
  border-color: var(--accent-soft-border);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.navmenu-link[aria-current="page"] .icon {
  color: var(--accent);
}

.navmenu-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The open tool at work: the sidebar's pulsing dot, after the check */
.navmenu-link.is-busy::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@media (max-width: 719.98px) {
  /* A sheet hanging from the top edge, right under the Tools button. */
  .navmenu-modal {
    width: 100%;
    max-width: calc(100vw - 16px);
    margin: 8px auto auto;
  }

  .navmenu-modal .modal-box {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .navmenu-modal .modal-body {
    padding: 14px;
  }
}

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

/* Main */
.app-main {
  grid-area: main;
  min-width: 0;
  padding: 28px 32px 40px;
  display: flex;
  flex-direction: column;
}

.app-main:focus {
  outline: none;
}

.page {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
}

.page-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  color: var(--accent);
}

.page-titles {
  min-width: 0;
  flex: 1;
}

.page-title {
  margin: 0;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.25;
}

.page-title:focus {
  outline: none;
}

.page-desc {
  margin: 4px 0 0;
  max-width: 80ch;
  color: var(--text-2);
}

/* "Result from 14:02 · Run again": the tool shows the result kept from the last visit */
.page-kept {
  margin-top: 8px;
}

/* One run of text, not a flex row: on a narrow screen it wraps like a sentence (the link as a
   whole), in a box whose corners suit two lines. */
.kept-note {
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.5;
}

.kept-note .kept-note-icon {
  margin-right: 6px;
  vertical-align: -2px;
  color: var(--text-3);
}

.kept-note-rerun {
  margin-left: 4px;
  white-space: nowrap;
}

.kept-note[data-kept="dropped"] {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.page-body {
  min-width: 0;
}

/* Offline, above a view that needs the network (app.js renderOfflineNote) */
.page-offline {
  margin-bottom: 20px;
}

.page-offline-tools {
  margin: 6px 0 0;
}

.page-offline-tools a {
  white-space: nowrap;
}

.page-loading {
  display: flex;
  justify-content: center;
  padding: 64px 0;
}

.app-footer {
  width: 100%;
  max-width: var(--content-max);
  margin: 48px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12.5px;
  color: var(--text-3);
}

.app-footer a {
  color: var(--text-2);
}

.app-footer .spacer {
  flex: 1;
}

.footer-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.footer-button kbd {
  text-decoration: none;
}

/* Keyboard shortcuts dialog */
.keys-table {
  width: 100%;
  border-collapse: collapse;
}

.keys-table th,
.keys-table td {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.keys-table tr:first-child th,
.keys-table tr:first-child td {
  padding-top: 0;
}

.keys-table th {
  width: 1%;
  padding-right: 18px;
  font-weight: 400;
  white-space: nowrap;
}

.keys-table td {
  color: var(--text-2);
}

.keys-combo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.keys-combo kbd {
  min-width: 24px;
  text-align: center;
  font-size: 12px;
}

.keys-plus {
  color: var(--text-3);
  font-size: 12px;
}

/* First-visit task picker (app.js, above the start page) and About › Where to start */
.start-picker {
  margin-bottom: 24px;
  padding: 16px 18px 18px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 55%);
}

.start-picker-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.start-picker-titles {
  flex: 1;
  min-width: 0;
}

.start-picker-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.start-picker-lead {
  margin: 3px 0 0;
  color: var(--text-2);
  font-size: 13.5px;
}

.start-picker-hide {
  margin: -6px -8px 0 0;
}

.start-tasks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 176px), 1fr));
  gap: 10px;
}

.start-task-item {
  min-width: 0;
}

.start-task {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 13px 14px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background var(--dur), border-color var(--dur), box-shadow var(--dur);
}

.start-task:hover {
  border-color: var(--accent-soft-border);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.start-task-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.start-task-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.start-task-title {
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.start-task-tool {
  color: var(--text-3);
  font-size: 12.5px;
}

.start-task-arrow {
  position: absolute;
  top: 14px;
  right: 12px;
  color: var(--text-3);
  transition: transform var(--dur), color var(--dur);
}

.start-task:hover .start-task-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

@media (max-width: 600px) {
  .start-picker {
    margin-bottom: 20px;
    padding: 12px 12px 12px 14px;
  }

  .start-picker-head {
    margin-bottom: 10px;
  }

  .start-picker-title {
    font-size: 15px;
  }

  .start-picker-lead {
    font-size: 13px;
  }

  .start-tasks {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .start-task {
    flex-direction: row;
    align-items: center;
    gap: 11px;
    padding: 7px 10px;
  }

  .start-task-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
  }

  .start-task-text {
    gap: 1px;
  }

  .start-task-tool {
    font-size: 12px;
  }

  .start-task-arrow {
    position: static;
    margin-left: auto;
  }

  /* The start page's strip: two columns of short chips, so the tool's own field stays near the top */
  .start-picker-lead {
    display: none;
  }

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

  .start-picker .start-task-item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .start-picker .start-task {
    gap: 9px;
    min-height: 44px;
    padding: 7px 9px;
  }

  .start-picker .start-task-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
  }

  .start-picker .start-task-icon .icon {
    width: 16px;
    height: 16px;
  }

  .start-picker .start-task-title {
    font-size: 13px;
    line-height: 1.25;
  }

  /* Still read out with the job (the link's name), not shown: the job says it. */
  .start-picker .start-task-tool {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .start-picker .start-task-arrow {
    display: none;
  }
}

/* The smallest phones: still two columns, the chips without their icons (the text needs the width) */
@media (max-width: 359.98px) {
  .start-picker {
    padding: 10px 10px 10px 12px;
  }

  .start-picker-title {
    font-size: 14px;
  }

  .start-picker .start-task-icon {
    display: none;
  }

  .start-picker .start-task {
    padding: 6px 8px;
  }

  .start-picker .start-task-title {
    font-size: 12.5px;
  }
}

/* Touch-only devices: no keyboard for the shortcuts to serve */
@media (hover: none) and (pointer: coarse) {
  .footer-button {
    display: none;
  }
}

.boot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 48px 0;
  color: var(--text-3);
}

.noscript {
  margin: 24px;
  padding: 16px 18px;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--text);
}

/* Settings dialog */
.settings-resolvers {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-resolver {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.settings-resolver:last-child {
  border-bottom: 0;
}

.settings-resolver.is-active {
  background: var(--accent-soft);
}

.settings-resolver-main {
  min-width: 0;
}

.settings-resolver-name {
  font-weight: 600;
}

.settings-resolver-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-3);
}

.settings-order {
  display: flex;
  gap: 2px;
}

.settings-pos {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent-solid);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
}

.settings-danger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
  background: var(--error-bg);
}

/* Phones & small tablets: nav becomes a horizontal, sticky scroller */
@media (max-width: 900px) {
  /* A field focused from the keyboard ('/', a start-page job) never lands under the sticky nav. */
  :root {
    scroll-padding-top: 60px;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "header"
      "nav"
      "main";
  }

  .app-header {
    position: relative;
    height: 54px;
    padding: 0 10px 0 14px;
  }

  .app-nav {
    position: sticky;
    top: 0;
    z-index: 35;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
    background: var(--surface);
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(1.5) blur(12px);
    backdrop-filter: saturate(1.5) blur(12px);
    border-right: 0;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }

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

  .nav-group {
    display: flex;
    flex: none;
  }

  .nav-group + .nav-group {
    margin: 0 0 0 6px;
    padding-left: 6px;
    border-left: 1px solid var(--border);
  }

  .nav-group-label,
  .nav-foot {
    display: none;
  }

  .nav-list {
    flex-direction: row;
  }

  .nav-link {
    padding: 6px 10px;
    white-space: nowrap;
    font-size: 13px;
    gap: 7px;
  }

  .nav-link.is-busy::after {
    position: static;
    margin: 0;
  }

  .target-chip-label {
    display: none;
  }

  .app-main {
    padding: 20px 16px 32px;
  }

  .page-header {
    gap: 12px;
    margin-bottom: 18px;
  }

  .page-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }

  .page-title {
    font-size: 20px;
  }
}

/* Below 720 px: one Tools button (a menu of every tool) instead of a strip showing three of them */
@media (max-width: 719.98px) {
  .app-nav {
    overflow: visible;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  /* The one navigation control on a phone: a full touch target */
  .btn.nav-menu-btn {
    --btn-h: 44px;
    padding: 0 14px;
    gap: 7px;
    font-size: 14px;
  }

  .app-nav .nav-group {
    display: none;
  }

  /* The Tools menu holds the workspace switcher here. */
  .header-workspace {
    display: none;
  }

  .nav-menu-bar {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
}

/* Up to 860 px a current target keeps the room: the workspace switcher shows its icon only (its
   name is the button's label and title). Below 720 px the Tools menu holds the switcher. */
@media (max-width: 860px) {
  .app-header.has-target .header-workspace {
    flex: none;
  }

  .app-header.has-target .ws-switch-name {
    display: none;
  }

  .app-header.has-target .ws-switch {
    gap: 3px;
    padding: 0 5px 0 7px;
  }
}

/* Small tablets: a current target takes the brand's subtitle place. */
@media (max-width: 760px) {
  .app-header.has-target .brand-sub {
    display: none;
  }
}

@media (max-width: 600px) {
  .brand-sub,
  .hide-sm,
  .header-actions .theme-toggle,
  .header-actions .gh-link,
  .filedrop-accept {
    display: none;
  }

  .header-actions .theme-cycle {
    display: inline-flex;
  }

  /* A current target takes the brand name's place; the logo stays the home link. */
  .app-header.has-target .brand-text {
    display: none;
  }

  .app-header.has-target {
    gap: 8px;
  }

  .header-target {
    flex: 1 1 auto;
    margin-left: 0;
  }

  .target-chip {
    gap: 4px;
    max-width: 100%;
    padding-left: 7px;
  }

  .target-chip-value {
    font-size: 12px;
  }

  .target-chip-clear {
    width: 22px;
    height: 22px;
  }

  .brand-logo {
    width: 28px;
    height: 28px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-sep {
    display: none;
  }

  .page-header {
    flex-wrap: wrap;
  }

  .page-actions {
    width: 100%;
  }

  .page-desc {
    font-size: 13.5px;
  }
}

/* ------------------------------------------------------------------------ */
/* 4. Components                                                            */
/* ------------------------------------------------------------------------ */

/* Icons */
.icon {
  display: inline-block;
  vertical-align: middle;
  flex: none;
}

/* Buttons */
.btn {
  --btn-h: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--btn-h);
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background var(--dur), border-color var(--dur), color var(--dur), box-shadow var(--dur);
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-solid);
  color: var(--on-accent);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

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

:root[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: #3b78ea;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary:hover:not(:disabled) {
    background: #3b78ea;
  }
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--text-3);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--error-solid);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.93);
}

.btn-sm {
  --btn-h: 28px;
  padding: 0 10px;
  gap: 5px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.btn-lg {
  --btn-h: 40px;
  padding: 0 18px;
  font-size: 14.5px;
}

.btn-icon,
.btn-icon-only {
  width: var(--btn-h);
  padding: 0;
}

.btn.is-copied {
  color: var(--ok);
}

.btn.is-busy {
  cursor: progress;
}

.btn.is-busy .icon {
  display: none;
}

.btn .spinner-inline {
  width: 13px;
  height: 13px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-xs);
}

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

/* Copy summary + Plain text (ui/summary-button.js): one group that wraps as a unit */
.sum-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.sum-fallback-text {
  width: 100%;
  resize: vertical;
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.field-req {
  color: var(--error);
}

.field-opt {
  font-weight: 400;
  color: var(--text-3);
}

.field-hint {
  font-size: 12.5px;
  color: var(--text-3);
}

.field-error {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--error);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
  opacity: 1;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--text-3);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.textarea {
  min-height: 96px;
  line-height: 1.5;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808898' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
}

.input-sm,
.select-sm {
  min-height: 30px;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 13px;
}

.input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.field.has-error .input,
.field.has-error .textarea,
.field.has-error .select {
  border-color: var(--error);
}

.fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fieldset > legend {
  padding: 0;
  margin-bottom: 8px;
}

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

.choice-inline .choice-list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.choice-bulk {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: -2px 0 8px;
}

.check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  align-items: start;
}

.check-input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent-solid);
  cursor: pointer;
}

.check-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.check-hint {
  grid-column: 2;
  font-size: 12.5px;
  color: var(--text-3);
}

.check.is-disabled .check-label {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Switch variant */
.check-switch {
  grid-template-columns: minmax(0, 1fr);
}

.check-switch .check-hint {
  grid-column: 1;
  padding-left: 44px;
}

.switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background var(--dur), border-color var(--dur);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur) var(--ease);
}

.switch-input:checked + .check-label .switch-track {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
}

.switch-input:checked + .check-label .switch-thumb {
  transform: translateX(14px);
}

.switch-input:focus-visible + .check-label .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}

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

.seg-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

:root[data-theme="dark"] .seg-btn[aria-pressed="true"] {
  background: var(--surface-3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seg-btn[aria-pressed="true"] {
    background: var(--surface-3);
  }
}

.seg-icon-only {
  width: 28px;
  padding: 0;
  justify-content: center;
}

.segmented-sm .seg-btn {
  height: 24px;
  font-size: 12px;
}

.segmented-sm .seg-icon-only {
  width: 24px;
}

/* Badges */
.badge {
  --b-fg: var(--text-2);
  --b-bg: var(--surface-2);
  --b-bd: var(--border);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 21px;
  padding: 0 8px;
  border: 1px solid var(--b-bd);
  border-radius: var(--radius-pill);
  background: var(--b-bg);
  color: var(--b-fg);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.badge .icon {
  margin-left: -2px;
}

.badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
  /* The badge itself uses line-height 1; give the clipped text box room for descenders
     (g, p, y) so overflow: hidden does not cut them off. */
  line-height: 1.3;
}

.badge.mono {
  font-family: var(--font-mono);
  font-weight: 550;
}

.badge-accent {
  --b-fg: var(--accent-text);
  --b-bg: var(--accent-soft);
  --b-bd: var(--accent-soft-border);
}

.badge-ok {
  --b-fg: var(--ok);
  --b-bg: var(--ok-bg);
  --b-bd: var(--ok-border);
}

.badge-info {
  --b-fg: var(--info);
  --b-bg: var(--info-bg);
  --b-bd: var(--info-border);
}

.badge-warn {
  --b-fg: var(--warn);
  --b-bg: var(--warn-bg);
  --b-bd: var(--warn-border);
}

.badge-error {
  --b-fg: var(--error);
  --b-bg: var(--error-bg);
  --b-bd: var(--error-border);
}

.badge-cloudflare {
  --b-fg: var(--k-cloudflare);
  --b-bg: var(--k-cloudflare-bg);
  --b-bd: var(--k-cloudflare-border);
}

.badge-cloudflare .icon {
  color: var(--k-cloudflare-solid);
}

.badge-cdn {
  --b-fg: var(--k-cdn);
  --b-bg: var(--k-cdn-bg);
  --b-bd: var(--k-cdn-border);
}

.badge-platform {
  --b-fg: var(--k-platform);
  --b-bg: var(--k-platform-bg);
  --b-bd: var(--k-platform-border);
}

.badge-direct {
  --b-fg: var(--k-direct);
  --b-bg: var(--k-direct-bg);
  --b-bd: var(--k-direct-border);
}

.badge-private {
  --b-fg: var(--k-private);
  --b-bg: var(--k-private-bg);
  --b-bd: var(--k-private-border);
}

.badge-unresolved {
  --b-fg: var(--k-unresolved);
  --b-bg: var(--k-unresolved-bg);
  --b-bd: var(--k-unresolved-border);
  border-style: dashed;
}

.badge-nxdomain {
  --b-fg: var(--k-nxdomain);
  --b-bg: var(--k-nxdomain-bg);
  --b-bd: var(--k-nxdomain-border);
}

.badge-dangling {
  --b-fg: var(--k-dangling);
  --b-bg: var(--k-dangling-bg);
  --b-bd: var(--k-dangling-border);
}

/* Severity glyphs */
.sev {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
}

.sev-ok {
  color: var(--ok);
}

.sev-info {
  color: var(--info);
}

.sev-warn {
  color: var(--warn);
}

.sev-error {
  color: var(--error);
}

/* Source status (ui/source-status.js): a cell a failed source left empty, never a silent dash */
.na-mark {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--warn);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}

.na-mark-text {
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.src-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.src-chips[hidden] {
  display: none;
}

/* The group takes the keyboard focus back when the Retry that had it is gone. */
.src-chips:focus {
  outline: none;
}

.src-chips:focus-visible {
  border-radius: var(--radius);
  box-shadow: var(--focus-ring);
}

.src-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  min-height: 28px;
  max-width: 100%;
  padding: 2px 4px 2px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
}

.src-chip .spinner-inline {
  width: 12px;
  height: 12px;
}

.src-chip-name {
  font-weight: 650;
}

.src-chip-value {
  padding-right: 6px;
  color: var(--text-3);
}

.src-chip[data-state="ok"] .icon {
  color: var(--ok);
}

.src-chip[data-state="idle"] {
  border-style: dashed;
  color: var(--text-3);
}

/* A used-up free quota or a service that is down: amber, like the Subdomains chips. */
.src-chip[data-state="failed"] {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.src-chip[data-state="failed"] .icon,
.src-chip[data-state="failed"] .src-chip-value {
  color: var(--warn);
}

.src-chip .btn {
  min-height: 24px;
  padding-block: 0;
}

/* Alerts */
.alert {
  --a-fg: var(--info);
  --a-bg: var(--info-bg);
  --a-bd: var(--info-border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--a-bd);
  border-radius: var(--radius);
  background: var(--a-bg);
  color: var(--text);
}

.alert-ok {
  --a-fg: var(--ok);
  --a-bg: var(--ok-bg);
  --a-bd: var(--ok-border);
}

.alert-warn {
  --a-fg: var(--warn);
  --a-bg: var(--warn-bg);
  --a-bd: var(--warn-border);
}

.alert-error {
  --a-fg: var(--error);
  --a-bg: var(--error-bg);
  --a-bd: var(--error-border);
}

.alert-icon {
  margin-top: 1px;
  color: var(--a-fg);
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: 650;
}

.alert-message {
  color: var(--text-2);
}

.alert-title + .alert-message {
  margin-top: 2px;
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.alert-details {
  margin-top: 6px;
  font-size: 12.5px;
}

.alert-details summary {
  cursor: pointer;
  color: var(--text-3);
}

.alert-details code {
  display: block;
  margin-top: 6px;
  white-space: pre-wrap;
}

.alert-compact {
  padding: 8px 12px;
  font-size: 13px;
}

.alert .btn-icon {
  margin: -4px -6px -4px 0;
}

/* Cards & sections */
.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.card-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
}

.card-titles {
  min-width: 0;
  flex: 1;
}

.card-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
}

.card-subtitle {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--text-3);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.card-body {
  padding: 16px;
}

.card-body-flush {
  padding: 0;
}

.card-foot {
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface-2);
}

.section + .section {
  margin-top: 32px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.section-titles {
  min-width: 0;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-desc {
  margin: 3px 0 0;
  max-width: 80ch;
  font-size: 13.5px;
  color: var(--text-2);
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.stat {
  --stat-accent: transparent;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px 12px 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: inherit;
  font: inherit;
  text-align: left;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--stat-accent);
}

.stat-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
}

.stat-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-hint {
  font-size: 12px;
  color: var(--text-3);
}

.stat-button {
  cursor: pointer;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.stat-button:hover {
  border-color: var(--border-strong);
}

.stat-button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.stat-v-accent {
  --stat-accent: var(--accent);
}

.stat-v-ok {
  --stat-accent: var(--ok-solid);
}

.stat-v-info {
  --stat-accent: var(--info-solid);
}

.stat-v-warn {
  --stat-accent: var(--warn-solid);
}

.stat-v-error {
  --stat-accent: var(--error-solid);
}

.stat-v-cloudflare {
  --stat-accent: var(--k-cloudflare-solid);
}

.stat-v-cdn {
  --stat-accent: var(--k-cdn-solid);
}

.stat-v-platform {
  --stat-accent: var(--k-platform-solid);
}

.stat-v-direct {
  --stat-accent: var(--k-direct-solid);
}

.stat-v-private {
  --stat-accent: var(--k-private-solid);
}

.stat-v-unresolved {
  --stat-accent: var(--k-unresolved-solid);
}

.stat-v-nxdomain {
  --stat-accent: var(--k-nxdomain-solid);
}

.stat-v-dangling {
  --stat-accent: var(--k-dangling-solid);
}

/* Key-value list */
.kv {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(110px, max-content) minmax(0, 1fr);
  column-gap: 20px;
}

.kv-row {
  display: contents;
}

.kv-key,
.kv-value {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.kv-row:last-child > .kv-key,
.kv-row:last-child > .kv-value {
  border-bottom: 0;
}

.kv-key {
  font-size: 13px;
  font-weight: 550;
  color: var(--text-3);
}

.kv-hint {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
}

.kv-value {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.kv-value-text {
  flex: 1;
  min-width: 0;
}

.kv-value .copy-btn {
  margin: -4px 0;
}

@media (min-width: 1100px) {
  .kv-cols-2 {
    grid-template-columns: minmax(100px, max-content) minmax(0, 1fr) minmax(100px, max-content) minmax(0, 1fr);
  }
}

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

  .kv-key {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .kv-value {
    padding-top: 2px;
  }
}

/* Code blocks */
.codeblock {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.codeblock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 3px 6px 3px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 650;
  color: var(--text-3);
}

.codeblock-pre {
  margin: 0;
  max-height: 420px;
  padding: 12px 14px;
  overflow: auto;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 2;
}

.codeblock-wrap .codeblock-pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Truncated lists */
.tlist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tlist.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.tlist-inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.tlist-item {
  overflow-wrap: anywhere;
}

.tlist-more {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tlist-more:hover {
  text-decoration: underline;
}

/* Disclosure */
.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.disclosure-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  border-radius: var(--radius);
}

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

.disclosure-summary:hover {
  background: var(--surface-hover);
}

.disclosure-chevron {
  color: var(--text-3);
  transition: transform var(--dur) var(--ease);
}

.disclosure[open] > .disclosure-summary .disclosure-chevron {
  transform: rotate(90deg);
}

/* A summary that is a heading (Disclosure({ heading })) reads like any other summary */
.disclosure-heading {
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
}

.disclosure-body {
  padding: 4px 14px 14px;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Tabs */
.tablist-scroll {
  margin-bottom: 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}

.tablist {
  display: flex;
  gap: 2px;
  min-width: max-content;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px 11px;
  border: 0;
  border-radius: 6px 6px 0 0;
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur), background var(--dur);
}

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

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

.tab.is-selected {
  color: var(--text);
}

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

.tab:focus-visible {
  outline-offset: -2px;
}

.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tab.is-selected .tab-badge {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* A status count keeps its colour on the selected tab too (the accent is for a plain count). */
.tab-badge-warn,
.tab.is-selected .tab-badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.tab-badge-error,
.tab.is-selected .tab-badge-error {
  background: var(--error-bg);
  color: var(--error);
}

.tab-badge-ok,
.tab.is-selected .tab-badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.tabpanel:focus-visible {
  outline-offset: 4px;
  border-radius: var(--radius-xs);
}

/* Progress */
.progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}

.progress-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-weight: 600;
}

.progress-value {
  white-space: nowrap;
  color: var(--text-3);
}

.progress-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s var(--ease);
}

.progress.is-ok .progress-fill {
  background: var(--ok-solid);
}

.progress.is-warn .progress-fill {
  background: var(--warn-solid);
}

.progress.is-error .progress-fill {
  background: var(--error-solid);
}

.progress.is-indeterminate .progress-fill {
  position: absolute;
  top: 0;
  width: 35%;
  animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
  from {
    left: -35%;
  }

  to {
    left: 100%;
  }
}

/* Spinner */
.spinner-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
}

.spinner {
  display: inline-block;
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.8;
  animation: spin 0.7s linear infinite;
}

.spinner-sm .spinner {
  width: 12px;
  height: 12px;
}

.spinner-lg .spinner {
  width: 24px;
  height: 24px;
  border-width: 2.5px;
}

.spinner-label {
  font-size: 13px;
}

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

/* Toasts */
.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  --t-accent: var(--info-solid);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--t-accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.18s var(--ease);
  transition: opacity 0.18s, transform 0.18s;
}

.toast-success {
  --t-accent: var(--ok-solid);
}

.toast-warn {
  --t-accent: var(--warn-solid);
}

.toast-error {
  --t-accent: var(--error-solid);
}

.toast-icon {
  margin-top: 2px;
  color: var(--t-accent);
}

.toast-body {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
  overflow-wrap: anywhere;
}

.toast-title {
  font-weight: 650;
}

.toast-message {
  color: var(--text-2);
}

.toast-title + .toast-message {
  margin-top: 1px;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
}

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

@media (max-width: 600px) {
  .toast-region {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
}

/* Modal */
.modal {
  width: 560px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}

.modal-sm {
  width: 440px;
}

.modal-lg {
  width: 820px;
}

.modal::backdrop {
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.modal[open] {
  animation: modal-in 0.16s var(--ease);
}

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

.modal-box {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 12px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 18px;
  overflow: auto;
}

.modal-message {
  margin: 0;
  color: var(--text-2);
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface-2);
}

/* Globalping consent + cost dialog of a one-click send (ui/globalping-gate.js) */
.gp-confirm p {
  margin: 0;
}

.gp-confirm [data-gp="confirm-privacy"] {
  color: var(--text-2);
  font-size: 13px;
}

/* File drop */
.filedrop {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}

.filedrop:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.filedrop.is-dragover {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  box-shadow: var(--focus-ring);
}

.filedrop-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}

.filedrop-text {
  flex: 1;
  min-width: 0;
}

.filedrop-title {
  font-weight: 650;
}

.filedrop-hint {
  font-size: 12.5px;
  color: var(--text-3);
}

.filedrop-accept {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.filedrop-status {
  flex-basis: 100%;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ok);
}

.filedrop-status:empty {
  display: none;
}

.filedrop-status.is-error {
  color: var(--error);
}

.filedrop-input {
  display: none;
}

.filedrop-compact {
  gap: 10px;
  padding: 10px 12px;
}

.filedrop-compact .filedrop-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-2);
}

.empty-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text-3);
}

.empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.empty-message {
  max-width: 56ch;
  font-size: 13.5px;
}

.empty-action {
  margin-top: 10px;
}

.empty-compact {
  padding: 22px 16px;
}

.empty-compact .empty-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

/* External links */
.ext-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  overflow-wrap: anywhere;
}

.ext-link-icon {
  opacity: 0.7;
}

/* Data table */
.dt {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.dt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.dt-search {
  position: relative;
  flex: 1 1 220px;
  max-width: 360px;
}

.dt-search-icon {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.dt-search-input {
  padding-left: 30px;
}

.dt-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.dt-export {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.dt-scroll {
  /* Containing block for absolutely positioned descendants (.sr-only labels in cells), so
     they are clipped with the table instead of widening the page on phones. */
  position: relative;
  max-height: min(72vh, 780px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  scrollbar-width: thin;
}

.dt-scroll-free {
  max-height: none;
}

.dt-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.dt-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
}

.dt-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  /* Hostnames, IPs and badges must not break mid-token; the table scrolls instead.
     Text-heavy columns opt in to wrapping with the column option `wrap: true`. */
  white-space: nowrap;
}

.dt-table td.dt-wrap {
  min-width: 14rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

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

.dt-table tbody .dt-row:hover td {
  background: var(--surface-hover);
}

.dt-dense td {
  padding: 5px 10px;
}

.dt-dense th {
  padding: 6px 10px;
}

.dt-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.dt-sort:hover {
  color: var(--text);
}

.dt-sort-icon {
  color: var(--text-3);
  opacity: 0.55;
}

.is-sorted .dt-sort-icon {
  color: var(--accent);
  opacity: 1;
}

.dt-align-end {
  text-align: right;
}

.dt-table th.dt-align-end .dt-sort {
  flex-direction: row-reverse;
}

.dt-align-center {
  text-align: center;
}

.dt-table td.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.dt-table td.nowrap {
  white-space: nowrap;
}

.dt-null {
  color: var(--text-3);
}

.dt-cell-error {
  color: var(--error);
}

.dt-row.is-clickable {
  cursor: pointer;
}

.dt-row:focus-visible {
  outline-offset: -2px;
}

.dt-table .dt-expander-col,
.dt-table .dt-expander {
  width: 36px;
  padding-right: 0;
}

.dt-expand-btn {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--text-3);
  cursor: pointer;
}

.dt-expand-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.dt-expand-btn .icon {
  transition: transform var(--dur) var(--ease);
}

.dt-expand-btn[aria-expanded="true"] .icon {
  transform: rotate(90deg);
}

.dt-table .dt-details > td {
  padding: 0;
  background: var(--surface-2);
  white-space: normal;
}

.dt-details-body {
  padding: 12px 16px 14px 48px;
}

.dt-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  font-size: 12.5px;
  color: var(--text-3);
}

.dt-more {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dt-empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.dt-empty-inner {
  display: flex;
  justify-content: center;
  padding: 28px 16px;
}

/* ------------------------------------------------------------------------ */
/* 5. Utilities                                                             */
/* ------------------------------------------------------------------------ */

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--font-mono);
}

.num {
  font-variant-numeric: tabular-nums;
}

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

.text-2 {
  color: var(--text-2);
}

.text-sm {
  font-size: 13px;
}

.text-xs {
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

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

.break {
  overflow-wrap: anywhere;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.spacer {
  flex: 1;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

@media (max-width: 1100px) {
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.clipboard-proxy {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

/* Reduced motion: keep status animations understandable but calm. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .spinner {
    animation-duration: 1.8s !important;
    animation-iteration-count: infinite !important;
  }

  .progress.is-indeterminate .progress-fill,
  .busy-bar::before {
    left: 0;
    width: 100%;
    opacity: 0.45;
    animation: none !important;
  }

  .nav-link.is-busy::after,
  .nav-menu-bar.is-busy .nav-menu-current::after,
  .navmenu-link.is-busy::after {
    animation: none !important;
  }

  /* An indeterminate job ring stands still as a quarter arc. */
  .nav-job.is-indeterminate .nav-job-ring {
    animation: none !important;
  }
}

/* Forced colors (Windows high contrast): keep outlines and borders visible. */
@media (forced-colors: active) {
  .badge,
  .btn,
  .seg-btn[aria-pressed="true"],
  .nav-link[aria-current="page"],
  .navmenu-link[aria-current="page"] {
    border: 1px solid CanvasText;
  }
}

/* The header app.js puts on top of the page while it prints (beforeprint → afterprint). */
.print-head {
  display: none;
}

/*
 * Print: the light palette whatever the theme (the dark tokens are screen-only, section 1), no
 * shell, forms or controls, every row of a table on one page where it fits, code and long values
 * wrapped instead of scrolled. app.js opens every <details> for the print and adds .print-head
 * (app, page title, UTC time, permalink); views hide their own forms in their stylesheets.
 */
@media print {
  @page {
    margin: 14mm 12mm;
  }

  :root {
    --bg: #fff;
    --surface: #fff;
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: none;
  }

  html,
  body {
    background: #fff;
  }

  body {
    min-height: 0;
    overflow: visible;
    font-size: 12.5px;
  }

  .app-header,
  .app-nav,
  .start-picker,
  .app-footer,
  .page-header,
  .toast-region,
  .skip-link,
  .busy-bar,
  dialog,
  .progress,
  .btn,
  .sum-actions,
  .segmented,
  .field,
  .check,
  .fieldset,
  .filedrop,
  .dt-toolbar,
  .dt-more,
  .dt-expander-col,
  .dt-expander,
  .disclosure-chevron,
  .dt-sort-icon,
  .tab:not(.is-selected),
  .no-print {
    display: none !important;
  }

  .app {
    display: block;
    min-height: 0;
  }

  .app-main {
    display: block;
    padding: 0;
  }

  .page {
    max-width: none;
  }

  .print-head {
    display: block;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-strong);
  }

  .print-head-title {
    font-size: 17px;
    color: var(--text);
  }

  .print-head-meta {
    margin-top: 2px;
    color: var(--text-2);
    font-size: 11px;
    overflow-wrap: anywhere;
  }

  .print-permalink {
    color: var(--text-2);
    text-decoration: none;
  }

  /* The selected tab names the panel below it; the other tabs are not printed. */
  .tablist-scroll {
    overflow: visible;
  }

  .tab.is-selected {
    padding: 0 0 6px;
    color: var(--text);
    font-size: 14px;
  }

  .tab.is-selected::after {
    display: none;
  }

  /* Scrollers print whole; long cells and code wrap inside the page width. */
  .dt-scroll,
  .codeblock,
  .codeblock-pre {
    max-height: none !important;
    overflow: visible !important;
  }

  .codeblock-pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  /* A code block's head without a label held only its (hidden) copy button. */
  .codeblock-head:not(:has(.codeblock-label)) {
    display: none;
  }

  /* Tighter tables: most host names and addresses fit whole; a longer one still wraps. */
  .dt-table {
    font-size: 11px;
  }

  .dt-table th,
  .dt-table td {
    padding: 5px 7px;
  }

  .dt-table th {
    position: static;
    white-space: normal;
    font-size: 10.5px;
  }

  /*
   * break-word, not anywhere: a cell breaks inside a word only when the word cannot fit on a line
   * of its own, so a column never shrinks below its longest word ("Certificate", a resolver's
   * name). Addresses and host names stay whole (nowrap in the views' print blocks).
   */
  .dt-table td {
    white-space: normal;
    overflow-wrap: break-word;
  }

  /* The same inside a cell's list (host names, CNAMEs); addresses are nowrap per view. */
  .tlist-item {
    overflow-wrap: break-word;
  }

  /*
   * A sortable header's label sits in a button, which Chrome leaves out of the header row it
   * repeats on the next page: without the button box the label is plain header text.
   */
  .dt-sort {
    display: contents;
  }

  :focus,
  :focus-visible {
    outline: none !important;
  }

  .dt-table thead {
    display: table-header-group;
  }

  tr,
  li,
  .alert,
  .stat,
  .kv-row,
  .codeblock,
  .card-head {
    break-inside: avoid;
  }

  h1,
  h2,
  h3,
  .card-head,
  .section-title {
    break-after: avoid;
  }

  a {
    color: inherit;
  }
}
